Compare commits
No commits in common. "dev" and "fix_orderCatalog_reload" have entirely different histories.
dev
...
fix_orderC
243
CHANGELOG.md
243
CHANGELOG.md
|
@ -1,246 +1,3 @@
|
|||
# Version 25.00 - 2025-01-14
|
||||
|
||||
### Added 🆕
|
||||
|
||||
- chore: refs #7056 move test by:jorgep
|
||||
- feat: refs #7050 7050 add object check by:Jtubau
|
||||
- feat: refs #7050 7050 add test to isEmpty() by:Jtubau
|
||||
- feat: refs #7056 add tests in FormModel by:jorgep
|
||||
- feat: refs #7056 update route meta information and add FormModel tests by:jorgep
|
||||
- feat: refs #7074 tests for fns setData(), parseDms() and showFormDialog() (7074-makeFrontTestToVnDmsList) by:Jtubau
|
||||
- feat: refs #7079 created VnLocation front test by:provira
|
||||
- feat: refs #7189 add Accept-Language header to axios requests by:jorgep
|
||||
- feat: refs #7924 add custom inspection checkbox and localization support by:jgallego
|
||||
- feat: refs #7924 update custom inspection label for clarity in English and Spanish locales by:jgallego
|
||||
- feat: refs #8004 enhance FetchedTags component with column support and styling updates by:pablone
|
||||
- feat: refs #8004 hide rightFilter by:pablone
|
||||
- feat: refs #8246 added new field in list by:Jon
|
||||
- feat: refs #8266 added descriptor to item name by:jtubau
|
||||
- feat: refs #8293 add zone filter by:Jtubau
|
||||
- feat: refs #8293 include zone data in each record by:Jtubau
|
||||
- fix: refs #8004 more list style issues by:pablone
|
||||
- fix: refs #8004 some style issues on all list by:pablone
|
||||
- style: refs #8004 update layout and styling in FetchedTags and ItemList components by:pablone
|
||||
- style: update CustomerBalance.vue to set label color by:jgallego
|
||||
|
||||
### Changed 📦
|
||||
|
||||
- perf: order by:alexm
|
||||
- perf: redirect transition list to card by:alexm
|
||||
- perf: refs #8201 onDataSaved fetch by:Jon
|
||||
- perf: revert processData by:alexm
|
||||
- perf: simplify if by:alexm
|
||||
- perf: simplify if (perf_redirectTransition) by:alexm
|
||||
- refactor: item fixedPrice by:Jon
|
||||
- refactor: refs #7050 refactorize by:jtubau
|
||||
- refactor: refs #7050 removed blank spaces by:jtubau
|
||||
- refactor: refs #7052 move EditTableCellValueForm tests to a new location and enhance test coverage by:jgallego
|
||||
- refactor: refs #7052 remove unnecessary console logs from EditTableCellValueForm tests by:jgallego
|
||||
- refactor: refs #7074 move dms constant to global scope by:Jtubau
|
||||
- refactor: refs #7079 removed useless code by:provira
|
||||
- refactor: refs #7924 simplify custom inspection icon rendering in ExtraCommunity.vue by:jgallego
|
||||
- refactor: refs #8004 remove console log from CardSummary component on mount by:pablone
|
||||
- refactor: refs #8004 remove consoleLogs by:pablone
|
||||
- refactor: refs #8004 remove unused stateStore import in InvoiceInList.vue by:pablone
|
||||
- refactor: refs #8004 remove unused travelFilterRef and chip definition in TravelList.vue by:pablone
|
||||
- refactor: refs #8004 replace VnSelect with VnSelectWorker in CustomerList component by:pablone
|
||||
- refactor: refs #8201 added onMounted to stablish the value to show icons by:Jon
|
||||
- refactor: refs #8201 deleted condition by:Jon
|
||||
- refactor: refs #8201 deleted log by:Jon
|
||||
- refactor: refs #8201 deleted logs by:Jon
|
||||
- refactor: refs #8266 8266 change expedition item name by:Jtubau
|
||||
- refactor: refs #8266 change expedition label by:Jtubau
|
||||
- refactor: refs #8293 remove redundant attributes by:Jtubau
|
||||
- refactor: refs #8320 changed folder names from "specs" to "**tests**" by:provira
|
||||
- refactor: refs #8320 moved front tests to their respective sections by:provira
|
||||
- refactor: refs #8813 removed unused class property by:provira
|
||||
|
||||
### Fixed 🛠️
|
||||
|
||||
- fix: discount class by:PAU ROVIRA ROSALENY
|
||||
- fix: duplicate transalation after test to dev by:alexm
|
||||
- fix: fix translations by:carlossa
|
||||
- fix: redirect to sales when confirming lines by:Jon
|
||||
- fix: refs #7050 delete import added by mistake by:Jtubau
|
||||
- fix: refs #7133 handleSalesModelValue function to handle empty input by:jorgep
|
||||
- fix: refs #7189 update user language on sessionStorage by:jorgep
|
||||
- fix: refs #7935 remove unused 'companyFk' column from InvoiceInList component by:jorgep
|
||||
- fix: refs #8004 more list style issues by:pablone
|
||||
- fix: refs #8004 some style issues on all list by:pablone
|
||||
- fix: refs #8004 update label for daysOnward in TravelFilter component and add translations by:pablone
|
||||
- fix: refs #8004 vnTable card with and add permanent labels by:pablone
|
||||
- fix: refs #8201 added onDataSaved emi to refetch when cahnges are made by:Jon
|
||||
- fix: refs #8201 use arrayData to fix the error by:Jon
|
||||
- fix: refs #8314 space between label and value by:jtubau
|
||||
- fix: refs #8813 fixed ClaimLines format by:provira
|
||||
- fix: update button sizes in ExtraCommunity.vue for better visibility by:jgallego
|
||||
- perf: revert processData by:alexm
|
||||
- refactor: item fixedPrice by:Jon
|
||||
|
||||
# Version 24.52 - 2024-01-07
|
||||
|
||||
### Added 🆕
|
||||
|
||||
- chore: refs #8197 remove console log by:alexm
|
||||
- chore: refs #8197 replace name by:alexm
|
||||
- chore: refs #8197 unnecessary file by:alexm
|
||||
- feat: #8110 apply mixin in quasar components by:Javier Segarra
|
||||
- feat(Account & AccountRole): refs #8197 add VnCardMain by:alexm
|
||||
- feat: addDptoLink by:Jtubau
|
||||
- feat: added restore ticket function in ticket descriptor menu by:Jon
|
||||
- feat: add support service wip by:jorgep
|
||||
- feat: focus menu searchbar by:jorgep
|
||||
- feat: make additional data object by:jorgep
|
||||
- feat: message to grant access by:jorgep
|
||||
- feat: refs #6583 add default param by:jorgep
|
||||
- feat: refs #6583 add destination opt filter by:jorgep
|
||||
- feat: refs #6583 add icon by:jorgep
|
||||
- feat: refs #6583 add locale by:jorgep
|
||||
- feat: refs #7072 added test to computed fn total by:Jtubau
|
||||
- feat: refs #7235 update invoice out global form to fetch config based on serial type by:jgallego
|
||||
- feat: refs #7301 add exclude inventory supplier from list by:pablone
|
||||
- feat: refs #7301 enhance VnDateBadge styling and improve ItemLastEntries component by:pablone
|
||||
- feat: refs #7882 Added distribution point by:guillermo
|
||||
- feat: refs #7882 Added longitude & latitude by:guillermo
|
||||
- feat: refs #7936 add autocomplete on tab fn by:jorgep
|
||||
- feat: refs #7936 add company filter by:jorgep
|
||||
- feat: refs #7936 add currency check before fetching by:jorgep
|
||||
- feat: refs #7936 add dueDated field by:jorgep
|
||||
- feat: refs #7936 add number validation to VnInputNumber & new daysAgo filter in InvoiceInFilter by:jorgep
|
||||
- feat: refs #7936 add optionCaption by:jorgep
|
||||
- feat: refs #7936 add row click navigation to InvoiceInSerial by:jorgep
|
||||
- feat: refs #7936 add unit tests by:jorgep
|
||||
- feat: refs #7936 add useAccountShortToStandard composable by:jorgep
|
||||
- feat: refs #7936 calculate exchange & update taxable base by:jorgep
|
||||
- feat: refs #7936 enhance downloadFile function to support opening in a new tab by:jorgep
|
||||
- feat: refs #7936 enhance getTotal fn & add unit tests by:jorgep
|
||||
- feat: refs #7936 enhance vn-select by:jorgep
|
||||
- feat: refs #7936 improve optionLabel logic in InvoiceInVat component for better handling of numeric values by:jorgep
|
||||
- feat: refs #7936 limit decimal places by:jorgep
|
||||
- feat: refs #7936 make fields required by:jorgep
|
||||
- feat: refs #7936 show country code & isVies fields by:jorgep
|
||||
- feat: refs #7936 show id & value by:jorgep
|
||||
- feat: refs #7936 simplify optionLabel wip by:jorgep
|
||||
- feat: refs #7936 update 'isVies' label to use global translation key by:jorgep
|
||||
- feat: refs #7936 update option labels in InvoiceIn components for better clarity by:jorgep
|
||||
- feat: refs #7936 use default invoice data by:jorgep
|
||||
- feat: refs #8001 change request by:robert
|
||||
- feat: refs #8001 ticketExpeditionGrafana by:robert
|
||||
- feat: refs #8194 created VnSelectWorker component and use it in Lilium by:Jon
|
||||
- feat: refs #8197 better leftMenu and VnCardMain improvements by:alexm
|
||||
- feat: refs #8197 default leftMenu by:alexm
|
||||
- feat: refs #8197 default sectionName by:alexm
|
||||
- feat: refs #8197 keepData in VnSection by:alexm
|
||||
- feat: refs #8197 vnTableFilter by:alexm
|
||||
- feat: refs #8197 working rightMenu by:alexm
|
||||
- feat: remove re-fetch when add element by:Javier Segarra
|
||||
- feat: remove search after category by:Javier Segarra
|
||||
- feat: requested changes in item module by:Jon
|
||||
- feat: update quantity by:Javier Segarra
|
||||
- feat(VnPaginate): refs #8197 hold data when change to Card by:alexm
|
||||
|
||||
### Changed 📦
|
||||
|
||||
- perf: #6896 REMOVE COMMENTS by:Javier Segarra
|
||||
- perf: qFormMixin by:Javier Segarra
|
||||
- perf: qFormMixin improvement by:Javier Segarra
|
||||
- perf: refs #8194 select worker component by:Jon
|
||||
- perf: refs #8197 perf by:alexm
|
||||
- perf: remove comments by:Javier Segarra
|
||||
- perf: remove unused variables (origin/warmfix_noUsedVars) by:Javier Segarra
|
||||
- refactor: added again search emit by:Jon
|
||||
- refactor: add useCau composable by:jorgep
|
||||
- refactor: deleted log by:Jon
|
||||
- refactor: deleted onUnmounted code by:Jon
|
||||
- refactor: deleted useless hidden tag by:Jon
|
||||
- refactor: deleted warnings and corrected itemTag by:Jon
|
||||
- refactor: drop logic by:jorgep
|
||||
- refactor: ignore params when searching by id on searchbar (origin/VnSearchbar-SearchRemoveParams) by:Jon
|
||||
- refactor: log error by:Jon
|
||||
- refactor: refs #7936 locale by:jorgep
|
||||
- refactor: refs #7936 simplify getTotal fn by:jorgep
|
||||
- refactor: refs #7936 update label capitalization and replace invoice type options by:jorgep
|
||||
- refactor: refs #8194 deleted unnecessary label by:Jon
|
||||
- refactor: refs #8194 modified select worker template by:Jon
|
||||
- refactor: refs #8194 modified select worker to allow no one filter from monitor ticket by:Jon
|
||||
- refactor: refs #8194 moved translation to the correct place by:Jon
|
||||
- refactor: refs #8194 requested changes by:Jon
|
||||
- refactor: refs #8194 structure changes in component and related files by:Jon
|
||||
- refactor: refs #8197 adapt AccountAcls to VnCardMain by:alexm
|
||||
- refactor: refs #8197 adapt AccountAlias by:alexm
|
||||
- refactor: refs #8197 adapt Ticket to VnCardMain by:alexm
|
||||
- refactor: refs #8197 backward compatible (8197-VnCardMain_backwardCompatibility) by:alexm
|
||||
- refactor: refs #8197 rename VnSectionMain to VnModule and VnCardMain to VnSection by:alexm
|
||||
- refactor: refs #8288 changed invoice out spanish translation by:provira
|
||||
- refactor: use locale keys by:jorgep
|
||||
- refactor: use teleport to avoid qdrawer overlapping by:Jon
|
||||
- refactor: use VnSelectWorker by:Jon
|
||||
|
||||
### Fixed 🛠️
|
||||
|
||||
- fix: account by:carlossa
|
||||
- fix: account create by:carlossa
|
||||
- fix: accountList create by:carlossa
|
||||
- fix(AccountList): use $refs by:alexm
|
||||
- fix: add data-key by:alexm
|
||||
- fix: addLocales by:Jtubau
|
||||
- fix: dated field by:Jon
|
||||
- fix: e2e by:jorgep
|
||||
- fix: fix department filter by:carlossa
|
||||
- fix: fixed translations by:Javier Segarra
|
||||
- fix: fixed translations by:provira
|
||||
- fix: get total from api by:Javier Segarra
|
||||
- fix: handle non-object options by:jorgep
|
||||
- fix: monitorPayMethodFilter by:carlossa
|
||||
- fix: orderBy priority by:Javier Segarra
|
||||
- fix: prevent null by:jorgep
|
||||
- fix: redirection vnTable VnTableFilter by:alexm
|
||||
- fix: refs #6389 fix filter trad by:carlossa
|
||||
- fix: refs #6389 fix front, filters, itp by:carlossa
|
||||
- fix: refs #6389 front add packing filter by:carlossa
|
||||
- fix: refs #6389 front by:carlossa
|
||||
- fix: refs #6389 front filters by:carlossa
|
||||
- fix: refs #6389 ipt by:carlossa
|
||||
- fix: refs #6389 packing by:carlossa
|
||||
- fix: refs #6583 update checkbox for filtering by destination in TicketAdvanceFilter by:jorgep
|
||||
- fix: refs #7031 add test e2e by:carlossa
|
||||
- fix: refs #7031 fix zoneTest by:carlossa
|
||||
- fix: refs #7301 unnecessary console logs from ItemLastEntries.vue by:pablone
|
||||
- fix: refs #7936 changes by:jorgep
|
||||
- fix: refs #7936 decimal places & locale by:jorgep
|
||||
- fix: refs #7936 descriptor & dueday by:jorgep
|
||||
- fix: refs #7936 exclude disabled els on tab by:jorgep
|
||||
- fix: refs #7936 format tax calculation to two decimal places by:jorgep
|
||||
- fix: refs #7936 improve error handling by:jorgep
|
||||
- fix: refs #7936 redirection by:jorgep
|
||||
- fix: refs #7936 rollback by:jorgep
|
||||
- fix: refs #7936 serial by:jorgep
|
||||
- fix: refs #7936 tabulation wip by:jorgep
|
||||
- fix: refs #7936 test by:jorgep
|
||||
- fix: refs #8114 clean by:carlossa
|
||||
- fix: refs #8114 fix agencyList by:carlossa
|
||||
- fix: refs #8114 fix lifeCycle hooks by:carlossa
|
||||
- fix: refs #8114 fix pr by:carlossa
|
||||
- fix: refs #8114 fix removeAddress by:carlossa
|
||||
- fix: refs #8114 orderList by:carlossa
|
||||
- fix: refs #8114 remove logs by:carlossa
|
||||
- fix: refs #8197 mapKey (origin/8197-perf_vnTableInside, 8197-perf_vnTableInside) by:alexm
|
||||
- fix: refs #8197 redirection (8197-perf_redirection) by:alexm
|
||||
- fix: refs #8197 staticParams and redirect by:alexm
|
||||
- fix: refs #8197 vnPaginate onFetch emit by:alexm
|
||||
- fix: refs #8197 vnPaginate when change :id by:alexm
|
||||
- fix: refs #8197 vnTableFilter in vnTable by:alexm
|
||||
- fix: refs #8315 ticketBoxing test by:alexm
|
||||
- fix: remove url by:carlossa
|
||||
- fix: rollback by:jorgep
|
||||
- fix: test by:jorgep
|
||||
- fix(VnDmsList): refs #8197 add mapKey by:alexm
|
||||
- revert: refs #8197 arrayData changes by:alexm
|
||||
- test: refs #8197 fix e2e by:alexm
|
||||
- test: refs #8315 fix claimDevelopment fixtures by:alexm
|
||||
- test: refs #8315 fix clientList by:alexm
|
||||
- test: refs #8315 fix VnSelect in e2e by:alexm
|
||||
|
||||
# Version 24.50 - 2024-12-10
|
||||
|
||||
### Added 🆕
|
||||
|
|
|
@ -11,7 +11,6 @@ module.exports = defineConfig({
|
|||
screenshotsFolder: 'test/cypress/screenshots',
|
||||
supportFile: 'test/cypress/support/index.js',
|
||||
videosFolder: 'test/cypress/videos',
|
||||
downloadsFolder: 'test/cypress/downloads',
|
||||
video: false,
|
||||
specPattern: 'test/cypress/integration/**/*.spec.js',
|
||||
experimentalRunAllSpecs: true,
|
||||
|
@ -34,7 +33,5 @@ module.exports = defineConfig({
|
|||
require('cypress-mochawesome-reporter/plugin')(on);
|
||||
// implement node event listeners here
|
||||
},
|
||||
viewportWidth: 1280,
|
||||
viewportHeight: 720,
|
||||
},
|
||||
});
|
||||
|
|
17
package.json
17
package.json
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "salix-front",
|
||||
"version": "25.06.0",
|
||||
"version": "24.52.0",
|
||||
"description": "Salix frontend",
|
||||
"productName": "Salix",
|
||||
"author": "Verdnatura",
|
||||
|
@ -21,24 +21,23 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@quasar/cli": "^2.3.0",
|
||||
"@quasar/extras": "^1.16.14",
|
||||
"@quasar/extras": "^1.16.9",
|
||||
"axios": "^1.4.0",
|
||||
"chromium": "^3.0.3",
|
||||
"croppie": "^2.6.5",
|
||||
"moment": "^2.30.1",
|
||||
"pinia": "^2.1.3",
|
||||
"quasar": "^2.17.4",
|
||||
"quasar": "^2.14.5",
|
||||
"validator": "^13.9.0",
|
||||
"vue": "^3.5.13",
|
||||
"vue-i18n": "^9.3.0",
|
||||
"vue-router": "^4.2.5"
|
||||
"vue": "^3.3.4",
|
||||
"vue-i18n": "^9.2.2",
|
||||
"vue-router": "^4.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^19.2.1",
|
||||
"@commitlint/config-conventional": "^19.1.0",
|
||||
"@intlify/unplugin-vue-i18n": "^0.8.1",
|
||||
"@pinia/testing": "^0.1.2",
|
||||
"@quasar/app-vite": "^1.11.0",
|
||||
"@quasar/app-vite": "^1.7.3",
|
||||
"@quasar/quasar-app-extension-qcalendar": "4.0.0-beta.15",
|
||||
"@quasar/quasar-app-extension-testing-unit-vitest": "^0.4.0",
|
||||
"@vue/test-utils": "^2.4.4",
|
||||
|
@ -52,7 +51,7 @@
|
|||
"husky": "^8.0.0",
|
||||
"postcss": "^8.4.23",
|
||||
"prettier": "^2.8.8",
|
||||
"vitest": "^0.34.0"
|
||||
"vitest": "^0.31.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20 || ^18 || ^16",
|
||||
|
|
1102
pnpm-lock.yaml
1102
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -3,12 +3,12 @@ import { useSession } from 'src/composables/useSession';
|
|||
import { Router } from 'src/router';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import { useStateQueryStore } from 'src/stores/useStateQueryStore';
|
||||
import { i18n } from 'src/boot/i18n';
|
||||
|
||||
const session = useSession();
|
||||
const { notify } = useNotify();
|
||||
const stateQuery = useStateQueryStore();
|
||||
const baseUrl = '/api/';
|
||||
|
||||
axios.defaults.baseURL = baseUrl;
|
||||
const axiosNoError = axios.create({ baseURL: baseUrl });
|
||||
|
||||
|
@ -16,7 +16,6 @@ const onRequest = (config) => {
|
|||
const token = session.getToken();
|
||||
if (token.length && !config.headers.Authorization) {
|
||||
config.headers.Authorization = token;
|
||||
config.headers['Accept-Language'] = i18n.global.locale.value;
|
||||
}
|
||||
stateQuery.add(config);
|
||||
return config;
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import { boot } from 'quasar/wrappers';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import messages from 'src/i18n';
|
||||
import { useState } from 'src/composables/useState';
|
||||
const user = useState().getUser();
|
||||
|
||||
const i18n = createI18n({
|
||||
locale: user.value.lang || navigator.language || navigator.userLanguage,
|
||||
locale: navigator.language || navigator.userLanguage,
|
||||
fallbackLocale: 'en',
|
||||
globalInjection: true,
|
||||
messages,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
function focusFirstInput(input) {
|
||||
input.focus();
|
||||
return;
|
||||
}
|
||||
export default {
|
||||
mounted: function () {
|
||||
|
@ -31,7 +32,7 @@ export default {
|
|||
console.error(error);
|
||||
}
|
||||
form.addEventListener('keyup', function (evt) {
|
||||
if (evt.key === 'Enter' && !that.$attrs['prevent-submit']) {
|
||||
if (evt.key === 'Enter') {
|
||||
const input = evt.target;
|
||||
if (input.type == 'textarea' && evt.shiftKey) {
|
||||
evt.preventDefault();
|
||||
|
|
|
@ -55,6 +55,13 @@ async function setCountry(countryFk, data) {
|
|||
}
|
||||
|
||||
// Province
|
||||
|
||||
async function handleProvinces(data) {
|
||||
provincesOptions.value = data;
|
||||
if (postcodeFormData.countryFk) {
|
||||
await fetchTowns();
|
||||
}
|
||||
}
|
||||
async function setProvince(id, data) {
|
||||
if (data.provinceFk === id) return;
|
||||
const newProvince = provincesOptions.value.find((province) => province.id == id);
|
||||
|
@ -62,7 +69,6 @@ async function setProvince(id, data) {
|
|||
postcodeFormData.provinceFk = id;
|
||||
await fetchTowns();
|
||||
}
|
||||
|
||||
async function onProvinceCreated(data) {
|
||||
postcodeFormData.provinceFk = data.id;
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ function resetData(data) {
|
|||
originalData.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 });
|
||||
}
|
||||
|
||||
|
@ -270,8 +270,10 @@ function getChanges() {
|
|||
|
||||
function isEmpty(obj) {
|
||||
if (obj == null) return true;
|
||||
if (Array.isArray(obj)) return !obj.length;
|
||||
return !Object.keys(obj).length;
|
||||
if (obj === undefined) return true;
|
||||
if (Object.keys(obj).length === 0) return true;
|
||||
|
||||
if (obj.length > 0) return false;
|
||||
}
|
||||
|
||||
async function reload(params) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script setup>
|
||||
import axios from 'axios';
|
||||
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 { useQuasar } from 'quasar';
|
||||
import { useState } from 'src/composables/useState';
|
||||
|
@ -12,6 +12,7 @@ import SkeletonForm from 'components/ui/SkeletonForm.vue';
|
|||
import VnConfirm from './ui/VnConfirm.vue';
|
||||
import { tMobile } from 'src/composables/tMobile';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
const { push } = useRouter();
|
||||
const quasar = useQuasar();
|
||||
|
@ -198,7 +199,6 @@ async function fetch() {
|
|||
} catch (e) {
|
||||
state.set(modelValue, {});
|
||||
originalData.value = {};
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -293,7 +293,6 @@ defineExpose({
|
|||
class="q-pa-md"
|
||||
:style="maxWidth ? 'max-width: ' + maxWidth : ''"
|
||||
id="formModel"
|
||||
:prevent-submit="$attrs['prevent-submit']"
|
||||
>
|
||||
<QCard>
|
||||
<slot
|
||||
|
|
|
@ -92,13 +92,13 @@ function findMatches(search, item) {
|
|||
}
|
||||
|
||||
function addChildren(module, route, parent) {
|
||||
const menus = route?.meta?.menu ?? route?.menus?.[props.source]; //backwards compatible
|
||||
if (!menus) return;
|
||||
if (route.menus) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,26 +122,16 @@ function getRoutes() {
|
|||
if (props.source === 'card') {
|
||||
const currentRoute = route.matched[1];
|
||||
const currentModule = toLowerCamel(currentRoute.name);
|
||||
let moduleDef = routes.find(
|
||||
const moduleDef = routes.find(
|
||||
(route) => toLowerCamel(route.name) === currentModule
|
||||
);
|
||||
|
||||
if (!moduleDef) return;
|
||||
if (!moduleDef?.menus) moduleDef = betaGetRoutes();
|
||||
|
||||
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) {
|
||||
if (event.defaultPrevented) return;
|
||||
event.preventDefault();
|
||||
|
|
|
@ -17,10 +17,12 @@ const stateQuery = useStateQueryStore();
|
|||
const state = useState();
|
||||
const user = state.getUser();
|
||||
const appName = 'Lilium';
|
||||
const pinnedModulesRef = ref();
|
||||
|
||||
onMounted(() => stateStore.setMounted());
|
||||
|
||||
const pinnedModulesRef = ref();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<QHeader color="white" elevated>
|
||||
<QToolbar class="q-py-sm q-px-md">
|
||||
|
@ -57,13 +59,22 @@ onMounted(() => stateStore.setMounted());
|
|||
'no-visible': !stateQuery.isLoading().value,
|
||||
}"
|
||||
size="xs"
|
||||
data-cy="loading-spinner"
|
||||
/>
|
||||
<QSpace />
|
||||
<div id="searchbar" class="searchbar"></div>
|
||||
<QSpace />
|
||||
<div class="q-pl-sm q-gutter-sm row items-center no-wrap">
|
||||
<div id="actions-prepend"></div>
|
||||
<QBtn
|
||||
flat
|
||||
v-if="!quasar.platform.is.mobile"
|
||||
@click="pinnedModulesRef.redirect($route.params.id)"
|
||||
icon="more_up"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('Go to Salix') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
<QBtn
|
||||
:class="{ 'q-pa-none': quasar.platform.is.mobile }"
|
||||
id="pinnedModules"
|
||||
|
@ -95,6 +106,7 @@ onMounted(() => stateStore.setMounted());
|
|||
<VnBreadcrumbs v-if="$q.screen.lt.md" class="q-ml-md" />
|
||||
</QHeader>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.searchbar {
|
||||
width: max-content;
|
||||
|
@ -103,3 +115,9 @@ onMounted(() => stateStore.setMounted());
|
|||
background-color: var(--vn-section-color);
|
||||
}
|
||||
</style>
|
||||
<i18n>
|
||||
en:
|
||||
Go to Salix: Go to Salix
|
||||
es:
|
||||
Go to Salix: Ir a Salix
|
||||
</i18n>
|
||||
|
|
|
@ -44,7 +44,7 @@ const onDataSaved = (data) => {
|
|||
<FormModelPopup
|
||||
url-create="Items/regularize"
|
||||
model="Items"
|
||||
:title="t('item.regularizeStock')"
|
||||
:title="t('Regularize stock')"
|
||||
:form-initial-data="regularizeFormData"
|
||||
@on-data-saved="onDataSaved($event)"
|
||||
>
|
||||
|
@ -55,7 +55,6 @@ const onDataSaved = (data) => {
|
|||
v-model.number="data.quantity"
|
||||
type="number"
|
||||
autofocus
|
||||
data-cy="regularizeStockInput"
|
||||
/>
|
||||
</VnRow>
|
||||
<VnRow>
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
<script setup>
|
||||
import quasarLang from 'src/utils/quasarLang';
|
||||
|
||||
import { onMounted, computed, ref } from 'vue';
|
||||
|
||||
import { Dark } from 'quasar';
|
||||
import { Dark, Quasar } from 'quasar';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
|
@ -34,7 +31,14 @@ const userLocale = computed({
|
|||
|
||||
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) {
|
||||
//
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -83,10 +87,10 @@ async function saveDarkMode(value) {
|
|||
async function saveLanguage(value) {
|
||||
const query = `/VnUsers/${user.value.id}`;
|
||||
try {
|
||||
await axios.patch(query, { lang: value });
|
||||
|
||||
await axios.patch(query, {
|
||||
lang: value,
|
||||
});
|
||||
user.value.lang = value;
|
||||
useState().setUser(user.value);
|
||||
onDataSaved();
|
||||
} catch (error) {
|
||||
onDataError();
|
||||
|
|
|
@ -32,10 +32,7 @@ const $props = defineProps({
|
|||
defineExpose({ addFilter, props: $props });
|
||||
|
||||
const model = defineModel(undefined, { required: true });
|
||||
const arrayData = useArrayData(
|
||||
$props.dataKey,
|
||||
$props.searchUrl ? { searchUrl: $props.searchUrl } : null
|
||||
);
|
||||
const arrayData = useArrayData($props.dataKey, { searchUrl: $props.searchUrl });
|
||||
const columnFilter = computed(() => $props.column?.columnFilter);
|
||||
|
||||
const updateEvent = { 'update:modelValue': addFilter };
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
<script setup>
|
||||
import { ref, onBeforeMount, onMounted, computed, watch, useAttrs } from 'vue';
|
||||
import { ref, onBeforeMount, onMounted, computed, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { useFilterParams } from 'src/composables/useFilterParams';
|
||||
|
||||
import CrudModel from 'src/components/CrudModel.vue';
|
||||
import FormModelPopup from 'components/FormModelPopup.vue';
|
||||
|
||||
import VnFilterPanel from 'components/ui/VnFilterPanel.vue';
|
||||
import VnTableColumn from 'components/VnTable/VnColumn.vue';
|
||||
import VnFilter from 'components/VnTable/VnFilter.vue';
|
||||
import VnTableChip from 'components/VnTable/VnChip.vue';
|
||||
import VnVisibleColumn from 'src/components/VnTable/VnVisibleColumn.vue';
|
||||
import VnLv from 'components/ui/VnLv.vue';
|
||||
import VnTableOrder from 'src/components/VnTable/VnOrder.vue';
|
||||
import VnTableFilter from './VnTableFilter.vue';
|
||||
|
||||
const $props = defineProps({
|
||||
columns: {
|
||||
|
@ -34,10 +33,6 @@ const $props = defineProps({
|
|||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
rightSearchIcon: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
rowClick: {
|
||||
type: [Function, Boolean],
|
||||
default: null,
|
||||
|
@ -59,8 +54,8 @@ const $props = defineProps({
|
|||
default: true,
|
||||
},
|
||||
bottom: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
cardClass: {
|
||||
type: String,
|
||||
|
@ -106,6 +101,10 @@ const $props = defineProps({
|
|||
type: String,
|
||||
default: '90vh',
|
||||
},
|
||||
chipLocale: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
footer: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
|
@ -120,21 +119,22 @@ const stateStore = useStateStore();
|
|||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const quasar = useQuasar();
|
||||
const $attrs = useAttrs();
|
||||
|
||||
const CARD_MODE = 'card';
|
||||
const TABLE_MODE = 'table';
|
||||
const mode = ref(CARD_MODE);
|
||||
const selected = ref([]);
|
||||
const hasParams = ref(false);
|
||||
const routeQuery = JSON.parse(route?.query[$props.searchUrl] ?? '{}');
|
||||
const params = ref({ ...routeQuery, ...routeQuery.filter?.where });
|
||||
const orders = ref(parseOrder(routeQuery.filter?.order));
|
||||
const CrudModelRef = ref({});
|
||||
const showForm = ref(false);
|
||||
const splittedColumns = ref({ columns: [] });
|
||||
const columnsVisibilitySkipped = ref();
|
||||
const createForm = ref();
|
||||
const tableFilterRef = ref([]);
|
||||
const tableRef = ref();
|
||||
const params = ref(useFilterParams($attrs['data-key']).params);
|
||||
const orders = ref(useFilterParams($attrs['data-key']).orders);
|
||||
|
||||
const tableModes = [
|
||||
{
|
||||
|
@ -150,7 +150,6 @@ const tableModes = [
|
|||
disable: $props.disableOption?.card,
|
||||
},
|
||||
];
|
||||
|
||||
onBeforeMount(() => {
|
||||
const urlParams = route.query[$props.searchUrl];
|
||||
hasParams.value = urlParams && Object.keys(urlParams).length !== 0;
|
||||
|
@ -163,9 +162,7 @@ onMounted(() => {
|
|||
: $props.defaultMode;
|
||||
stateStore.rightDrawer = quasar.screen.gt.xs;
|
||||
columnsVisibilitySkipped.value = [
|
||||
...splittedColumns.value.columns
|
||||
.filter((c) => c.visible === false)
|
||||
.map((c) => c.name),
|
||||
...splittedColumns.value.columns.filter((c) => !c.visible).map((c) => c.name),
|
||||
...['tableActions'],
|
||||
];
|
||||
createForm.value = $props.create;
|
||||
|
@ -184,8 +181,41 @@ watch(
|
|||
{ immediate: true }
|
||||
);
|
||||
|
||||
watch(
|
||||
() => route.query[$props.searchUrl],
|
||||
(val) => setUserParams(val),
|
||||
{ immediate: true, deep: true }
|
||||
);
|
||||
|
||||
const isTableMode = computed(() => mode.value == TABLE_MODE);
|
||||
const showRightIcon = computed(() => $props.rightSearch || $props.rightSearchIcon);
|
||||
|
||||
function setUserParams(watchedParams, watchedOrder) {
|
||||
if (!watchedParams) return;
|
||||
|
||||
if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams);
|
||||
const filter =
|
||||
typeof watchedParams?.filter == 'string'
|
||||
? JSON.parse(watchedParams?.filter ?? '{}')
|
||||
: watchedParams?.filter;
|
||||
const where = filter?.where;
|
||||
const order = watchedOrder ?? filter?.order;
|
||||
|
||||
watchedParams = { ...watchedParams, ...where };
|
||||
delete watchedParams.filter;
|
||||
delete params.value?.filter;
|
||||
params.value = { ...params.value, ...sanitizer(watchedParams) };
|
||||
orders.value = parseOrder(order);
|
||||
}
|
||||
|
||||
function sanitizer(params) {
|
||||
for (const [key, value] of Object.entries(params)) {
|
||||
if (value && typeof value == 'object') {
|
||||
const param = Object.values(value)[0];
|
||||
if (typeof param == 'string') params[key] = param.replaceAll('%', '');
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
function splitColumns(columns) {
|
||||
splittedColumns.value = {
|
||||
|
@ -266,6 +296,17 @@ function getColAlign(col) {
|
|||
return 'text-' + (col.align ?? 'left');
|
||||
}
|
||||
|
||||
function parseOrder(urlOrders) {
|
||||
const orderObject = {};
|
||||
if (!urlOrders) return orderObject;
|
||||
if (typeof urlOrders == 'string') urlOrders = [urlOrders];
|
||||
for (const [index, orders] of urlOrders.entries()) {
|
||||
const [name, direction] = orders.split(' ');
|
||||
orderObject[name] = { direction, index: index + 1 };
|
||||
}
|
||||
return orderObject;
|
||||
}
|
||||
|
||||
const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']);
|
||||
defineExpose({
|
||||
create: createForm,
|
||||
|
@ -314,7 +355,61 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
show-if-above
|
||||
>
|
||||
<QScrollArea class="fit">
|
||||
<VnTableFilter :data-key="$attrs['data-key']" :columns="columns" :redirect="redirect" />
|
||||
<VnFilterPanel
|
||||
:data-key="$attrs['data-key']"
|
||||
:search-button="true"
|
||||
v-model="params"
|
||||
:search-url="searchUrl"
|
||||
:redirect="!!redirect"
|
||||
@set-user-params="setUserParams"
|
||||
:disable-submit-event="true"
|
||||
@remove="
|
||||
(key) =>
|
||||
tableFilterRef
|
||||
.find((f) => f.props?.column.name == key)
|
||||
?.addFilter()
|
||||
"
|
||||
>
|
||||
<template #body>
|
||||
<div
|
||||
class="row no-wrap flex-center"
|
||||
v-for="col of splittedColumns.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="false"
|
||||
/>
|
||||
</div>
|
||||
<slot
|
||||
name="moreFilterPanel"
|
||||
:params="params"
|
||||
:columns="splittedColumns.columns"
|
||||
/>
|
||||
</template>
|
||||
<template #tags="{ tag, formatFn }" v-if="chipLocale">
|
||||
<div class="q-gutter-x-xs">
|
||||
<strong>{{ t(`${chipLocale}.${tag.label}`) }}: </strong>
|
||||
<span>{{ formatFn(tag.value) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</VnFilterPanel>
|
||||
</QScrollArea>
|
||||
</QDrawer>
|
||||
<CrudModel
|
||||
|
@ -370,7 +465,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
:options="tableModes.filter((mode) => !mode.disable)"
|
||||
/>
|
||||
<QBtn
|
||||
v-if="showRightIcon"
|
||||
v-if="$props.rightSearch"
|
||||
icon="filter_alt"
|
||||
class="bg-vn-section-color q-ml-sm"
|
||||
dense
|
||||
|
@ -384,7 +479,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
:class="col.headerClass"
|
||||
>
|
||||
<div
|
||||
class="column ellipsis"
|
||||
class="column self-start q-ml-xs ellipsis"
|
||||
:class="`text-${col?.align ?? 'left'}`"
|
||||
:style="$props.columnSearch ? 'height: 75px' : ''"
|
||||
>
|
||||
|
@ -426,7 +521,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
<!-- Columns -->
|
||||
<QTd
|
||||
auto-width
|
||||
class="no-margin"
|
||||
class="no-margin q-px-xs"
|
||||
:class="[getColAlign(col), col.columnClass]"
|
||||
:style="col.style"
|
||||
v-if="col.visible ?? true"
|
||||
|
@ -478,6 +573,29 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
/>
|
||||
</QTd>
|
||||
</template>
|
||||
<template #bottom v-if="bottom">
|
||||
<slot name="bottom-table">
|
||||
<QBtn
|
||||
@click="
|
||||
() =>
|
||||
createAsDialog
|
||||
? (showForm = !showForm)
|
||||
: handleOnDataSaved(create)
|
||||
"
|
||||
class="cursor-pointer fill-icon"
|
||||
color="primary"
|
||||
icon="add_circle"
|
||||
size="md"
|
||||
round
|
||||
flat
|
||||
shortcut="+"
|
||||
:disabled="!disabledAttr"
|
||||
/>
|
||||
<QTooltip>
|
||||
{{ createForm.title }}
|
||||
</QTooltip>
|
||||
</slot>
|
||||
</template>
|
||||
<template #item="{ row, colsMap }">
|
||||
<component
|
||||
:is="$props.redirect ? 'router-link' : 'span'"
|
||||
|
@ -538,7 +656,13 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
:key="col.name"
|
||||
class="fields"
|
||||
>
|
||||
<VnLv :label="col.label + ':'">
|
||||
<VnLv
|
||||
:label="
|
||||
!col.component && col.label
|
||||
? `${col.label}:`
|
||||
: ''
|
||||
"
|
||||
>
|
||||
<template #value>
|
||||
<span
|
||||
@click="stopEventPropagation($event)"
|
||||
|
@ -602,27 +726,6 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
</QTr>
|
||||
</template>
|
||||
</QTable>
|
||||
<div class="full-width bottomButton" v-if="bottom">
|
||||
<QBtn
|
||||
@click="
|
||||
() =>
|
||||
createAsDialog
|
||||
? (showForm = !showForm)
|
||||
: handleOnDataSaved(create)
|
||||
"
|
||||
class="cursor-pointer fill-icon"
|
||||
color="primary"
|
||||
icon="add_circle"
|
||||
size="md"
|
||||
round
|
||||
flat
|
||||
shortcut="+"
|
||||
:disabled="!disabledAttr"
|
||||
/>
|
||||
<QTooltip>
|
||||
{{ createForm.title }}
|
||||
</QTooltip>
|
||||
</div>
|
||||
</template>
|
||||
</CrudModel>
|
||||
<QPageSticky v-if="$props.create" :offset="[20, 20]" style="z-index: 2">
|
||||
|
@ -700,7 +803,7 @@ es:
|
|||
|
||||
.grid-three {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(350px, max-content));
|
||||
grid-template-columns: repeat(auto-fit, minmax(400px, max-content));
|
||||
max-width: 100%;
|
||||
grid-gap: 20px;
|
||||
margin: 0 auto;
|
||||
|
@ -749,6 +852,21 @@ es:
|
|||
top: 0;
|
||||
padding: 12px 0;
|
||||
}
|
||||
tbody {
|
||||
.q-checkbox {
|
||||
display: flex;
|
||||
margin-bottom: 9px;
|
||||
& .q-checkbox__label {
|
||||
margin-left: 31px;
|
||||
color: var(--vn-text-color);
|
||||
}
|
||||
& .q-checkbox__inner {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
color: var(--vn-label-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
.sticky {
|
||||
position: sticky;
|
||||
right: 0;
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
import VnFilterPanel from 'components/ui/VnFilterPanel.vue';
|
||||
import VnFilter from 'components/VnTable/VnFilter.vue';
|
||||
import VnTableOrder from 'src/components/VnTable/VnOrder.vue';
|
||||
|
||||
defineProps({
|
||||
columns: {
|
||||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
searchUrl: {
|
||||
type: [String, Boolean],
|
||||
default: 'table',
|
||||
},
|
||||
});
|
||||
|
||||
const tableFilterRef = ref([]);
|
||||
|
||||
function columnName(col) {
|
||||
const column = { ...col, ...col.columnFilter };
|
||||
let name = column.name;
|
||||
if (column.alias) name = column.alias + '.' + name;
|
||||
return name;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<VnFilterPanel v-bind="$attrs" :search-button="true" :disable-submit-event="true">
|
||||
<template #body="{ params, orders }">
|
||||
<div
|
||||
class="row no-wrap flex-center"
|
||||
v-for="col of columns.filter((c) => c.columnFilter ?? true)"
|
||||
:key="col.id"
|
||||
>
|
||||
<VnFilter
|
||||
ref="tableFilterRef"
|
||||
:column="col"
|
||||
:data-key="$attrs['data-key']"
|
||||
v-model="params[columnName(col)]"
|
||||
:search-url="searchUrl"
|
||||
/>
|
||||
<VnTableOrder
|
||||
v-if="col?.columnFilter !== false && col?.name !== 'tableActions'"
|
||||
v-model="orders[col.orderBy ?? col.name]"
|
||||
:name="col.orderBy ?? col.name"
|
||||
:data-key="$attrs['data-key']"
|
||||
:search-url="searchUrl"
|
||||
:vertical="true"
|
||||
/>
|
||||
</div>
|
||||
<slot
|
||||
name="moreFilterPanel"
|
||||
:params="params"
|
||||
:orders="orders"
|
||||
:columns="columns"
|
||||
/>
|
||||
</template>
|
||||
<template #tags="{ tag, formatFn, getLocale }">
|
||||
<div class="q-gutter-x-xs">
|
||||
<strong>{{ getLocale(`${tag.label}`) }}: </strong>
|
||||
<span>{{ formatFn(tag.value) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</VnFilterPanel>
|
||||
</template>
|
|
@ -152,7 +152,7 @@ onMounted(async () => {
|
|||
<QCheckbox
|
||||
v-for="col in localColumns"
|
||||
:key="col.name"
|
||||
:label="col.label ?? col.name"
|
||||
:label="col.label"
|
||||
v-model="col.visible"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -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,248 +0,0 @@
|
|||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import CrudModel from 'components/CrudModel.vue';
|
||||
import { vi, afterEach, beforeEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
|
||||
describe('CrudModel', () => {
|
||||
let wrapper;
|
||||
let vm;
|
||||
let data;
|
||||
beforeAll(() => {
|
||||
wrapper = createWrapper(CrudModel, {
|
||||
global: {
|
||||
stubs: [
|
||||
'vnPaginate',
|
||||
'useState',
|
||||
'arrayData',
|
||||
'useStateStore',
|
||||
'vue-i18n',
|
||||
],
|
||||
mocks: {
|
||||
validate: vi.fn(),
|
||||
},
|
||||
},
|
||||
propsData: {
|
||||
dataRequired: {
|
||||
fk: 1,
|
||||
},
|
||||
dataKey: 'crudModelKey',
|
||||
model: 'crudModel',
|
||||
url: 'crudModelUrl',
|
||||
saveFn: '',
|
||||
},
|
||||
});
|
||||
wrapper=wrapper.wrapper;
|
||||
vm=wrapper.vm;
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
vm.fetch([]);
|
||||
vm.watchChanges = null;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('insert()', () => {
|
||||
it('should new element in list with index 0 if formData not has data', () => {
|
||||
vm.insert();
|
||||
|
||||
expect(vm.formData.length).toEqual(1);
|
||||
expect(vm.formData[0].fk).toEqual(1);
|
||||
expect(vm.formData[0].$index).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getChanges()', () => {
|
||||
it('should return correct updates and creates', async () => {
|
||||
vm.fetch([
|
||||
{ id: 1, name: 'New name one' },
|
||||
{ id: 2, name: 'New name two' },
|
||||
{ id: 3, name: 'Bruce Wayne' },
|
||||
]);
|
||||
|
||||
vm.originalData = [
|
||||
{ id: 1, name: 'Tony Starks' },
|
||||
{ id: 2, name: 'Jessica Jones' },
|
||||
{ id: 3, name: 'Bruce Wayne' },
|
||||
];
|
||||
|
||||
vm.insert();
|
||||
const result = vm.getChanges();
|
||||
|
||||
const expected = {
|
||||
creates: [
|
||||
{
|
||||
$index: 3,
|
||||
fk: 1,
|
||||
},
|
||||
],
|
||||
updates: [
|
||||
{
|
||||
data: {
|
||||
name: 'New name one',
|
||||
},
|
||||
where: {
|
||||
id: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
data: {
|
||||
name: 'New name two',
|
||||
},
|
||||
where: {
|
||||
id: 2,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getDifferences()', () => {
|
||||
it('should return the differences between two objects', async () => {
|
||||
const obj1 = {
|
||||
a: 1,
|
||||
b: 2,
|
||||
c: 3,
|
||||
};
|
||||
const obj2 = {
|
||||
a: null,
|
||||
b: 4,
|
||||
d: 5,
|
||||
};
|
||||
|
||||
const result = vm.getDifferences(obj1, obj2);
|
||||
|
||||
expect(result).toEqual({
|
||||
a: null,
|
||||
b: 4,
|
||||
d: 5,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('isEmpty()', () => {
|
||||
let dummyObj;
|
||||
let dummyArray;
|
||||
let result;
|
||||
it('should return true if object si null', async () => {
|
||||
dummyObj = null;
|
||||
result = vm.isEmpty(dummyObj);
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true if object si undefined', async () => {
|
||||
dummyObj = undefined;
|
||||
result = vm.isEmpty(dummyObj);
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true if object is empty', async () => {
|
||||
dummyObj ={};
|
||||
result = vm.isEmpty(dummyObj);
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false if object is not empty', async () => {
|
||||
dummyObj = {a:1, b:2, c:3};
|
||||
result = vm.isEmpty(dummyObj);
|
||||
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it('should return true if array is empty', async () => {
|
||||
dummyArray = [];
|
||||
result = vm.isEmpty(dummyArray);
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false if array is not empty', async () => {
|
||||
dummyArray = [1,2,3];
|
||||
result = vm.isEmpty(dummyArray);
|
||||
|
||||
expect(result).toBe(false);
|
||||
})
|
||||
});
|
||||
|
||||
describe('resetData()', () => {
|
||||
it('should add $index to elements in data[] and sets originalData and formData with data', async () => {
|
||||
data = [{
|
||||
name: 'Tony',
|
||||
lastName: 'Stark',
|
||||
age: 42,
|
||||
}];
|
||||
|
||||
vm.resetData(data);
|
||||
|
||||
expect(vm.originalData).toEqual(data);
|
||||
expect(vm.originalData[0].$index).toEqual(0);
|
||||
expect(vm.formData).toEqual(data);
|
||||
expect(vm.formData[0].$index).toEqual(0);
|
||||
expect(vm.watchChanges).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should dont do nothing if data is null', async () => {
|
||||
vm.resetData(null);
|
||||
|
||||
expect(vm.watchChanges).toBeNull();
|
||||
});
|
||||
|
||||
it('should set originalData and formatData with data and generate watchChanges', async () => {
|
||||
data = {
|
||||
name: 'Tony',
|
||||
lastName: 'Stark',
|
||||
age: 42,
|
||||
};
|
||||
|
||||
vm.resetData(data);
|
||||
|
||||
expect(vm.originalData).toEqual(data);
|
||||
expect(vm.formData).toEqual(data);
|
||||
expect(vm.watchChanges).not.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('saveChanges()', () => {
|
||||
data = [{
|
||||
name: 'Tony',
|
||||
lastName: 'Stark',
|
||||
age: 42,
|
||||
}];
|
||||
|
||||
it('should call saveFn if exists', async () => {
|
||||
await wrapper.setProps({ saveFn: vi.fn() });
|
||||
|
||||
vm.saveChanges(data);
|
||||
|
||||
expect(vm.saveFn).toHaveBeenCalledOnce();
|
||||
expect(vm.isLoading).toBe(false);
|
||||
expect(vm.hasChanges).toBe(false);
|
||||
|
||||
await wrapper.setProps({ saveFn: '' });
|
||||
});
|
||||
|
||||
it("should use default url if there's not saveFn", async () => {
|
||||
const postMock =vi.spyOn(axios, 'post');
|
||||
|
||||
vm.formData = [{
|
||||
name: 'Bruce',
|
||||
lastName: 'Wayne',
|
||||
age: 45,
|
||||
}]
|
||||
|
||||
await vm.saveChanges(data);
|
||||
|
||||
expect(postMock).toHaveBeenCalledWith(vm.url + '/crud', data);
|
||||
expect(vm.isLoading).toBe(false);
|
||||
expect(vm.hasChanges).toBe(false);
|
||||
expect(vm.originalData).toEqual(JSON.parse(JSON.stringify(vm.formData)));
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,56 +0,0 @@
|
|||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import EditForm from 'components/EditTableCellValueForm.vue';
|
||||
import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
|
||||
const fieldA = 'fieldA';
|
||||
const fieldB = 'fieldB';
|
||||
|
||||
describe('EditForm', () => {
|
||||
let vm;
|
||||
const mockRows = [
|
||||
{ id: 1, itemFk: 101 },
|
||||
{ id: 2, itemFk: 102 },
|
||||
];
|
||||
const mockFieldsOptions = [
|
||||
{ label: 'Field A', field: fieldA, component: 'input', attrs: {} },
|
||||
{ label: 'Field B', field: fieldB, component: 'date', attrs: {} },
|
||||
];
|
||||
const editUrl = '/api/edit';
|
||||
|
||||
beforeAll(() => {
|
||||
vi.spyOn(axios, 'post').mockResolvedValue({ status: 200 });
|
||||
vm = createWrapper(EditForm, {
|
||||
props: {
|
||||
rows: mockRows,
|
||||
fieldsOptions: mockFieldsOptions,
|
||||
editUrl,
|
||||
},
|
||||
}).vm;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
it('should call axios.post with the correct parameters in the payload', async () => {
|
||||
const selectedField = { field: fieldA, component: 'input', attrs: {} };
|
||||
const newValue = 'Test Value';
|
||||
|
||||
vm.selectedField = selectedField;
|
||||
vm.newValue = newValue;
|
||||
|
||||
await vm.onSubmit();
|
||||
|
||||
const payload = axios.post.mock.calls[0][1];
|
||||
|
||||
expect(axios.post).toHaveBeenCalledWith(editUrl, expect.any(Object));
|
||||
expect(payload.field).toEqual(fieldA);
|
||||
expect(payload.newValue).toEqual(newValue);
|
||||
|
||||
expect(payload.lines).toEqual(expect.arrayContaining(mockRows));
|
||||
|
||||
expect(vm.isLoading).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,82 +0,0 @@
|
|||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import FilterItemForm from 'src/components/FilterItemForm.vue';
|
||||
import { vi, beforeAll, describe, expect, it } from 'vitest';
|
||||
|
||||
describe('FilterItemForm', () => {
|
||||
let vm;
|
||||
let wrapper;
|
||||
|
||||
beforeAll(() => {
|
||||
wrapper = createWrapper(FilterItemForm, {
|
||||
props: {
|
||||
url: 'Items/withName',
|
||||
},
|
||||
});
|
||||
vm = wrapper.vm;
|
||||
wrapper = wrapper.wrapper;
|
||||
|
||||
vi.spyOn(axios, 'get').mockResolvedValue({
|
||||
data: [
|
||||
{
|
||||
id: 999996,
|
||||
name: 'bolas de madera',
|
||||
size: 2,
|
||||
inkFk: null,
|
||||
producerFk: null,
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('should filter data and populate tableRows for table display', async () => {
|
||||
vm.itemFilterParams.name = 'bolas de madera';
|
||||
|
||||
await vm.onSubmit();
|
||||
|
||||
const expectedFilter = {
|
||||
include: [
|
||||
{ relation: 'producer', scope: { fields: ['name'] } },
|
||||
{ relation: 'ink', scope: { fields: ['name'] } },
|
||||
],
|
||||
where: {"name":{"like":"%bolas de madera%"}},
|
||||
};
|
||||
|
||||
expect(axios.get).toHaveBeenCalledWith('Items/withName', {
|
||||
params: { filter: JSON.stringify(expectedFilter) },
|
||||
});
|
||||
|
||||
expect(vm.tableRows).toEqual([
|
||||
{
|
||||
id: 999996,
|
||||
name: 'bolas de madera',
|
||||
size: 2,
|
||||
inkFk: null,
|
||||
producerFk: null,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('should handle an empty itemFilterParams correctly', async () => {
|
||||
vm.itemFilterParams.name = null;
|
||||
vm.itemFilterParams = {};
|
||||
|
||||
await vm.onSubmit();
|
||||
|
||||
const expectedFilter = {
|
||||
include: [
|
||||
{ relation: 'producer', scope: { fields: ['name'] } },
|
||||
{ relation: 'ink', scope: { fields: ['name'] } },
|
||||
],
|
||||
where: {},
|
||||
};
|
||||
|
||||
expect(axios.get).toHaveBeenCalledWith('Items/withName', {
|
||||
params: { filter: JSON.stringify(expectedFilter) },
|
||||
});
|
||||
});
|
||||
|
||||
it('should emit "itemSelected" with the correct id and close the form', () => {
|
||||
vm.selectItem({ id: 12345 });
|
||||
expect(wrapper.emitted('itemSelected')[0]).toEqual([12345]);
|
||||
});
|
||||
});
|
|
@ -1,149 +0,0 @@
|
|||
import { describe, expect, it, beforeAll, vi, afterAll } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import FormModel from 'src/components/FormModel.vue';
|
||||
|
||||
describe('FormModel', () => {
|
||||
const model = 'mockModel';
|
||||
const url = 'mockUrl';
|
||||
const formInitialData = { mockKey: 'mockVal' };
|
||||
|
||||
describe('modelValue', () => {
|
||||
it('should use the provided model', () => {
|
||||
const { vm } = mount({ propsData: { model } });
|
||||
expect(vm.modelValue).toBe(model);
|
||||
});
|
||||
|
||||
it('should use the route meta title when model is not provided', () => {
|
||||
const { vm } = mount({});
|
||||
expect(vm.modelValue).toBe('formModel_mockTitle');
|
||||
});
|
||||
});
|
||||
|
||||
describe('onMounted()', () => {
|
||||
let mockGet;
|
||||
|
||||
beforeAll(() => {
|
||||
mockGet = vi.spyOn(axios, 'get').mockResolvedValue({ data: {} });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
mockGet.mockRestore();
|
||||
});
|
||||
|
||||
it('should not fetch when has formInitialData', () => {
|
||||
mount({ propsData: { url, model, autoLoad: true, formInitialData } });
|
||||
expect(mockGet).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should fetch when there is url and auto-load', () => {
|
||||
mount({ propsData: { url, model, autoLoad: true } });
|
||||
expect(mockGet).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not observe changes', () => {
|
||||
const { vm } = mount({
|
||||
propsData: { url, model, observeFormChanges: false, formInitialData },
|
||||
});
|
||||
|
||||
expect(vm.hasChanges).toBe(true);
|
||||
vm.reset();
|
||||
expect(vm.hasChanges).toBe(true);
|
||||
});
|
||||
|
||||
it('should observe changes', async () => {
|
||||
const { vm } = mount({
|
||||
propsData: { url, model, formInitialData },
|
||||
});
|
||||
vm.state.set(model, formInitialData);
|
||||
expect(vm.hasChanges).toBe(false);
|
||||
|
||||
vm.formData.mockKey = 'newVal';
|
||||
await vm.$nextTick();
|
||||
expect(vm.hasChanges).toBe(true);
|
||||
vm.formData.mockKey = 'mockVal';
|
||||
});
|
||||
});
|
||||
|
||||
describe('trimData()', () => {
|
||||
let vm;
|
||||
beforeAll(() => {
|
||||
vm = mount({}).vm;
|
||||
});
|
||||
|
||||
it('should trim whitespace from string values', () => {
|
||||
const data = { key1: ' value1 ', key2: ' value2 ' };
|
||||
const trimmedData = vm.trimData(data);
|
||||
expect(trimmedData).toEqual({ key1: 'value1', key2: 'value2' });
|
||||
});
|
||||
|
||||
it('should not modify non-string values', () => {
|
||||
const data = { key1: 123, key2: true, key3: null, key4: undefined };
|
||||
const trimmedData = vm.trimData(data);
|
||||
expect(trimmedData).toEqual(data);
|
||||
});
|
||||
});
|
||||
|
||||
describe('save()', async () => {
|
||||
it('should not call if there are not changes', async () => {
|
||||
const { vm } = mount({ propsData: { url, model } });
|
||||
|
||||
await vm.save();
|
||||
expect(vm.hasChanges).toBe(false);
|
||||
});
|
||||
|
||||
it('should call axios.patch with the right data', async () => {
|
||||
const spy = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
||||
const { vm } = mount({ propsData: { url, model, formInitialData } });
|
||||
vm.formData.mockKey = 'newVal';
|
||||
await vm.$nextTick();
|
||||
await vm.save();
|
||||
expect(spy).toHaveBeenCalled();
|
||||
vm.formData.mockKey = 'mockVal';
|
||||
});
|
||||
|
||||
it('should call axios.post with the right data', async () => {
|
||||
const spy = vi.spyOn(axios, 'post').mockResolvedValue({ data: {} });
|
||||
const { vm } = mount({
|
||||
propsData: { url, model, formInitialData, urlCreate: 'mockUrlCreate' },
|
||||
});
|
||||
vm.formData.mockKey = 'newVal';
|
||||
await vm.$nextTick();
|
||||
await vm.save();
|
||||
expect(spy).toHaveBeenCalled();
|
||||
vm.formData.mockKey = 'mockVal';
|
||||
});
|
||||
|
||||
it('should use the saveFn', async () => {
|
||||
const { vm } = mount({
|
||||
propsData: { url, model, formInitialData, saveFn: () => {} },
|
||||
});
|
||||
const spyPatch = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
||||
const spySaveFn = vi.spyOn(vm.$props, 'saveFn');
|
||||
|
||||
vm.formData.mockKey = 'newVal';
|
||||
await vm.$nextTick();
|
||||
await vm.save();
|
||||
expect(spyPatch).not.toHaveBeenCalled();
|
||||
expect(spySaveFn).toHaveBeenCalled();
|
||||
vm.formData.mockKey = 'mockVal';
|
||||
});
|
||||
|
||||
it('should reload the data after save', async () => {
|
||||
const { vm } = mount({
|
||||
propsData: { url, model, formInitialData, reload: true },
|
||||
});
|
||||
vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} });
|
||||
|
||||
vm.formData.mockKey = 'newVal';
|
||||
await vm.$nextTick();
|
||||
await vm.save();
|
||||
vm.formData.mockKey = 'mockVal';
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function mount({ propsData = {} }) {
|
||||
return createWrapper(FormModel, {
|
||||
propsData,
|
||||
});
|
||||
}
|
|
@ -1,20 +1,32 @@
|
|||
<script setup>
|
||||
import { onMounted, useSlots } from 'vue';
|
||||
import { ref, onMounted, useSlots } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
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 hasContent = useHasContent('#right-panel');
|
||||
const hasContent = ref(false);
|
||||
const rightPanel = ref(null);
|
||||
|
||||
onMounted(() => {
|
||||
if ((!slots['right-panel'] && !hasContent.value) || quasar.platform.is.mobile)
|
||||
stateStore.rightDrawer = false;
|
||||
rightPanel.value = document.querySelector('#right-panel');
|
||||
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>
|
||||
<template>
|
||||
<Teleport to="#actions-append" v-if="stateStore.isHeaderMounted()">
|
||||
|
@ -33,7 +45,7 @@ onMounted(() => {
|
|||
</QBtn>
|
||||
</div>
|
||||
</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">
|
||||
<div id="right-panel"></div>
|
||||
<slot v-if="!hasContent" name="right-panel" />
|
||||
|
|
|
@ -15,7 +15,7 @@ let root = ref(null);
|
|||
|
||||
watchEffect(() => {
|
||||
matched.value = currentRoute.value.matched.filter(
|
||||
(matched) => !!matched?.meta?.title || !!matched?.meta?.icon
|
||||
(matched) => Object.keys(matched.meta).length
|
||||
);
|
||||
breadcrumbs.value.length = 0;
|
||||
if (!matched.value[0]) return;
|
||||
|
|
|
@ -14,7 +14,6 @@ defineProps({
|
|||
hide-dropdown-icon
|
||||
focus-on-mount
|
||||
@update:model-value="promise"
|
||||
data-cy="vnBtnSelect_select"
|
||||
/>
|
||||
</QBtnDropdown>
|
||||
</template>
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
<script setup>
|
||||
import { onBeforeMount, computed } from 'vue';
|
||||
import { useRoute, useRouter, onBeforeRouteUpdate } from 'vue-router';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import useCardSize from 'src/composables/useCardSize';
|
||||
import LeftMenu from 'components/LeftMenu.vue';
|
||||
import VnSubToolbar from '../ui/VnSubToolbar.vue';
|
||||
|
||||
const props = defineProps({
|
||||
dataKey: { type: String, required: true },
|
||||
baseUrl: { type: String, default: undefined },
|
||||
customUrl: { type: String, default: undefined },
|
||||
filter: { type: Object, default: () => {} },
|
||||
descriptor: { type: Object, required: true },
|
||||
filterPanel: { type: Object, default: undefined },
|
||||
searchDataKey: { type: String, default: undefined },
|
||||
searchbarProps: { type: Object, default: undefined },
|
||||
redirectOnError: { type: Boolean, default: false },
|
||||
});
|
||||
|
||||
const stateStore = useStateStore();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const url = computed(() => {
|
||||
if (props.baseUrl) {
|
||||
return `${props.baseUrl}/${route.params.id}`;
|
||||
}
|
||||
return props.customUrl;
|
||||
});
|
||||
|
||||
const arrayData = useArrayData(props.dataKey, {
|
||||
url: url.value,
|
||||
filter: props.filter,
|
||||
});
|
||||
|
||||
onBeforeMount(async () => {
|
||||
try {
|
||||
if (!props.baseUrl) arrayData.store.filter.where = { id: route.params.id };
|
||||
await arrayData.fetch({ append: false, updateRouter: false });
|
||||
} catch {
|
||||
const { matched: matches } = router.currentRoute.value;
|
||||
const { path } = matches.at(-1);
|
||||
router.push({ path: path.replace(/:id.*/, '') });
|
||||
}
|
||||
});
|
||||
|
||||
if (props.baseUrl) {
|
||||
onBeforeRouteUpdate(async (to, from) => {
|
||||
if (to.params.id !== from.params.id) {
|
||||
arrayData.store.url = `${props.baseUrl}/${to.params.id}`;
|
||||
await arrayData.fetch({ append: false, updateRouter: false });
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Teleport to="#left-panel" v-if="stateStore.isHeaderMounted()">
|
||||
<component :is="descriptor" />
|
||||
<QSeparator />
|
||||
<LeftMenu source="card" />
|
||||
</Teleport>
|
||||
<VnSubToolbar />
|
||||
<div :class="[useCardSize(), $attrs.class]">
|
||||
<RouterView :key="route.path" />
|
||||
</div>
|
||||
</template>
|
|
@ -2,9 +2,9 @@
|
|||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import VnRow from '../ui/VnRow.vue';
|
||||
import VnInput from './VnInput.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: () => {} },
|
||||
|
@ -70,19 +70,19 @@ defineExpose({ show: () => changePassDialog.value.show() });
|
|||
</QCardSection>
|
||||
<QForm ref="form">
|
||||
<QCardSection>
|
||||
<VnInputPassword
|
||||
<VnInput
|
||||
v-if="props.askOldPass"
|
||||
:label="t('Old password')"
|
||||
v-model="passwords.oldPassword"
|
||||
type="password"
|
||||
:required="true"
|
||||
:toggle-visibility="true"
|
||||
autofocus
|
||||
/>
|
||||
<VnInputPassword
|
||||
<VnInput
|
||||
:label="t('New password')"
|
||||
v-model="passwords.newPassword"
|
||||
type="password"
|
||||
:required="true"
|
||||
:toggle-visibility="true"
|
||||
:info="
|
||||
t('passwordRequirements', {
|
||||
length: requirements.length,
|
||||
|
@ -95,10 +95,10 @@ defineExpose({ show: () => changePassDialog.value.show() });
|
|||
autofocus
|
||||
/>
|
||||
|
||||
<VnInputPassword
|
||||
<VnInput
|
||||
:label="t('Repeat password')"
|
||||
v-model="passwords.repeatPassword"
|
||||
:toggle-visibility="true"
|
||||
type="password"
|
||||
/>
|
||||
</QCardSection>
|
||||
</QForm>
|
||||
|
|
|
@ -11,9 +11,9 @@ function getBadgeAttrs(date) {
|
|||
|
||||
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' };
|
||||
if (timeDiff == 0) return { color: 'warning', 'text-color': 'black' };
|
||||
if (timeDiff < 0) return { color: 'success', 'text-color': 'black' };
|
||||
return { color: 'transparent', 'text-color': 'white' };
|
||||
}
|
||||
|
||||
function formatShippedDate(date) {
|
||||
|
@ -29,11 +29,3 @@ function formatShippedDate(date) {
|
|||
{{ 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>
|
||||
|
|
|
@ -297,14 +297,13 @@ defineExpose({
|
|||
ref="dmsRef"
|
||||
:data-key="$props.model"
|
||||
:url="$props.model"
|
||||
:user-filter="dmsFilter"
|
||||
:filter="dmsFilter"
|
||||
:order="['dmsFk DESC']"
|
||||
auto-load
|
||||
:auto-load="true"
|
||||
@on-fetch="setData"
|
||||
>
|
||||
<template #body>
|
||||
<QTable
|
||||
v-if="rows"
|
||||
:columns="columns"
|
||||
:rows="rows"
|
||||
class="full-width q-mt-md"
|
||||
|
|
|
@ -42,10 +42,6 @@ const $props = defineProps({
|
|||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
uppercase: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
const vnInputRef = ref(null);
|
||||
|
@ -120,10 +116,6 @@ const handleInsertMode = (e) => {
|
|||
input.setSelectionRange(cursorPos + 1, cursorPos + 1);
|
||||
});
|
||||
};
|
||||
|
||||
const handleUppercase = () => {
|
||||
value.value = value.value?.toUpperCase() || '';
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -142,23 +134,20 @@ const handleUppercase = () => {
|
|||
hide-bottom-space
|
||||
:data-cy="$attrs.dataCy ?? $attrs.label + '_input'"
|
||||
>
|
||||
<template #prepend>
|
||||
<template v-if="$slots.prepend" #prepend>
|
||||
<slot name="prepend" />
|
||||
</template>
|
||||
<template #append>
|
||||
<QIcon
|
||||
name="close"
|
||||
size="xs"
|
||||
:style="{
|
||||
visibility:
|
||||
hover &&
|
||||
value &&
|
||||
!$attrs.disabled &&
|
||||
!$attrs.readonly &&
|
||||
$props.clearable
|
||||
? 'visible'
|
||||
: 'hidden',
|
||||
}"
|
||||
v-if="
|
||||
hover &&
|
||||
value &&
|
||||
!$attrs.disabled &&
|
||||
!$attrs.readonly &&
|
||||
$props.clearable
|
||||
"
|
||||
@click="
|
||||
() => {
|
||||
value = null;
|
||||
|
@ -167,15 +156,6 @@ const handleUppercase = () => {
|
|||
}
|
||||
"
|
||||
></QIcon>
|
||||
|
||||
<QIcon
|
||||
name="match_case"
|
||||
size="xs"
|
||||
v-if="!$attrs.disabled && !($attrs.readonly) && $props.uppercase"
|
||||
@click="handleUppercase"
|
||||
class="uppercase-icon"
|
||||
/>
|
||||
|
||||
<slot name="append" v-if="$slots.append && !$attrs.disabled" />
|
||||
<QIcon v-if="info" name="info">
|
||||
<QTooltip max-width="350px">
|
||||
|
@ -186,7 +166,6 @@ const handleUppercase = () => {
|
|||
</QInput>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
en:
|
||||
inputMin: Must be more than {value}
|
||||
|
@ -196,4 +175,9 @@ const handleUppercase = () => {
|
|||
inputMin: Debe ser mayor a {value}
|
||||
maxLength: El valor excede los {value} carácteres
|
||||
inputMax: Debe ser menor a {value}
|
||||
</i18n>
|
||||
</i18n>
|
||||
<style lang="scss">
|
||||
.q-field__append {
|
||||
padding-inline: 0;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
<script setup>
|
||||
import { onMounted, watch, computed, ref, useAttrs } from 'vue';
|
||||
import { date } from 'quasar';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import VnDate from './VnDate.vue';
|
||||
import { useRequired } from 'src/composables/useRequired';
|
||||
|
||||
const $attrs = useAttrs();
|
||||
const { isRequired, requiredFieldRule } = useRequired($attrs);
|
||||
const model = defineModel({ type: [String, Date] });
|
||||
const { t } = useI18n();
|
||||
|
||||
const $props = defineProps({
|
||||
isOutlined: {
|
||||
|
@ -104,8 +106,7 @@ const manageDate = (date) => {
|
|||
:class="{ required: isRequired }"
|
||||
:rules="mixinRules"
|
||||
:clearable="false"
|
||||
@click="isPopupOpen = !isPopupOpen"
|
||||
@keydown="isPopupOpen = false"
|
||||
@click="isPopupOpen = true"
|
||||
hide-bottom-space
|
||||
>
|
||||
<template #append>
|
||||
|
@ -124,6 +125,13 @@ const manageDate = (date) => {
|
|||
isPopupOpen = false;
|
||||
"
|
||||
/>
|
||||
<QIcon
|
||||
v-if="showEvent"
|
||||
name="event"
|
||||
class="cursor-pointer"
|
||||
@click="isPopupOpen = !isPopupOpen"
|
||||
:title="t('Open date')"
|
||||
/>
|
||||
</template>
|
||||
<QMenu
|
||||
v-if="$q.screen.gt.xs"
|
||||
|
@ -143,6 +151,15 @@ const manageDate = (date) => {
|
|||
</QInput>
|
||||
</div>
|
||||
</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>
|
||||
es:
|
||||
Open date: Abrir fecha
|
||||
|
|
|
@ -1,28 +1,13 @@
|
|||
<script setup>
|
||||
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 },
|
||||
});
|
||||
import { ref } from 'vue';
|
||||
import { useAttrs } from 'vue';
|
||||
|
||||
const model = defineModel({ type: [Number, String] });
|
||||
const $attrs = useAttrs();
|
||||
const step = ref($attrs.step || 0.01);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnInput
|
||||
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);
|
||||
}
|
||||
"
|
||||
/>
|
||||
<VnInput v-bind="$attrs" v-model.number="model" type="number" :step="step" />
|
||||
</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,13 @@
|
|||
<script setup>
|
||||
import { computed, ref, useAttrs } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { date } from 'quasar';
|
||||
import VnTime from './VnTime.vue';
|
||||
import { useRequired } from 'src/composables/useRequired';
|
||||
|
||||
const $attrs = useAttrs();
|
||||
const { isRequired, requiredFieldRule } = useRequired($attrs);
|
||||
const { t } = useI18n();
|
||||
const model = defineModel({ type: String });
|
||||
const props = defineProps({
|
||||
timeOnly: {
|
||||
|
@ -78,8 +80,7 @@ function dateToTime(newDate) {
|
|||
:class="{ required: isRequired }"
|
||||
style="min-width: 100px"
|
||||
:rules="mixinRules"
|
||||
@click="isPopupOpen = !isPopupOpen"
|
||||
@keydown="isPopupOpen = false"
|
||||
@click="isPopupOpen = false"
|
||||
type="time"
|
||||
hide-bottom-space
|
||||
>
|
||||
|
@ -99,6 +100,12 @@ function dateToTime(newDate) {
|
|||
isPopupOpen = false;
|
||||
"
|
||||
/>
|
||||
<QIcon
|
||||
name="Schedule"
|
||||
class="cursor-pointer"
|
||||
@click="isPopupOpen = !isPopupOpen"
|
||||
:title="t('Open time')"
|
||||
/>
|
||||
</template>
|
||||
<QMenu
|
||||
v-if="$q.screen.gt.xs"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import CreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue';
|
||||
import VnSelectDialog from 'components/common/VnSelectDialog.vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ref, watch } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
import { useAttrs } from 'vue';
|
||||
import { useRequired } from 'src/composables/useRequired';
|
||||
const { t } = useI18n();
|
||||
|
@ -16,14 +16,6 @@ const props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.location,
|
||||
(newValue) => {
|
||||
if (!modelValue.value) return;
|
||||
modelValue.value = formatLocation(newValue) ?? null;
|
||||
}
|
||||
);
|
||||
|
||||
const mixinRules = [requiredFieldRule];
|
||||
const locationProperties = [
|
||||
'postcode',
|
||||
|
@ -34,7 +26,7 @@ const locationProperties = [
|
|||
(obj) => obj.country?.name,
|
||||
];
|
||||
|
||||
const formatLocation = (obj, properties = locationProperties) => {
|
||||
const formatLocation = (obj, properties) => {
|
||||
const parts = properties.map((prop) => {
|
||||
if (typeof prop === 'string') {
|
||||
return obj[prop];
|
||||
|
@ -51,7 +43,9 @@ const formatLocation = (obj, properties = locationProperties) => {
|
|||
return filteredParts.join(', ');
|
||||
};
|
||||
|
||||
const modelValue = ref(props.location ? formatLocation(props.location) : null);
|
||||
const modelValue = computed(() =>
|
||||
props.location ? formatLocation(props.location, locationProperties) : null
|
||||
);
|
||||
|
||||
function showLabel(data) {
|
||||
const dataProperties = [
|
||||
|
@ -70,6 +64,9 @@ const handleModelValue = (data) => {
|
|||
<VnSelectDialog
|
||||
v-model="modelValue"
|
||||
option-filter-value="search"
|
||||
:option-label="
|
||||
(opt) => (typeof modelValue === 'string' ? modelValue : showLabel(opt))
|
||||
"
|
||||
url="Postcodes/filter"
|
||||
@update:model-value="handleModelValue"
|
||||
:use-like="false"
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
<script setup>
|
||||
import RightMenu from './RightMenu.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 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);
|
||||
});
|
||||
|
||||
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>
|
||||
<RightMenu>
|
||||
<template #right-panel v-if="$slots['rightMenu'] || rightFilter">
|
||||
<slot name="rightMenu">
|
||||
<VnTableFilter
|
||||
v-if="rightFilter && columns"
|
||||
:data-key="dataKey"
|
||||
:array-data="arrayData"
|
||||
:columns="columns"
|
||||
/>
|
||||
</slot>
|
||||
</template>
|
||||
</RightMenu>
|
||||
<slot name="body" v-if="isMainSection" />
|
||||
<RouterView v-else />
|
||||
</template>
|
|
@ -1,8 +1,8 @@
|
|||
<script setup>
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import LeftMenu from 'components/LeftMenu.vue';
|
||||
import { onMounted } from 'vue';
|
||||
import { useQuasar } from 'quasar';
|
||||
import LeftMenu from '../LeftMenu.vue';
|
||||
|
||||
const stateStore = useStateStore();
|
||||
const $props = defineProps({
|
||||
|
@ -14,29 +14,12 @@ const $props = defineProps({
|
|||
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" />
|
||||
<LeftMenu />
|
||||
</QScrollArea>
|
||||
</QDrawer>
|
||||
<QPageContainer>
|
|
@ -4,7 +4,6 @@ import { useI18n } from 'vue-i18n';
|
|||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
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 $attrs = useAttrs();
|
||||
|
@ -34,10 +33,6 @@ const $props = defineProps({
|
|||
type: String,
|
||||
default: 'id',
|
||||
},
|
||||
optionCaption: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
optionFilter: {
|
||||
type: String,
|
||||
default: null,
|
||||
|
@ -106,22 +101,11 @@ const $props = defineProps({
|
|||
type: String,
|
||||
default: null,
|
||||
},
|
||||
isOutlined: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
const mixinRules = [requiredFieldRule, ...($attrs.rules ?? [])];
|
||||
const {
|
||||
optionLabel,
|
||||
optionValue,
|
||||
optionCaption,
|
||||
optionFilter,
|
||||
optionFilterValue,
|
||||
options,
|
||||
modelValue,
|
||||
} = toRefs($props);
|
||||
const { optionLabel, optionValue, optionFilter, optionFilterValue, options, modelValue } =
|
||||
toRefs($props);
|
||||
const myOptions = ref([]);
|
||||
const myOptionsOriginal = ref([]);
|
||||
const vnSelectRef = ref();
|
||||
|
@ -131,15 +115,6 @@ 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({
|
||||
|
@ -173,11 +148,7 @@ onMounted(() => {
|
|||
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'],
|
||||
});
|
||||
const arrayData = useArrayData(arrayDataKey, { url: $props.url, searchUrl: false });
|
||||
|
||||
function findKeyInOptions() {
|
||||
if (!$props.options) return;
|
||||
|
@ -205,10 +176,10 @@ function filter(val, options) {
|
|||
}
|
||||
|
||||
if (!row) return;
|
||||
const id = String(row[$props.optionValue]);
|
||||
const id = row[$props.optionValue];
|
||||
const optionLabel = String(row[$props.optionLabel]).toLowerCase();
|
||||
|
||||
return id.includes(search) || optionLabel.includes(search);
|
||||
return id == search || optionLabel.includes(search);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -232,15 +203,12 @@ async function fetchFilter(val) {
|
|||
} else defaultWhere = { [key]: getVal(val) };
|
||||
const where = { ...(val ? defaultWhere : {}), ...$props.where };
|
||||
$props.exprBuilder && Object.assign(where, $props.exprBuilder(key, val));
|
||||
const filterOptions = { where, include, limit };
|
||||
if (fields) filterOptions.fields = fields;
|
||||
if (sortBy) filterOptions.order = sortBy;
|
||||
arrayData.resetPagination();
|
||||
const fetchOptions = { where, include, limit };
|
||||
if (fields) fetchOptions.fields = fields;
|
||||
if (sortBy) fetchOptions.order = sortBy;
|
||||
arrayData.reset(['skip', 'filter.skip', 'page']);
|
||||
|
||||
const { data } = await arrayData.applyFilter(
|
||||
{ filter: filterOptions },
|
||||
{ updateRouter: false }
|
||||
);
|
||||
const { data } = await arrayData.applyFilter({ filter: fetchOptions });
|
||||
setOptions(data);
|
||||
return data;
|
||||
}
|
||||
|
@ -297,7 +265,7 @@ async function onScroll({ to, direction, from, index }) {
|
|||
}
|
||||
}
|
||||
|
||||
defineExpose({ opts: myOptions, vnSelectRef });
|
||||
defineExpose({ opts: myOptions });
|
||||
|
||||
function handleKeyDown(event) {
|
||||
if (event.key === 'Tab' && !event.shiftKey) {
|
||||
|
@ -320,7 +288,7 @@ function handleKeyDown(event) {
|
|||
}
|
||||
|
||||
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])'
|
||||
'a, button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])'
|
||||
);
|
||||
const currentIndex = Array.prototype.indexOf.call(
|
||||
focusableElements,
|
||||
|
@ -331,11 +299,6 @@ function handleKeyDown(event) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getCaption(opt) {
|
||||
if (optionCaption.value === false) return;
|
||||
return opt[optionCaption.value] || opt[optionValue.value];
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -344,8 +307,9 @@ function getCaption(opt) {
|
|||
:options="myOptions"
|
||||
:option-label="optionLabel"
|
||||
:option-value="optionValue"
|
||||
v-bind="{ ...$attrs, ...styleAttrs }"
|
||||
v-bind="$attrs"
|
||||
@filter="filterHandler"
|
||||
@keydown="handleKeyDown"
|
||||
:emit-value="nullishToTrue($attrs['emit-value'])"
|
||||
:map-options="nullishToTrue($attrs['map-options'])"
|
||||
:use-input="nullishToTrue($attrs['use-input'])"
|
||||
|
@ -360,15 +324,13 @@ function getCaption(opt) {
|
|||
:input-debounce="useURL ? '300' : '0'"
|
||||
:loading="isLoading"
|
||||
@virtual-scroll="onScroll"
|
||||
@keydown="handleKeyDown"
|
||||
:data-cy="$attrs.dataCy ?? $attrs.label + '_select'"
|
||||
:data-url="url"
|
||||
>
|
||||
<template #append>
|
||||
<QIcon
|
||||
v-show="isClearable && value"
|
||||
name="close"
|
||||
@click="
|
||||
@click.stop="
|
||||
() => {
|
||||
value = null;
|
||||
emit('remove');
|
||||
|
@ -396,22 +358,6 @@ function getCaption(opt) {
|
|||
</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>
|
||||
</QSelect>
|
||||
</template>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
import { useRole } from 'src/composables/useRole';
|
||||
import { useAcl } from 'src/composables/useAcl';
|
||||
|
||||
|
@ -7,7 +7,6 @@ import VnSelect from 'src/components/common/VnSelect.vue';
|
|||
const emit = defineEmits(['update:modelValue']);
|
||||
|
||||
const value = defineModel({ type: [String, Number, Object] });
|
||||
const select = ref(null);
|
||||
const $props = defineProps({
|
||||
rolesAllowedToCreate: {
|
||||
type: Array,
|
||||
|
@ -34,13 +33,10 @@ const isAllowedToCreate = computed(() => {
|
|||
if ($props.acls.length) return acl.hasAny($props.acls);
|
||||
return role.hasAny($props.rolesAllowedToCreate);
|
||||
});
|
||||
|
||||
defineExpose({ vnSelectDialogRef: select });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnSelect
|
||||
ref="select"
|
||||
v-model="value"
|
||||
v-bind="$attrs"
|
||||
@update:model-value="(...args) => emit('update:modelValue', ...args)"
|
||||
|
|
|
@ -51,11 +51,10 @@ const url = computed(() => {
|
|||
option-value="id"
|
||||
option-label="nickname"
|
||||
:fields="['id', 'name', 'nickname', 'code']"
|
||||
:filter-options="['id', 'name', 'nickname', 'code']"
|
||||
sort-by="nickname ASC"
|
||||
>
|
||||
<template #prepend v-if="$props.hasAvatar">
|
||||
<VnAvatar :worker-id="value" color="primary" v-bind="$attrs" />
|
||||
<VnAvatar :worker-id="value" color="primary" :title="title" />
|
||||
</template>
|
||||
<template #append v-if="$props.hasInfo">
|
||||
<QIcon name="info" class="cursor-pointer">
|
||||
|
@ -72,8 +71,7 @@ const url = computed(() => {
|
|||
{{ scope.opt.nickname }}
|
||||
</QItemLabel>
|
||||
<QItemLabel caption v-else>
|
||||
#{{ scope.opt.id }}, {{ scope.opt.nickname }},
|
||||
{{ scope.opt.code }}
|
||||
{{ scope.opt.nickname }}, {{ scope.opt.code }}
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import VnDmsList from 'src/components/common/VnDmsList.vue';
|
||||
import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
|
||||
describe('VnDmsList', () => {
|
||||
let vm;
|
||||
const dms = {
|
||||
userFk: 1,
|
||||
name: 'DMS 1'
|
||||
};
|
||||
|
||||
beforeAll(() => {
|
||||
vi.spyOn(axios, 'get').mockResolvedValue({ data: [] });
|
||||
vm = createWrapper(VnDmsList, {
|
||||
props: {
|
||||
model: 'WorkerDms/1110/filter',
|
||||
defaultDmsCode: 'hhrrData',
|
||||
filter: 'wd.workerFk',
|
||||
updateModel: 'Workers',
|
||||
deleteModel: 'WorkerDms',
|
||||
downloadModel: 'WorkerDms'
|
||||
}
|
||||
}).vm;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('setData()', () => {
|
||||
const data = [
|
||||
{
|
||||
userFk: 1,
|
||||
name: 'Jessica',
|
||||
lastName: 'Jones',
|
||||
file: '4.jpg',
|
||||
created: '2021-07-28 21:00:00'
|
||||
},
|
||||
{
|
||||
userFk: 2,
|
||||
name: 'Bruce',
|
||||
lastName: 'Banner',
|
||||
created: '2022-07-28 21:00:00',
|
||||
dms: {
|
||||
userFk: 2,
|
||||
name: 'Bruce',
|
||||
lastName: 'BannerDMS',
|
||||
created: '2022-07-28 21:00:00',
|
||||
file: '4.jpg',
|
||||
}
|
||||
},
|
||||
{
|
||||
userFk: 3,
|
||||
name: 'Natasha',
|
||||
lastName: 'Romanoff',
|
||||
file: '4.jpg',
|
||||
created: '2021-10-28 21:00:00'
|
||||
}
|
||||
]
|
||||
|
||||
it('Should replace objects that contain the "dms" property with the value of the same and sort by creation date', () => {
|
||||
vm.setData(data);
|
||||
expect([vm.rows][0][0].lastName).toEqual('BannerDMS');
|
||||
expect([vm.rows][0][1].lastName).toEqual('Romanoff');
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseDms()', () => {
|
||||
const resultDms = { ...dms, userId:1};
|
||||
|
||||
it('Should add properties that end with "Fk" by changing the suffix to "Id"', () => {
|
||||
const parsedDms = vm.parseDms(dms);
|
||||
expect(parsedDms).toEqual(resultDms);
|
||||
});
|
||||
});
|
||||
|
||||
describe('showFormDialog()', () => {
|
||||
const resultDms = { ...dms, userId:1};
|
||||
|
||||
it('should call fn parseDms() and set show true if dms is defined', () => {
|
||||
vm.showFormDialog(dms);
|
||||
expect(vm.formDialog.show).toEqual(true);
|
||||
expect(vm.formDialog.dms).toEqual(resultDms);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,72 +0,0 @@
|
|||
import { createWrapper } from 'app/test/vitest/helper.js';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||
|
||||
let vm;
|
||||
let wrapper;
|
||||
|
||||
function generateWrapper(date, outlined, required) {
|
||||
wrapper = createWrapper(VnInputDate, {
|
||||
props: {
|
||||
modelValue: date,
|
||||
},
|
||||
attrs: {
|
||||
isOutlined: outlined,
|
||||
required: required
|
||||
},
|
||||
});
|
||||
wrapper = wrapper.wrapper;
|
||||
vm = wrapper.vm;
|
||||
};
|
||||
|
||||
describe('VnInputDate', () => {
|
||||
|
||||
describe('formattedDate', () => {
|
||||
it('formats a valid date correctly', async () => {
|
||||
generateWrapper('2023-12-25', false, false);
|
||||
await vm.$nextTick();
|
||||
expect(vm.formattedDate).toBe('25/12/2023');
|
||||
});
|
||||
|
||||
it('updates the model value when a new date is set', async () => {
|
||||
const input = wrapper.find('input');
|
||||
await input.setValue('31/12/2023');
|
||||
expect(wrapper.emitted()['update:modelValue']).toBeTruthy();
|
||||
expect(wrapper.emitted()['update:modelValue'][0][0]).toBe('2023-12-31T00:00:00.000Z');
|
||||
});
|
||||
|
||||
it('should not update the model value when an invalid date is set', async () => {
|
||||
const input = wrapper.find('input');
|
||||
await input.setValue('invalid-date');
|
||||
expect(wrapper.emitted()['update:modelValue'][0][0]).toBe('2023-12-31T00:00:00.000Z');
|
||||
});
|
||||
});
|
||||
|
||||
describe('styleAttrs', () => {
|
||||
it('should return empty styleAttrs when isOutlined is false', async () => {
|
||||
generateWrapper('2023-12-25', false, false);
|
||||
await vm.$nextTick();
|
||||
expect(vm.styleAttrs).toEqual({});
|
||||
});
|
||||
|
||||
it('should set styleAttrs when isOutlined is true', async () => {
|
||||
generateWrapper('2023-12-25', true, false);
|
||||
await vm.$nextTick();
|
||||
expect(vm.styleAttrs.outlined).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('required', () => {
|
||||
it('should not applies required class when isRequired is false', async () => {
|
||||
generateWrapper('2023-12-25', false, false);
|
||||
await vm.$nextTick();
|
||||
expect(wrapper.find('.vn-input-date').classes()).not.toContain('required');
|
||||
});
|
||||
|
||||
it('should applies required class when isRequired is true', async () => {
|
||||
generateWrapper('2023-12-25', false, true);
|
||||
await vm.$nextTick();
|
||||
expect(wrapper.find('.vn-input-date').classes()).toContain('required');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,63 +0,0 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import VnInputTime from 'components/common/VnInputTime.vue';
|
||||
|
||||
describe('VnInputTime', () => {
|
||||
let wrapper;
|
||||
let vm;
|
||||
|
||||
beforeAll(() => {
|
||||
wrapper = createWrapper(VnInputTime, {
|
||||
props: {
|
||||
isOutlined: true,
|
||||
timeOnly: false,
|
||||
},
|
||||
});
|
||||
vm = wrapper.vm;
|
||||
wrapper = wrapper.wrapper;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should return the correct data if isOutlined is true', () => {
|
||||
expect(vm.isOutlined).toBe(true);
|
||||
expect(vm.styleAttrs).toEqual({ dense: true, outlined: true, rounded: true });
|
||||
});
|
||||
|
||||
it('should return the formatted data', () => {
|
||||
expect(vm.dateToTime('2022-01-01T03:23:43')).toBe('03:23');
|
||||
});
|
||||
|
||||
describe('formattedTime', () => {
|
||||
it('should return the formatted time for a valid ISO date', () => {
|
||||
vm.model = '2025-01-02T15:45:00';
|
||||
expect(vm.formattedTime).toBe('15:45');
|
||||
});
|
||||
|
||||
it('should handle null model value gracefully', () => {
|
||||
vm.model = null;
|
||||
expect(vm.formattedTime).toBe(null);
|
||||
});
|
||||
|
||||
it('should handle time-only input correctly', async () => {
|
||||
await wrapper.setProps({ timeOnly: true });
|
||||
vm.formattedTime = '14:30';
|
||||
expect(vm.model).toBe('14:30');
|
||||
});
|
||||
|
||||
it('should pad short time values correctly', async () => {
|
||||
await wrapper.setProps({ timeOnly: true });
|
||||
vm.formattedTime = '9';
|
||||
expect(vm.model).toBe('09:00');
|
||||
});
|
||||
|
||||
it('should not update the model if the value is unchanged', () => {
|
||||
vm.model = '14:30';
|
||||
const previousModel = vm.model;
|
||||
vm.formattedTime = '14:30';
|
||||
expect(vm.model).toBe(previousModel);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,95 +0,0 @@
|
|||
import { describe, it, expect } from 'vitest';
|
||||
import VnJsonValue from 'src/components/common/VnJsonValue.vue';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
|
||||
const buildComponent = (props) => {
|
||||
return createWrapper(VnJsonValue, {
|
||||
props,
|
||||
}).wrapper;
|
||||
};
|
||||
|
||||
describe('VnJsonValue', () => {
|
||||
it('renders null value correctly', async () => {
|
||||
const wrapper = buildComponent({ value: null });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe('∅');
|
||||
expect(span.classes()).toContain('json-null');
|
||||
});
|
||||
|
||||
it('renders boolean true correctly', async () => {
|
||||
const wrapper = buildComponent({ value: true });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe('✓');
|
||||
expect(span.classes()).toContain('json-true');
|
||||
});
|
||||
|
||||
it('renders boolean false correctly', async () => {
|
||||
const wrapper = buildComponent({ value: false });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe('✗');
|
||||
expect(span.classes()).toContain('json-false');
|
||||
});
|
||||
|
||||
it('renders a short string correctly', async () => {
|
||||
const wrapper = buildComponent({ value: 'Hello' });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe('Hello');
|
||||
expect(span.classes()).toContain('json-string');
|
||||
});
|
||||
|
||||
it('renders a long string correctly with ellipsis', async () => {
|
||||
const longString = 'a'.repeat(600);
|
||||
const wrapper = buildComponent({ value: longString });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toContain('...');
|
||||
expect(span.text().length).toBeLessThanOrEqual(515);
|
||||
expect(span.attributes('title')).toBe(longString);
|
||||
expect(span.classes()).toContain('json-string');
|
||||
});
|
||||
|
||||
it('renders a number correctly', async () => {
|
||||
const wrapper = buildComponent({ value: 123.4567 });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe('123.457');
|
||||
expect(span.classes()).toContain('json-number');
|
||||
});
|
||||
|
||||
it('renders an integer correctly', async () => {
|
||||
const wrapper = buildComponent({ value: 42 });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe('42');
|
||||
expect(span.classes()).toContain('json-number');
|
||||
});
|
||||
|
||||
it('renders a date correctly', async () => {
|
||||
const date = new Date('2023-01-01');
|
||||
const wrapper = buildComponent({ value: date });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe('2023-01-01');
|
||||
expect(span.classes()).toContain('json-object');
|
||||
});
|
||||
|
||||
it('renders an object correctly', async () => {
|
||||
const obj = { key: 'value' };
|
||||
const wrapper = buildComponent({ value: obj });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe(obj.toString());
|
||||
expect(span.classes()).toContain('json-object');
|
||||
});
|
||||
|
||||
it('renders an array correctly', async () => {
|
||||
const arr = [1, 2, 3];
|
||||
const wrapper = buildComponent({ value: arr });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe(arr.toString());
|
||||
expect(span.classes()).toContain('json-object');
|
||||
});
|
||||
|
||||
it('updates value when prop changes', async () => {
|
||||
const wrapper = buildComponent({ value: true });
|
||||
await wrapper.setProps({ value: 123 });
|
||||
const span = wrapper.find('span');
|
||||
expect(span.text()).toBe('123');
|
||||
expect(span.classes()).toContain('json-number');
|
||||
});
|
||||
});
|
|
@ -1,91 +0,0 @@
|
|||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import VnLocation from 'components/common/VnLocation.vue';
|
||||
import { vi, afterEach, expect, it, beforeEach, describe } from 'vitest';
|
||||
|
||||
function buildComponent(data) {
|
||||
return createWrapper(VnLocation, {
|
||||
global: {
|
||||
props: {
|
||||
location: data
|
||||
}
|
||||
},
|
||||
}).vm;
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('formatLocation', () => {
|
||||
let locationBase;
|
||||
|
||||
beforeEach(() => {
|
||||
locationBase = {
|
||||
postcode: '46680',
|
||||
city: 'Algemesi',
|
||||
province: { name: 'Valencia' },
|
||||
country: { name: 'Spain' }
|
||||
};
|
||||
});
|
||||
|
||||
it('should return the postcode, city, province and country', () => {
|
||||
const location = { ...locationBase };
|
||||
const vm = buildComponent(location);
|
||||
expect(vm.formatLocation(location)).toEqual('46680, Algemesi(Valencia), Spain');
|
||||
});
|
||||
|
||||
it('should return the postcode and country', () => {
|
||||
const location = { ...locationBase, city: undefined };
|
||||
const vm = buildComponent(location);
|
||||
expect(vm.formatLocation(location)).toEqual('46680, Spain');
|
||||
});
|
||||
|
||||
it('should return the city, province and country', () => {
|
||||
const location = { ...locationBase, postcode: undefined };
|
||||
const vm = buildComponent(location);
|
||||
expect(vm.formatLocation(location)).toEqual('Algemesi(Valencia), Spain');
|
||||
});
|
||||
|
||||
it('should return the country', () => {
|
||||
const location = { ...locationBase, postcode: undefined, city: undefined, province: undefined };
|
||||
const vm = buildComponent(location);
|
||||
expect(vm.formatLocation(location)).toEqual('Spain');
|
||||
});
|
||||
});
|
||||
|
||||
describe('showLabel', () => {
|
||||
let locationBase;
|
||||
|
||||
beforeEach(() => {
|
||||
locationBase = {
|
||||
code: '46680',
|
||||
town: 'Algemesi',
|
||||
province: 'Valencia',
|
||||
country: 'Spain'
|
||||
};
|
||||
});
|
||||
|
||||
it('should show the label with postcode, city, province and country', () => {
|
||||
const location = { ...locationBase };
|
||||
const vm = buildComponent(location);
|
||||
expect(vm.showLabel(location)).toEqual('46680, Algemesi(Valencia), Spain');
|
||||
});
|
||||
|
||||
it('should show the label with postcode and country', () => {
|
||||
const location = { ...locationBase, town: undefined };
|
||||
const vm = buildComponent(location);
|
||||
expect(vm.showLabel(location)).toEqual('46680, Spain');
|
||||
});
|
||||
|
||||
it('should show the label with city, province and country', () => {
|
||||
const location = { ...locationBase, code: undefined };
|
||||
const vm = buildComponent(location);
|
||||
expect(vm.showLabel(location)).toEqual('Algemesi(Valencia), Spain');
|
||||
});
|
||||
|
||||
it('should show the label with country', () => {
|
||||
const location = { ...locationBase, code: undefined, town: undefined, province: undefined };
|
||||
const vm = buildComponent(location);
|
||||
expect(vm.showLabel(location)).toEqual('Spain');
|
||||
});
|
||||
});
|
|
@ -1,107 +0,0 @@
|
|||
import { describe, it, expect, vi, beforeAll, afterEach, beforeEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import VnNotes from 'src/components/ui/VnNotes.vue';
|
||||
|
||||
describe('VnNotes', () => {
|
||||
let vm;
|
||||
let wrapper;
|
||||
let spyFetch;
|
||||
let postMock;
|
||||
let expectedBody;
|
||||
const mockData= {name: 'Tony', lastName: 'Stark', text: 'Test Note', observationTypeFk: 1};
|
||||
|
||||
function generateExpectedBody() {
|
||||
expectedBody = {...vm.$props.body, ...{ text: vm.newNote.text, observationTypeFk: vm.newNote.observationTypeFk }};
|
||||
}
|
||||
|
||||
async function setTestParams(text, observationType, type){
|
||||
vm.newNote.text = text;
|
||||
vm.newNote.observationTypeFk = observationType;
|
||||
wrapper.setProps({ selectType: type });
|
||||
}
|
||||
|
||||
beforeAll(async () => {
|
||||
vi.spyOn(axios, 'get').mockReturnValue({ data: [] });
|
||||
|
||||
wrapper = createWrapper(VnNotes, {
|
||||
propsData: {
|
||||
url: '/test',
|
||||
body: { name: 'Tony', lastName: 'Stark' },
|
||||
}
|
||||
});
|
||||
wrapper = wrapper.wrapper;
|
||||
vm = wrapper.vm;
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
postMock = vi.spyOn(axios, 'post').mockResolvedValue(mockData);
|
||||
spyFetch = vi.spyOn(vm.vnPaginateRef, 'fetch').mockImplementation(() => vi.fn());
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
expectedBody = {};
|
||||
});
|
||||
|
||||
describe('insert', () => {
|
||||
it('should not call axios.post and vnPaginateRef.fetch if newNote.text is null', async () => {
|
||||
await setTestParams( null, null, true );
|
||||
|
||||
await vm.insert();
|
||||
|
||||
expect(postMock).not.toHaveBeenCalled();
|
||||
expect(spyFetch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not call axios.post and vnPaginateRef.fetch if newNote.text is empty', async () => {
|
||||
await setTestParams( "", null, false );
|
||||
|
||||
await vm.insert();
|
||||
|
||||
expect(postMock).not.toHaveBeenCalled();
|
||||
expect(spyFetch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not call axios.post and vnPaginateRef.fetch if observationTypeFk is missing and selectType is true', async () => {
|
||||
await setTestParams( "Test Note", null, true );
|
||||
|
||||
await vm.insert();
|
||||
|
||||
expect(postMock).not.toHaveBeenCalled();
|
||||
expect(spyFetch).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call axios.post and vnPaginateRef.fetch if observationTypeFk is missing and selectType is false', async () => {
|
||||
await setTestParams( "Test Note", null, false );
|
||||
|
||||
generateExpectedBody();
|
||||
|
||||
await vm.insert();
|
||||
|
||||
expect(postMock).toHaveBeenCalledWith(vm.$props.url, expectedBody);
|
||||
expect(spyFetch).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call axios.post and vnPaginateRef.fetch if observationTypeFk is setted and selectType is false', async () => {
|
||||
await setTestParams( "Test Note", 1, false );
|
||||
|
||||
generateExpectedBody();
|
||||
|
||||
await vm.insert();
|
||||
|
||||
expect(postMock).toHaveBeenCalledWith(vm.$props.url, expectedBody);
|
||||
expect(spyFetch).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call axios.post and vnPaginateRef.fetch when newNote is valid', async () => {
|
||||
await setTestParams( "Test Note", 1, true );
|
||||
|
||||
generateExpectedBody();
|
||||
|
||||
await vm.insert();
|
||||
|
||||
expect(postMock).toHaveBeenCalledWith(vm.$props.url, expectedBody);
|
||||
expect(spyFetch).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -6,7 +6,6 @@ import { useArrayData } from 'composables/useArrayData';
|
|||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||
import { useState } from 'src/composables/useState';
|
||||
import { useRoute } from 'vue-router';
|
||||
import VnMoreOptions from './VnMoreOptions.vue';
|
||||
|
||||
const $props = defineProps({
|
||||
url: {
|
||||
|
@ -48,6 +47,7 @@ let store;
|
|||
let entity;
|
||||
const isLoading = ref(false);
|
||||
const isSameDataKey = computed(() => $props.dataKey === route.meta.moduleName);
|
||||
const menuRef = ref();
|
||||
defineExpose({ getData });
|
||||
|
||||
onBeforeMount(async () => {
|
||||
|
@ -159,11 +159,25 @@ const toModule = computed(() =>
|
|||
</QTooltip>
|
||||
</QBtn>
|
||||
</RouterLink>
|
||||
<VnMoreOptions v-if="$slots.menu">
|
||||
<template #menu="{ menuRef }">
|
||||
<slot name="menu" :entity="entity" :menu-ref="menuRef" />
|
||||
</template>
|
||||
</VnMoreOptions>
|
||||
<QBtn
|
||||
v-if="$slots.menu"
|
||||
color="white"
|
||||
dense
|
||||
flat
|
||||
icon="more_vert"
|
||||
round
|
||||
size="md"
|
||||
data-cy="descriptor-more-opts"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('components.cardDescriptor.moreOptions') }}
|
||||
</QTooltip>
|
||||
<QMenu :ref="menuRef">
|
||||
<QList>
|
||||
<slot name="menu" :entity="entity" :menu-ref="menuRef" />
|
||||
</QList>
|
||||
</QMenu>
|
||||
</QBtn>
|
||||
</div>
|
||||
<slot name="before" />
|
||||
<div class="body q-py-sm">
|
||||
|
@ -208,8 +222,8 @@ const toModule = computed(() =>
|
|||
/>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
.body {
|
||||
<style lang="scss" scoped>
|
||||
:deep(.body) {
|
||||
background-color: var(--vn-section-color);
|
||||
.text-h5 {
|
||||
font-size: 20px;
|
||||
|
@ -248,9 +262,7 @@ const toModule = computed(() =>
|
|||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.title {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
import { ref, computed, watch, onBeforeMount } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import SkeletonSummary from 'components/ui/SkeletonSummary.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { isDialogOpened } from 'src/filters';
|
||||
import VnMoreOptions from './VnMoreOptions.vue';
|
||||
|
||||
const props = defineProps({
|
||||
url: {
|
||||
|
@ -81,16 +81,11 @@ async function fetch() {
|
|||
<span v-else></span>
|
||||
</slot>
|
||||
<slot name="header" :entity="entity" dense>
|
||||
{{ entity.id + ' - ' + entity.name }}
|
||||
<VnLv :label="`${entity.id} -`" :value="entity.name" />
|
||||
</slot>
|
||||
<slot name="header-right" :entity="entity">
|
||||
<span></span>
|
||||
</slot>
|
||||
<span class="row no-wrap">
|
||||
<slot name="header-right" :entity="entity" />
|
||||
<VnMoreOptions v-if="$slots.menu && isDialogOpened()">
|
||||
<template #menu="{ menuRef }">
|
||||
<slot name="menu" :entity="entity" :menu-ref="menuRef" />
|
||||
</template>
|
||||
</VnMoreOptions>
|
||||
</span>
|
||||
</div>
|
||||
<div class="summaryBody row q-mb-md">
|
||||
<slot name="body" :entity="entity" />
|
||||
|
@ -175,7 +170,7 @@ async function fetch() {
|
|||
display: inline-block;
|
||||
}
|
||||
.header.link:hover {
|
||||
color: rgba(var(--q-primary), 0.8);
|
||||
color: lighten($primary, 20%);
|
||||
}
|
||||
.q-checkbox {
|
||||
& .q-checkbox__label {
|
||||
|
|
|
@ -16,12 +16,7 @@ const $props = defineProps({
|
|||
required: false,
|
||||
default: 'value',
|
||||
},
|
||||
columns: {
|
||||
type: Number,
|
||||
default: 3,
|
||||
},
|
||||
});
|
||||
|
||||
const tags = computed(() => {
|
||||
return Object.keys($props.item)
|
||||
.filter((i) => i.startsWith(`${$props.tag}`))
|
||||
|
@ -33,21 +28,10 @@ const tags = computed(() => {
|
|||
return acc;
|
||||
}, {});
|
||||
});
|
||||
|
||||
const columnStyle = computed(() => {
|
||||
if ($props.columns) {
|
||||
return {
|
||||
'grid-template-columns': `repeat(${$props.columns}, 1fr)`,
|
||||
'max-width': `${$props.columns * 4}rem`,
|
||||
};
|
||||
}
|
||||
return {};
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="fetchedTags">
|
||||
<div class="wrap" :style="columnStyle">
|
||||
<div class="wrap">
|
||||
<div
|
||||
v-for="(val, key) in tags"
|
||||
:key="key"
|
||||
|
@ -55,43 +39,37 @@ const columnStyle = computed(() => {
|
|||
:title="`${key}: ${val}`"
|
||||
:class="{ empty: !val }"
|
||||
>
|
||||
<span class="text">{{ val }} </span>
|
||||
{{ val }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.fetchedTags {
|
||||
align-items: center;
|
||||
.wrap {
|
||||
display: grid;
|
||||
width: 100%;
|
||||
flex-wrap: wrap;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.inline-tag {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 1rem;
|
||||
margin: 0.05rem;
|
||||
color: var(--vn-label-color);
|
||||
color: $color-font-secondary;
|
||||
text-align: center;
|
||||
font-size: smaller;
|
||||
padding: 1px;
|
||||
border: 1px solid var(--vn-label-color);
|
||||
flex: 1;
|
||||
border: 1px solid $color-spacer;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
min-width: 4rem;
|
||||
max-width: 4rem;
|
||||
}
|
||||
|
||||
.text {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
font-size: smaller;
|
||||
}
|
||||
.empty {
|
||||
border: 1px solid var(--vn-empty-tag);
|
||||
border: 1px solid #2b2b2b;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -1,49 +1,38 @@
|
|||
<template>
|
||||
<div class="header bg-primary q-pa-sm q-mb-md">
|
||||
<QSkeleton type="rect" square />
|
||||
<QSkeleton type="rect" square />
|
||||
</div>
|
||||
<div class="row q-pa-md q-col-gutter-md q-mb-md">
|
||||
<div class="col">
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
</div>
|
||||
<div class="col">
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
</div>
|
||||
<div class="col">
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
</div>
|
||||
<div class="col">
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
</div>
|
||||
<div class="col">
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
</div>
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="rect" class="q-mb-md" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
<QSkeleton type="text" square />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
|
@ -98,7 +98,6 @@ function cancel() {
|
|||
/>
|
||||
<QBtn
|
||||
:label="t('globals.confirm')"
|
||||
:title="t('globals.confirm')"
|
||||
color="primary"
|
||||
:loading="isLoading"
|
||||
@click="confirm()"
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { onMounted, ref, computed, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
import { useRoute } from 'vue-router';
|
||||
import toDate from 'filters/toDate';
|
||||
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
|
||||
import { useFilterParams } from 'src/composables/useFilterParams';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
const $props = defineProps({
|
||||
modelValue: {
|
||||
type: Object,
|
||||
|
@ -57,10 +55,6 @@ const $props = defineProps({
|
|||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
arrayData: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits([
|
||||
|
@ -73,19 +67,52 @@ const emit = defineEmits([
|
|||
'setUserParams',
|
||||
]);
|
||||
|
||||
const arrayData =
|
||||
$props.arrayData ??
|
||||
useArrayData($props.dataKey, {
|
||||
exprBuilder: $props.exprBuilder,
|
||||
searchUrl: $props.searchUrl,
|
||||
navigate: $props.redirect ? {} : null,
|
||||
});
|
||||
|
||||
const arrayData = useArrayData($props.dataKey, {
|
||||
exprBuilder: $props.exprBuilder,
|
||||
searchUrl: $props.searchUrl,
|
||||
navigate: $props.redirect ? {} : null,
|
||||
});
|
||||
const route = useRoute();
|
||||
const store = arrayData.store;
|
||||
const userParams = ref(useFilterParams($props.dataKey).params);
|
||||
const userOrders = ref(useFilterParams($props.dataKey).orders);
|
||||
const userParams = ref({});
|
||||
|
||||
defineExpose({ search, params: userParams, remove });
|
||||
defineExpose({ search, sanitizer, params: userParams });
|
||||
|
||||
onMounted(() => {
|
||||
if (!userParams.value) userParams.value = $props.modelValue ?? {};
|
||||
emit('init', { params: userParams.value });
|
||||
});
|
||||
|
||||
function setUserParams(watchedParams) {
|
||||
if (!watchedParams || Object.keys(watchedParams).length == 0) return;
|
||||
|
||||
if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams);
|
||||
if (typeof watchedParams?.filter == 'string')
|
||||
watchedParams.filter = JSON.parse(watchedParams.filter);
|
||||
|
||||
watchedParams = { ...watchedParams, ...watchedParams.filter?.where };
|
||||
const order = watchedParams.filter?.order;
|
||||
|
||||
delete watchedParams.filter;
|
||||
userParams.value = sanitizer(watchedParams);
|
||||
emit('setUserParams', userParams.value, order);
|
||||
}
|
||||
|
||||
watch(
|
||||
() => route.query[$props.searchUrl],
|
||||
(val, oldValue) => (val || oldValue) && setUserParams(val)
|
||||
);
|
||||
|
||||
watch(
|
||||
() => arrayData.store.userParams,
|
||||
(val, oldValue) => (val || oldValue) && setUserParams(val),
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
watch(
|
||||
() => $props.modelValue,
|
||||
(val) => (userParams.value = val ?? {})
|
||||
);
|
||||
|
||||
const isLoading = ref(false);
|
||||
async function search(evt) {
|
||||
|
@ -96,9 +123,10 @@ async function search(evt) {
|
|||
isLoading.value = true;
|
||||
const filter = { ...userParams.value, ...$props.modelValue };
|
||||
store.userParamsChanged = true;
|
||||
await arrayData.addFilter({
|
||||
const { params: newParams } = await arrayData.addFilter({
|
||||
params: filter,
|
||||
});
|
||||
userParams.value = newParams;
|
||||
|
||||
if (!$props.showAll && !Object.values(filter).length) store.data = [];
|
||||
emit('search');
|
||||
|
@ -111,7 +139,7 @@ async function clearFilters() {
|
|||
try {
|
||||
isLoading.value = true;
|
||||
store.userParamsChanged = true;
|
||||
arrayData.resetPagination();
|
||||
arrayData.reset(['skip', 'filter.skip', 'page']);
|
||||
// Filtrar los params no removibles
|
||||
const removableFilters = Object.keys(userParams.value).filter((param) =>
|
||||
$props.unremovableParams.includes(param)
|
||||
|
@ -121,8 +149,9 @@ async function clearFilters() {
|
|||
for (const key of removableFilters) {
|
||||
newParams[key] = userParams.value[key];
|
||||
}
|
||||
|
||||
await arrayData.applyFilter({ params: { ...newParams } });
|
||||
userParams.value = {};
|
||||
userParams.value = { ...newParams }; // Actualizar los params con los removibles
|
||||
await arrayData.applyFilter({ params: userParams.value });
|
||||
|
||||
if (!$props.showAll) {
|
||||
store.data = [];
|
||||
|
@ -185,13 +214,20 @@ function formatValue(value) {
|
|||
return `"${value}"`;
|
||||
}
|
||||
|
||||
const getLocale = (label) => {
|
||||
const param = label.split('.').at(-1);
|
||||
const globalLocale = `globals.params.${param}`;
|
||||
if (te(globalLocale)) return t(globalLocale);
|
||||
else if (te(t(`params.${param}`)));
|
||||
else return t(`${route.meta.moduleName.toLowerCase()}.params.${param}`);
|
||||
};
|
||||
function sanitizer(params) {
|
||||
for (const [key, value] of Object.entries(params)) {
|
||||
if (key === 'and' && Array.isArray(value)) {
|
||||
value.forEach((item) => {
|
||||
Object.assign(params, item);
|
||||
});
|
||||
delete params[key];
|
||||
} else if (value && typeof value === 'object') {
|
||||
const param = Object.values(value)[0];
|
||||
if (typeof param == 'string') params[key] = param.replaceAll('%', '');
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -202,11 +238,7 @@ const getLocale = (label) => {
|
|||
style="position: fixed; z-index: 1; right: 0; bottom: 0"
|
||||
icon="search"
|
||||
@click="search()"
|
||||
>
|
||||
<QTooltip bottom anchor="bottom right">
|
||||
{{ t('globals.search') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
></QBtn>
|
||||
<QForm @submit="search" id="filterPanelForm" @keyup.enter="search()">
|
||||
<QList dense>
|
||||
<QItem class="q-mt-xs">
|
||||
|
@ -245,12 +277,7 @@ const getLocale = (label) => {
|
|||
@remove="remove(chip.label)"
|
||||
data-cy="vnFilterPanelChip"
|
||||
>
|
||||
<slot
|
||||
name="tags"
|
||||
:tag="chip"
|
||||
:format-fn="formatValue"
|
||||
:get-locale="getLocale"
|
||||
>
|
||||
<slot name="tags" :tag="chip" :format-fn="formatValue">
|
||||
<div class="q-gutter-x-xs">
|
||||
<strong>{{ chip.label }}:</strong>
|
||||
<span>"{{ formatValue(chip.value) }}"</span>
|
||||
|
@ -263,7 +290,6 @@ const getLocale = (label) => {
|
|||
:params="userParams"
|
||||
:tags="customTags"
|
||||
:format-fn="formatValue"
|
||||
:get-locale="getLocale"
|
||||
:search-fn="search"
|
||||
/>
|
||||
</div>
|
||||
|
@ -271,13 +297,7 @@ const getLocale = (label) => {
|
|||
<QSeparator />
|
||||
</QList>
|
||||
<QList dense class="list q-gutter-y-sm q-mt-sm">
|
||||
<slot
|
||||
name="body"
|
||||
:get-locale="getLocale"
|
||||
:params="userParams"
|
||||
:orders="userOrders"
|
||||
:search-fn="search"
|
||||
></slot>
|
||||
<slot name="body" :params="sanitizer(userParams)" :search-fn="search"></slot>
|
||||
</QList>
|
||||
</QForm>
|
||||
<QInnerLoading
|
||||
|
|
|
@ -30,7 +30,7 @@ onBeforeMount(async () => {
|
|||
.data;
|
||||
if (!channel) channel = defaultChannel;
|
||||
|
||||
phone.value = await parsePhone(props.phoneNumber, props.country?.toLowerCase());
|
||||
phone.value = await parsePhone(props.phoneNumber, props.country.toLowerCase());
|
||||
config[
|
||||
type
|
||||
].url = `${url}?customerIdentity=%2B${phone.value}&channelId=${channel}`;
|
||||
|
|
|
@ -39,7 +39,7 @@ const val = computed(() => $props.value);
|
|||
<template v-else>
|
||||
<div v-if="label || $slots.label" class="label">
|
||||
<slot name="label">
|
||||
<span style="color: var(--vn-label-color)">{{ label }}</span>
|
||||
<span>{{ label }}</span>
|
||||
</slot>
|
||||
</div>
|
||||
<div class="value">
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
<template>
|
||||
<QBtn
|
||||
color="white"
|
||||
dense
|
||||
flat
|
||||
icon="more_vert"
|
||||
round
|
||||
size="md"
|
||||
data-cy="descriptor-more-opts"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ $t('components.cardDescriptor.moreOptions') }}
|
||||
</QTooltip>
|
||||
<QMenu ref="menuRef">
|
||||
<QList>
|
||||
<slot name="menu" :menu-ref="$refs.menuRef" />
|
||||
</QList>
|
||||
</QMenu>
|
||||
</QBtn>
|
||||
</template>
|
|
@ -110,7 +110,7 @@ onBeforeRouteLeave((to, from, next) => {
|
|||
:url="$props.url"
|
||||
order="created DESC"
|
||||
:limit="0"
|
||||
:user-filter="$props.filter"
|
||||
:filter="$props.filter"
|
||||
auto-load
|
||||
ref="vnPaginateRef"
|
||||
class="show"
|
||||
|
|
|
@ -74,10 +74,6 @@ const props = defineProps({
|
|||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
mapKey: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['onFetch', 'onPaginate', 'onChange']);
|
||||
|
@ -100,20 +96,15 @@ const arrayData = useArrayData(props.dataKey, {
|
|||
exprBuilder: props.exprBuilder,
|
||||
keepOpts: props.keepOpts,
|
||||
searchUrl: props.searchUrl,
|
||||
mapKey: props.mapKey,
|
||||
});
|
||||
const store = arrayData.store;
|
||||
|
||||
onMounted(async () => {
|
||||
if (props.autoLoad && !store.data?.length) await fetch();
|
||||
else emit('onFetch', store.data);
|
||||
mounted.value = true;
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (!store.keepData) arrayData.reset(['data']);
|
||||
arrayData.resetPagination();
|
||||
});
|
||||
onBeforeUnmount(() => arrayData.reset());
|
||||
|
||||
watch(
|
||||
() => props.data,
|
||||
|
@ -141,8 +132,8 @@ const addFilter = async (filter, params) => {
|
|||
|
||||
async function fetch(params) {
|
||||
useArrayData(props.dataKey, params);
|
||||
arrayData.resetPagination();
|
||||
await arrayData.fetch({ append: false });
|
||||
arrayData.reset(['filter.skip', 'skip', 'page']);
|
||||
await arrayData.fetch({ append: false, updateRouter: mounted.value });
|
||||
return emitStoreData();
|
||||
}
|
||||
|
||||
|
@ -204,20 +195,13 @@ async function onLoad(index, done) {
|
|||
done(isDone);
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
fetch,
|
||||
update,
|
||||
addFilter,
|
||||
paginate,
|
||||
userParams: arrayData.store.userParams,
|
||||
currentFilter: arrayData.store.currentFilter,
|
||||
});
|
||||
defineExpose({ fetch, update, addFilter, paginate });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="full-width">
|
||||
<div
|
||||
v-if="!store.data && !store.data?.length && !isLoading"
|
||||
v-if="!props.autoLoad && !store.data && !isLoading"
|
||||
class="info-row q-pa-md text-center"
|
||||
>
|
||||
<h5>
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
<script setup>
|
||||
import { onMounted, ref, computed, watch } from 'vue';
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useStateStore } from 'src/stores/useStateStore';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
const quasar = useQuasar();
|
||||
const { t } = useI18n();
|
||||
const state = useStateStore();
|
||||
const route = useRoute();
|
||||
|
||||
const props = defineProps({
|
||||
dataKey: {
|
||||
|
@ -53,6 +51,10 @@ const props = defineProps({
|
|||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
staticParams: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
exprBuilder: {
|
||||
type: Function,
|
||||
default: null,
|
||||
|
@ -65,10 +67,6 @@ const props = defineProps({
|
|||
type: Function,
|
||||
default: undefined,
|
||||
},
|
||||
searchRemoveParams: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
|
||||
const searchText = ref();
|
||||
|
@ -85,17 +83,6 @@ if (props.redirect)
|
|||
};
|
||||
let arrayData = useArrayData(props.dataKey, arrayDataProps);
|
||||
let store = arrayData.store;
|
||||
const to = computed(() => {
|
||||
const url = { path: route.path, query: { ...(route.query ?? {}) } };
|
||||
const searchUrl = arrayData.store.searchUrl;
|
||||
const currentFilter = {
|
||||
...arrayData.store.currentFilter,
|
||||
search: searchText.value || undefined,
|
||||
};
|
||||
|
||||
if (searchUrl) url.query[searchUrl] = JSON.stringify(currentFilter);
|
||||
return url;
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.dataKey,
|
||||
|
@ -113,21 +100,16 @@ onMounted(() => {
|
|||
});
|
||||
|
||||
async function search() {
|
||||
arrayData.resetPagination();
|
||||
const staticParams = Object.entries(store.userParams);
|
||||
arrayData.reset(['skip', 'page']);
|
||||
|
||||
let filter = { params: { search: searchText.value } };
|
||||
|
||||
if (!props.searchRemoveParams || !searchText.value) {
|
||||
filter = {
|
||||
params: {
|
||||
...store.userParams,
|
||||
search: searchText.value,
|
||||
},
|
||||
filter: store.filter,
|
||||
};
|
||||
} else {
|
||||
arrayData.reset(['currentFilter', 'userParams']);
|
||||
}
|
||||
const filter = {
|
||||
params: {
|
||||
...Object.fromEntries(staticParams),
|
||||
search: searchText.value,
|
||||
},
|
||||
...{ filter: props.filter },
|
||||
};
|
||||
|
||||
if (props.whereFilter) {
|
||||
filter.filter = {
|
||||
|
@ -136,38 +118,28 @@ async function search() {
|
|||
delete filter.params.search;
|
||||
}
|
||||
await arrayData.applyFilter(filter);
|
||||
searchText.value = undefined;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Teleport to="#searchbar" v-if="state.isHeaderMounted()">
|
||||
<QForm @submit="search" id="searchbarForm">
|
||||
<RouterLink
|
||||
:to="to"
|
||||
@click="
|
||||
!$event.shiftKey && !$event.ctrlKey && search();
|
||||
$refs.input.focus();
|
||||
"
|
||||
>
|
||||
<QIcon
|
||||
v-if="!quasar.platform.is.mobile"
|
||||
class="cursor-pointer"
|
||||
name="search"
|
||||
size="sm"
|
||||
>
|
||||
<QTooltip>{{ t('link') }}</QTooltip>
|
||||
</QIcon>
|
||||
</RouterLink>
|
||||
<VnInput
|
||||
id="searchbar"
|
||||
ref="input"
|
||||
v-model.trim="searchText"
|
||||
:placeholder="t(props.label)"
|
||||
dense
|
||||
standout
|
||||
autofocus
|
||||
data-cy="vn-searchbar"
|
||||
borderless
|
||||
data-cy="vnSearchBar"
|
||||
>
|
||||
<template #prepend>
|
||||
<QIcon
|
||||
v-if="!quasar.platform.is.mobile"
|
||||
class="cursor-pointer"
|
||||
name="search"
|
||||
@click="search"
|
||||
/>
|
||||
</template>
|
||||
<template #append>
|
||||
<QIcon
|
||||
v-if="props.info && $q.screen.gt.xs"
|
||||
|
@ -192,52 +164,20 @@ async function search() {
|
|||
.q-field {
|
||||
transition: width 0.36s;
|
||||
}
|
||||
</style>
|
||||
|
||||
:deep(.q-field__native) {
|
||||
padding-top: 10px;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
:deep(.q-field--dark .q-field__native:focus) {
|
||||
color: black;
|
||||
}
|
||||
|
||||
:deep(.q-field--focused) {
|
||||
.q-icon {
|
||||
color: black;
|
||||
}
|
||||
}
|
||||
|
||||
<style lang="scss">
|
||||
.cursor-info {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.q-form {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-radius: 4px;
|
||||
padding: 0 5px;
|
||||
background-color: var(--vn-search-color);
|
||||
|
||||
&:hover {
|
||||
background-color: var(--vn-search-color-hover);
|
||||
}
|
||||
&:focus-within {
|
||||
#searchbar {
|
||||
.q-field--standout.q-field--highlighted .q-field__control {
|
||||
background-color: white;
|
||||
|
||||
color: black;
|
||||
.q-field__native,
|
||||
.q-icon {
|
||||
color: black;
|
||||
color: black !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.q-icon {
|
||||
color: var(--vn-label-color);
|
||||
}
|
||||
</style>
|
||||
<i18n>
|
||||
en:
|
||||
link: click to search, ctrl + click to open in a new tab, shift + click to open in a new window
|
||||
es:
|
||||
link: clic para buscar, ctrl + clic para abrir en una nueva pestaña, shift + clic para abrir en una nueva ventana
|
||||
</i18n>
|
||||
|
|
|
@ -54,7 +54,6 @@ function formatNumber(number) {
|
|||
:offset="100"
|
||||
:limit="5"
|
||||
auto-load
|
||||
map-key="smsFk"
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
<QCard
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
import { vi, describe, expect, it, beforeAll, afterEach, beforeEach } from 'vitest';
|
||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import CardSummary from 'src/components/ui/CardSummary.vue';
|
||||
import * as vueRouter from 'vue-router';
|
||||
|
||||
describe('CardSummary', () => {
|
||||
let vm;
|
||||
let wrapper;
|
||||
|
||||
beforeAll(() => {
|
||||
vi.spyOn(axios, 'get').mockResolvedValue({ data: [] });
|
||||
});
|
||||
|
||||
vi.spyOn(vueRouter, 'useRoute').mockReturnValue({
|
||||
query: {},
|
||||
params: {},
|
||||
meta: { moduleName: 'mockName' },
|
||||
path: 'mockName/1/summary',
|
||||
name: 'CardSummary',
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = createWrapper(CardSummary, {
|
||||
propsData: {
|
||||
dataKey: 'cardSummaryKey',
|
||||
url: 'cardSummaryUrl',
|
||||
filter: 'cardFilter',
|
||||
},
|
||||
});
|
||||
vm = wrapper.vm;
|
||||
wrapper = wrapper.wrapper;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should fetch data correctly', async () => {
|
||||
const fetchSpy = vi
|
||||
.spyOn(vm.arrayData, 'fetch')
|
||||
.mockResolvedValue({ data: [{ id: 1, name: 'Test Entity' }] });
|
||||
await vm.fetch();
|
||||
|
||||
expect(fetchSpy).toHaveBeenCalledWith({ append: false, updateRouter: false });
|
||||
expect(wrapper.emitted('onFetch')).toBeTruthy();
|
||||
expect(vm.isLoading).toBe(false);
|
||||
});
|
||||
|
||||
it('should set correct props to the store', () => {
|
||||
expect(vm.store.url).toEqual('cardSummaryUrl');
|
||||
expect(vm.store.filter).toEqual('cardFilter');
|
||||
});
|
||||
|
||||
it('should compute entity correctly from store data', () => {
|
||||
vm.store.data = [{ id: 1, name: 'Entity 1' }];
|
||||
expect(vm.entity).toEqual({ id: 1, name: 'Entity 1' });
|
||||
});
|
||||
|
||||
it('should handle empty data gracefully', () => {
|
||||
vm.store.data = [];
|
||||
expect(vm.entity).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should respond to prop changes and refetch data', async () => {
|
||||
const newUrl = 'CardSummary/35';
|
||||
const newKey = 'cardSummaryKey/35';
|
||||
const fetchSpy = vi.spyOn(vm.arrayData, 'fetch');
|
||||
await wrapper.setProps({ url: newUrl, filter: { key: newKey } });
|
||||
|
||||
expect(fetchSpy).toHaveBeenCalled();
|
||||
expect(vm.store.url).toBe(newUrl);
|
||||
expect(vm.store.filter).toEqual({ key: newKey });
|
||||
});
|
||||
|
||||
it('should return true if route path ends with /summary' , () => {
|
||||
expect(vm.isSummary).toBe(true);
|
||||
});
|
||||
});
|
|
@ -1,81 +0,0 @@
|
|||
import { describe, expect, it } from 'vitest';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import FetchedTags from 'src/components/ui/FetchedTags.vue';
|
||||
|
||||
describe('tags computed property', () => {
|
||||
it('returns an object with the correct keys and values', () => {
|
||||
const vm = createWrapper(FetchedTags, {
|
||||
props: {
|
||||
item: {
|
||||
tag1: 'JavaScript',
|
||||
value1: 'Programming Language',
|
||||
tag2: 'Vue',
|
||||
value2: 'Framework',
|
||||
tag3: 'EmptyTag',
|
||||
},
|
||||
tag: 'tag',
|
||||
value: 'value',
|
||||
columns: 2,
|
||||
},
|
||||
}).vm;
|
||||
expect(vm.tags).toEqual({
|
||||
JavaScript: 'Programming Language',
|
||||
Vue: 'Framework',
|
||||
EmptyTag: '',
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an empty object if the item prop is an empty object', () => {
|
||||
const vm = createWrapper(FetchedTags, {
|
||||
props: {
|
||||
item: {},
|
||||
tag: 'tag',
|
||||
value: 'value',
|
||||
},
|
||||
}).vm;
|
||||
expect(vm.tags).toEqual({});
|
||||
});
|
||||
|
||||
it('should calculate the correct columnStyle when columns prop is defined', () => {
|
||||
const vm = createWrapper(FetchedTags, {
|
||||
props: {
|
||||
item: {
|
||||
tag1: 'JavaScript',
|
||||
value1: 'Programming Language',
|
||||
tag2: 'Vue',
|
||||
value2: 'Framework',
|
||||
tag3: 'EmptyTag',
|
||||
},
|
||||
tag: 'tag',
|
||||
value: 'value',
|
||||
columns: 2,
|
||||
},
|
||||
}).vm;
|
||||
|
||||
const expectedStyle = {
|
||||
'grid-template-columns': 'repeat(2, 1fr)',
|
||||
'max-width': '8rem',
|
||||
};
|
||||
|
||||
expect(vm.columnStyle).toEqual(expectedStyle);
|
||||
});
|
||||
|
||||
it('should return an empty object for columnStyle when columns prop is not defined', () => {
|
||||
const vm = createWrapper(FetchedTags, {
|
||||
props: {
|
||||
item: {
|
||||
tag1: 'JavaScript',
|
||||
value1: 'Programming Language',
|
||||
tag2: 'Vue',
|
||||
value2: 'Framework',
|
||||
tag3: 'EmptyTag',
|
||||
},
|
||||
tag: 'tag',
|
||||
value: 'value',
|
||||
columns: null,
|
||||
},
|
||||
}).vm;
|
||||
|
||||
expect(vm.columnStyle).toEqual({});
|
||||
});
|
||||
});
|
|
@ -1,89 +0,0 @@
|
|||
import { vi, describe, expect, it, beforeEach, afterEach } from 'vitest';
|
||||
import { createWrapper } from 'app/test/vitest/helper';
|
||||
import VnImg from 'src/components/ui/VnImg.vue';
|
||||
|
||||
let wrapper;
|
||||
let vm;
|
||||
const isEmployeeMock = vi.fn();
|
||||
|
||||
function generateWrapper(storage = 'images') {
|
||||
wrapper = createWrapper(VnImg, {
|
||||
props: {
|
||||
id: 123,
|
||||
zoomResolution: '400x400',
|
||||
storage,
|
||||
}
|
||||
});
|
||||
wrapper = wrapper.wrapper;
|
||||
vm = wrapper.vm;
|
||||
vm.timeStamp = 'timestamp';
|
||||
};
|
||||
|
||||
vi.mock('src/composables/useSession', () => ({
|
||||
useSession: () => ({
|
||||
getTokenMultimedia: () => 'token',
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock('src/composables/useRole', () => ({
|
||||
useRole: () => ({
|
||||
isEmployee: isEmployeeMock,
|
||||
}),
|
||||
}));
|
||||
|
||||
|
||||
describe('VnImg', () => {
|
||||
beforeEach(() => {
|
||||
isEmployeeMock.mockReset();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('getUrl', () => {
|
||||
it('should return /api/{storage}/{id}/downloadFile?access_token={token} when storage is dms', async () => {
|
||||
isEmployeeMock.mockReturnValue(false);
|
||||
generateWrapper('dms');
|
||||
await vm.$nextTick();
|
||||
const url = vm.getUrl();
|
||||
expect(url).toBe('/api/dms/123/downloadFile?access_token=token');
|
||||
});
|
||||
|
||||
it('should return /no-user.png when role is not employee and storage is not dms', async () => {
|
||||
isEmployeeMock.mockReturnValue(false);
|
||||
generateWrapper();
|
||||
await vm.$nextTick();
|
||||
const url = vm.getUrl();
|
||||
expect(url).toBe('/no-user.png');
|
||||
});
|
||||
|
||||
it('should return /api/{storage}/{collection}/{curResolution}/{id}/download?access_token={token}&{timeStamp} when zoom is false and role is employee and storage is not dms', async () => {
|
||||
isEmployeeMock.mockReturnValue(true);
|
||||
generateWrapper();
|
||||
await vm.$nextTick();
|
||||
const url = vm.getUrl();
|
||||
expect(url).toBe('/api/images/catalog/200x200/123/download?access_token=token×tamp');
|
||||
});
|
||||
|
||||
it('should return /api/{storage}/{collection}/{curResolution}/{id}/download?access_token={token}&{timeStamp} when zoom is true and role is employee and storage is not dms', async () => {
|
||||
isEmployeeMock.mockReturnValue(true);
|
||||
generateWrapper();
|
||||
await vm.$nextTick();
|
||||
const url = vm.getUrl(true);
|
||||
expect(url).toBe('/api/images/catalog/400x400/123/download?access_token=token×tamp');
|
||||
});
|
||||
});
|
||||
|
||||
describe('reload', () => {
|
||||
it('should update the timestamp', async () => {
|
||||
generateWrapper();
|
||||
const initialTimestamp = wrapper.vm.timeStamp;
|
||||
|
||||
wrapper.vm.reload();
|
||||
const newTimestamp = wrapper.vm.timeStamp;
|
||||
|
||||
expect(initialTimestamp).not.toEqual(newTimestamp);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,45 +0,0 @@
|
|||
import { describe, expect, it, vi } from 'vitest';
|
||||
import axios from 'axios';
|
||||
import { getExchange } from 'src/composables/getExchange';
|
||||
|
||||
vi.mock('axios');
|
||||
|
||||
describe('getExchange()', () => {
|
||||
it('should return the correct exchange rate', async () => {
|
||||
axios.get.mockResolvedValue({
|
||||
data: { value: 1.2 },
|
||||
});
|
||||
|
||||
const amount = 100;
|
||||
const currencyFk = 1;
|
||||
const dated = '2023-01-01';
|
||||
const result = await getExchange(amount, currencyFk, dated);
|
||||
|
||||
expect(result).toBe('83.33');
|
||||
});
|
||||
|
||||
it('should return the correct exchange rate with custom decimal places', async () => {
|
||||
axios.get.mockResolvedValue({
|
||||
data: { value: 1.2 },
|
||||
});
|
||||
|
||||
const amount = 100;
|
||||
const currencyFk = 1;
|
||||
const dated = '2023-01-01';
|
||||
const decimalPlaces = 3;
|
||||
const result = await getExchange(amount, currencyFk, dated, decimalPlaces);
|
||||
|
||||
expect(result).toBe('83.333');
|
||||
});
|
||||
|
||||
it('should return null if the API call fails', async () => {
|
||||
axios.get.mockRejectedValue(new Error('Network error'));
|
||||
|
||||
const amount = 100;
|
||||
const currencyFk = 1;
|
||||
const dated = '2023-01-01';
|
||||
const result = await getExchange(amount, currencyFk, dated);
|
||||
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
});
|
|
@ -1,55 +0,0 @@
|
|||
import { vi, describe, expect, it } from 'vitest';
|
||||
import { getTotal } from 'src/composables/getTotal';
|
||||
|
||||
vi.mock('src/filters', () => ({
|
||||
toCurrency: vi.fn((value, currency) => `${currency} ${value.toFixed(2)}`),
|
||||
}));
|
||||
|
||||
describe('getTotal()', () => {
|
||||
const rows = [
|
||||
{ amount: 10.5, tax: 2.1 },
|
||||
{ amount: 20.75, tax: 3.25 },
|
||||
{ amount: 30.25, tax: 4.75 },
|
||||
];
|
||||
|
||||
it('should calculate the total for a given key', () => {
|
||||
const total = getTotal(rows, 'amount');
|
||||
expect(total).toBe('61.50');
|
||||
});
|
||||
|
||||
it('should calculate the total with a callback function', () => {
|
||||
const total = getTotal(rows, null, { cb: (row) => row.amount + row.tax });
|
||||
expect(total).toBe('71.60');
|
||||
});
|
||||
|
||||
it('should format the total as currency', () => {
|
||||
const total = getTotal(rows, 'amount', { currency: 'USD' });
|
||||
expect(total).toBe('USD 61.50');
|
||||
});
|
||||
|
||||
it('should format the total as currency with default currency', () => {
|
||||
const total = getTotal(rows, 'amount', { currency: 'default' });
|
||||
expect(total).toBe('undefined 61.50');
|
||||
});
|
||||
|
||||
it('should calculate the total with integer formatting', () => {
|
||||
const total = getTotal(rows, 'amount', { decimalPlaces: 0 });
|
||||
expect(total).toBe('62');
|
||||
});
|
||||
|
||||
it('should calculate the total with custom decimal places', () => {
|
||||
const total = getTotal(rows, 'amount', { decimalPlaces: 1 });
|
||||
expect(total).toBe('61.5');
|
||||
});
|
||||
|
||||
it('should handle rows with missing keys', () => {
|
||||
const rowsWithMissingKeys = [{ amount: 10.5 }, { amount: 20.75 }, {}];
|
||||
const total = getTotal(rowsWithMissingKeys, 'amount');
|
||||
expect(total).toBe('31.25');
|
||||
});
|
||||
|
||||
it('should handle empty rows', () => {
|
||||
const total = getTotal([], 'amount');
|
||||
expect(total).toBe('0.00');
|
||||
});
|
||||
});
|
|
@ -1,9 +0,0 @@
|
|||
import { describe, expect, it } from 'vitest';
|
||||
import { useAccountShortToStandard } from 'src/composables/useAccountShortToStandard';
|
||||
|
||||
describe('useAccountShortToStandard()', () => {
|
||||
it('should pad the decimal part with zeros for short numbers', () => {
|
||||
expect(useAccountShortToStandard('123.45')).toBe('1230000045');
|
||||
expect(useAccountShortToStandard('123.')).toBe('1230000000');
|
||||
});
|
||||
});
|
|
@ -1,16 +0,0 @@
|
|||
import axios from 'axios';
|
||||
export async function getExchange(amount, currencyFk, dated, decimalPlaces = 2) {
|
||||
try {
|
||||
const { data } = await axios.get('ReferenceRates/findOne', {
|
||||
params: {
|
||||
filter: {
|
||||
fields: ['value'],
|
||||
where: { currencyFk, dated },
|
||||
},
|
||||
},
|
||||
});
|
||||
return (amount / data.value).toFixed(decimalPlaces);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
import { toCurrency } from 'src/filters';
|
||||
|
||||
export function getTotal(rows, key, opts = {}) {
|
||||
const { currency, cb, decimalPlaces } = opts;
|
||||
const { currency, cb } = opts;
|
||||
const total = rows.reduce((acc, row) => acc + +(cb ? cb(row) : row[key] || 0), 0);
|
||||
|
||||
return currency
|
||||
? toCurrency(total, currency == 'default' ? undefined : currency)
|
||||
: parseFloat(total).toFixed(decimalPlaces ?? 2);
|
||||
: total;
|
||||
}
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
export function useAccountShortToStandard(val) {
|
||||
if (!val || !/^\d+(\.\d*)$/.test(val)) return;
|
||||
return val?.replace('.', '0'.repeat(11 - val.length));
|
||||
}
|
|
@ -7,9 +7,7 @@ import { isDialogOpened } from 'src/filters';
|
|||
|
||||
const arrayDataStore = useArrayDataStore();
|
||||
|
||||
export function useArrayData(key, userOptions) {
|
||||
key ??= useRoute().meta.moduleName;
|
||||
|
||||
export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||
if (!key) throw new Error('ArrayData: A key is required to use this composable');
|
||||
|
||||
if (!arrayDataStore.get(key)) arrayDataStore.set(key);
|
||||
|
@ -27,17 +25,13 @@ export function useArrayData(key, userOptions) {
|
|||
const searchUrl = store.searchUrl;
|
||||
if (query[searchUrl]) {
|
||||
const params = JSON.parse(query[searchUrl]);
|
||||
const filter =
|
||||
params?.filter && typeof params?.filter == 'object'
|
||||
? params?.filter
|
||||
: JSON.parse(params?.filter ?? '{}');
|
||||
const filter = params?.filter && JSON.parse(params?.filter ?? '{}');
|
||||
delete params.filter;
|
||||
|
||||
store.userParams = params;
|
||||
store.filter = { ...filter, ...store.userFilter };
|
||||
store.userParams = { ...store.userParams, ...params };
|
||||
store.userFilter = { ...filter, ...store.userFilter };
|
||||
if (filter?.order) store.order = filter.order;
|
||||
}
|
||||
setCurrentFilter();
|
||||
});
|
||||
|
||||
if (key && userOptions) setOptions();
|
||||
|
@ -55,8 +49,6 @@ export function useArrayData(key, userOptions) {
|
|||
'exprBuilder',
|
||||
'searchUrl',
|
||||
'navigate',
|
||||
'mapKey',
|
||||
'keepData',
|
||||
];
|
||||
if (typeof userOptions === 'object') {
|
||||
for (const option in userOptions) {
|
||||
|
@ -68,7 +60,6 @@ export function useArrayData(key, userOptions) {
|
|||
store[option] = userOptions.keepOpts?.includes(option)
|
||||
? Object.assign(defaultOpts, store[option])
|
||||
: defaultOpts;
|
||||
if (option === 'userParams') store.defaultParams = store[option];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +70,31 @@ export function useArrayData(key, userOptions) {
|
|||
|
||||
cancelRequest();
|
||||
canceller = new AbortController();
|
||||
const { params, limit } = setCurrentFilter();
|
||||
|
||||
const filter = {
|
||||
limit: store.limit,
|
||||
};
|
||||
|
||||
let userParams = { ...store.userParams };
|
||||
|
||||
Object.assign(filter, store.userFilter);
|
||||
|
||||
let where;
|
||||
if (filter?.where || store.filter?.where)
|
||||
where = Object.assign(filter?.where ?? {}, store.filter?.where ?? {});
|
||||
Object.assign(filter, store.filter);
|
||||
filter.where = where;
|
||||
const params = { filter };
|
||||
|
||||
Object.assign(params, userParams);
|
||||
if (params.filter) params.filter.skip = store.skip;
|
||||
if (store?.order && typeof store?.order == 'string') store.order = [store.order];
|
||||
if (store.order?.length) params.filter.order = [...store.order];
|
||||
else delete params.filter.order;
|
||||
|
||||
store.currentFilter = JSON.parse(JSON.stringify(params));
|
||||
delete store.currentFilter.filter.include;
|
||||
store.currentFilter.filter = JSON.stringify(store.currentFilter.filter);
|
||||
|
||||
let exprFilter;
|
||||
if (store?.exprBuilder) {
|
||||
|
@ -101,16 +116,20 @@ export function useArrayData(key, userOptions) {
|
|||
params,
|
||||
});
|
||||
|
||||
const { limit } = filter;
|
||||
store.hasMoreData = limit && response.data.length >= limit;
|
||||
|
||||
if (!append && !isDialogOpened() && updateRouter) {
|
||||
if (updateStateParams(response.data)?.redirect && !store.keepData) return;
|
||||
if (append) {
|
||||
if (!store.data) store.data = [];
|
||||
for (const row of response.data) store.data.push(row);
|
||||
} else {
|
||||
store.data = response.data;
|
||||
if (!isDialogOpened()) updateRouter && updateStateParams();
|
||||
}
|
||||
|
||||
store.isLoading = false;
|
||||
|
||||
canceller = null;
|
||||
|
||||
processData(response.data, { map: !!store.mapKey, append });
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
@ -128,10 +147,6 @@ export function useArrayData(key, userOptions) {
|
|||
if (arrayDataStore.get(key)) arrayDataStore.reset(key, opts);
|
||||
}
|
||||
|
||||
function resetPagination() {
|
||||
if (arrayDataStore.get(key)) arrayDataStore.resetPagination(key);
|
||||
}
|
||||
|
||||
function cancelRequest() {
|
||||
if (canceller) {
|
||||
canceller.abort();
|
||||
|
@ -139,12 +154,12 @@ export function useArrayData(key, userOptions) {
|
|||
}
|
||||
}
|
||||
|
||||
async function applyFilter({ filter, params }, fetchOptions = {}) {
|
||||
async function applyFilter({ filter, params }) {
|
||||
if (filter) store.userFilter = filter;
|
||||
store.filter = {};
|
||||
if (params) store.userParams = { ...params };
|
||||
|
||||
const response = await fetch(fetchOptions);
|
||||
const response = await fetch({});
|
||||
return response;
|
||||
}
|
||||
|
||||
|
@ -155,7 +170,7 @@ export function useArrayData(key, userOptions) {
|
|||
userParams = sanitizerParams(userParams, store?.exprBuilder);
|
||||
|
||||
store.userParams = userParams;
|
||||
resetPagination();
|
||||
reset(['skip', 'filter.skip', 'page']);
|
||||
|
||||
await fetch({});
|
||||
return { filter, params };
|
||||
|
@ -182,7 +197,7 @@ export function useArrayData(key, userOptions) {
|
|||
}
|
||||
|
||||
store.order = order;
|
||||
resetPagination();
|
||||
reset(['skip', 'filter.skip', 'page']);
|
||||
fetch({});
|
||||
index++;
|
||||
|
||||
|
@ -240,7 +255,7 @@ export function useArrayData(key, userOptions) {
|
|||
if (Object.values(store.userParams).length) await fetch({});
|
||||
}
|
||||
|
||||
function updateStateParams(data) {
|
||||
function updateStateParams() {
|
||||
if (!route?.path) return;
|
||||
const newUrl = { path: route.path, query: { ...(route.query ?? {}) } };
|
||||
if (store?.searchUrl)
|
||||
|
@ -257,79 +272,22 @@ export function useArrayData(key, userOptions) {
|
|||
const { path } = matches.at(-1);
|
||||
|
||||
const to =
|
||||
data?.length === 1
|
||||
? path.replace(/\/(list|:id)|-list/, `/${data[0].id}`)
|
||||
store?.data?.length === 1
|
||||
? path.replace(/\/(list|:id)|-list/, `/${store.data[0].id}`)
|
||||
: path.replace(/:id.*/, '');
|
||||
|
||||
if (route.path != to) {
|
||||
const pushUrl = { path: to };
|
||||
if (to.endsWith('/list') || to.endsWith('/'))
|
||||
pushUrl.query = newUrl.query;
|
||||
return router.push(pushUrl) && { redirect: true };
|
||||
else destroy();
|
||||
return router.push(pushUrl);
|
||||
}
|
||||
}
|
||||
|
||||
router.replace(newUrl);
|
||||
}
|
||||
|
||||
function getCurrentFilter() {
|
||||
if (!Object.keys(store.userParams).length)
|
||||
store.userParams = store.defaultParams ?? {};
|
||||
|
||||
const filter = {
|
||||
limit: store.limit,
|
||||
...store.userFilter,
|
||||
};
|
||||
|
||||
let where;
|
||||
if (filter?.where || store.filter?.where)
|
||||
where = Object.assign(filter?.where ?? {}, store.filter?.where ?? {});
|
||||
Object.assign(filter, store.filter);
|
||||
filter.where = where;
|
||||
const params = { filter };
|
||||
|
||||
Object.assign(params, store.userParams);
|
||||
if (params.filter) params.filter.skip = store.skip;
|
||||
if (store?.order && typeof store?.order == 'string') store.order = [store.order];
|
||||
if (store.order?.length) params.filter.order = [...store.order];
|
||||
else delete params.filter.order;
|
||||
|
||||
return { filter, params, limit: filter.limit };
|
||||
}
|
||||
|
||||
function setCurrentFilter() {
|
||||
const { params, limit } = getCurrentFilter();
|
||||
store.currentFilter = JSON.parse(JSON.stringify(params));
|
||||
delete store.currentFilter.filter.include;
|
||||
store.currentFilter.filter = JSON.stringify(store.currentFilter.filter);
|
||||
return { params, limit };
|
||||
}
|
||||
|
||||
function processData(data, { map = true, append = true }) {
|
||||
if (!append) {
|
||||
store.data = [];
|
||||
store.map = new Map();
|
||||
}
|
||||
|
||||
if (!Array.isArray(data)) store.data = data;
|
||||
else if (!map && append) for (const row of data) store.data.push(row);
|
||||
else
|
||||
for (const row of data) {
|
||||
const key = row[store.mapKey];
|
||||
const val = { ...row, key };
|
||||
if (key && store.map.has(key)) {
|
||||
const { position } = store.map.get(key);
|
||||
val.position = position;
|
||||
store.map.set(key, val);
|
||||
store.data[position] = val;
|
||||
} else {
|
||||
val.position = store.map.size;
|
||||
store.map.set(key, val);
|
||||
store.data.push(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const totalRows = computed(() => (store.data && store.data.length) || 0);
|
||||
const isLoading = computed(() => store.isLoading || false);
|
||||
|
||||
|
@ -337,8 +295,6 @@ export function useArrayData(key, userOptions) {
|
|||
fetch,
|
||||
applyFilter,
|
||||
addFilter,
|
||||
getCurrentFilter,
|
||||
setCurrentFilter,
|
||||
addFilterWhere,
|
||||
addOrder,
|
||||
deleteOrder,
|
||||
|
@ -351,6 +307,5 @@ export function useArrayData(key, userOptions) {
|
|||
isLoading,
|
||||
deleteOption,
|
||||
reset,
|
||||
resetPagination,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { onBeforeMount, ref, watch } from 'vue';
|
||||
|
||||
export function useFilterParams(key) {
|
||||
if (!key) throw new Error('ArrayData: A key is required to use this composable');
|
||||
const params = ref({});
|
||||
const orders = ref({});
|
||||
const arrayData = ref({});
|
||||
|
||||
onBeforeMount(() => {
|
||||
arrayData.value = useArrayData(key);
|
||||
});
|
||||
|
||||
watch(
|
||||
() => arrayData.value.store?.currentFilter,
|
||||
(val, oldValue) => (val || oldValue) && setUserParams(val),
|
||||
{ immediate: true, deep: true }
|
||||
);
|
||||
|
||||
function parseOrder(urlOrders) {
|
||||
const orderObject = {};
|
||||
if (urlOrders) {
|
||||
if (typeof urlOrders == 'string') urlOrders = [urlOrders];
|
||||
for (const [index, orders] of urlOrders.entries()) {
|
||||
const [name, direction] = orders.split(' ');
|
||||
orderObject[name] = { direction, index: index + 1 };
|
||||
}
|
||||
}
|
||||
orders.value = orderObject;
|
||||
}
|
||||
|
||||
function setUserParams(watchedParams = {}) {
|
||||
if (Object.keys(watchedParams).length == 0) {
|
||||
params.value = {};
|
||||
orders.value = {};
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams);
|
||||
if (typeof watchedParams?.filter == 'string')
|
||||
watchedParams.filter = JSON.parse(watchedParams.filter);
|
||||
|
||||
watchedParams = { ...watchedParams, ...watchedParams.filter?.where };
|
||||
parseOrder(watchedParams.filter?.order);
|
||||
|
||||
delete watchedParams.filter;
|
||||
params.value = sanitizer(watchedParams);
|
||||
}
|
||||
|
||||
function sanitizer(params) {
|
||||
for (const [key, value] of Object.entries(params)) {
|
||||
if (key === 'and' && Array.isArray(value)) {
|
||||
value.forEach((item) => {
|
||||
Object.assign(params, item);
|
||||
});
|
||||
delete params[key];
|
||||
} else if (value && typeof value === 'object') {
|
||||
const param = Object.values(value)[0];
|
||||
if (typeof param == 'string') params[key] = param.replaceAll('%', '');
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
return {
|
||||
params,
|
||||
orders,
|
||||
};
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
import axios from 'axios';
|
||||
|
||||
export default async (id) => {
|
||||
const { data } = await axios.get(`Accounts/${id}/exists`);
|
||||
return data.exists;
|
||||
};
|
|
@ -1,24 +0,0 @@
|
|||
import { onMounted, ref } from 'vue';
|
||||
|
||||
export function useHasContent(selector) {
|
||||
const container = ref({});
|
||||
const hasContent = ref();
|
||||
|
||||
onMounted(() => {
|
||||
container.value = document.querySelector(selector);
|
||||
if (!container.value) return;
|
||||
|
||||
const observer = new MutationObserver(() => {
|
||||
if (document.querySelector(selector))
|
||||
hasContent.value = !!container.value.childNodes.length;
|
||||
});
|
||||
|
||||
observer.observe(container.value, {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
attributes: true,
|
||||
});
|
||||
});
|
||||
|
||||
return hasContent;
|
||||
}
|
|
@ -3,23 +3,19 @@
|
|||
@import '@quasar/quasar-ui-qcalendar/src/QCalendarMonth.sass';
|
||||
|
||||
body.body--light {
|
||||
--font-color: black;
|
||||
--vn-header-color: #cecece;
|
||||
--vn-page-color: #ffffff;
|
||||
--vn-section-color: #e0e0e0;
|
||||
--vn-section-hover-color: #b9b9b9;
|
||||
--vn-text-color: black;
|
||||
--vn-text-color: var(--font-color);
|
||||
--vn-label-color: #5f5f5f;
|
||||
--vn-accent-color: #e7e3e3;
|
||||
--vn-search-color: #d4d4d4;
|
||||
--vn-search-color-hover: #cfcfcf;
|
||||
--vn-empty-tag: #acacac;
|
||||
--vn-black-text-color: black;
|
||||
--vn-text-color-contrast: white;
|
||||
|
||||
background-color: var(--vn-page-color);
|
||||
|
||||
.q-header .q-toolbar {
|
||||
color: var(--vn-text-color);
|
||||
color: var(--font-color);
|
||||
}
|
||||
}
|
||||
body.body--dark {
|
||||
|
@ -30,11 +26,6 @@ body.body--dark {
|
|||
--vn-text-color: white;
|
||||
--vn-label-color: #a8a8a8;
|
||||
--vn-accent-color: #424242;
|
||||
--vn-search-color: #4b4b4b;
|
||||
--vn-search-color-hover: #5b5b5b;
|
||||
--vn-empty-tag: #2d2d2d;
|
||||
--vn-black-text-color: black;
|
||||
--vn-text-color-contrast: black;
|
||||
|
||||
background-color: var(--vn-page-color);
|
||||
}
|
||||
|
@ -93,10 +84,6 @@ select:-webkit-autofill {
|
|||
background-color: var(--vn-section-hover-color);
|
||||
}
|
||||
|
||||
.bg-vn-page {
|
||||
background-color: var(--vn-page-color);
|
||||
}
|
||||
|
||||
.color-vn-label {
|
||||
color: var(--vn-label-color);
|
||||
}
|
||||
|
@ -162,8 +149,7 @@ select:-webkit-autofill {
|
|||
.q-card,
|
||||
.q-table,
|
||||
.q-table__bottom,
|
||||
.q-drawer,
|
||||
.bottomButton {
|
||||
.q-drawer {
|
||||
background-color: var(--vn-section-color);
|
||||
}
|
||||
|
||||
|
@ -200,7 +186,7 @@ select:-webkit-autofill {
|
|||
|
||||
.q-tooltip {
|
||||
background-color: var(--vn-page-color);
|
||||
color: var(--vn-text-color);
|
||||
color: var(--font-color);
|
||||
font-size: medium;
|
||||
}
|
||||
|
||||
|
@ -254,7 +240,7 @@ input::-webkit-inner-spin-button {
|
|||
.q-table {
|
||||
th,
|
||||
td {
|
||||
padding: 1px 3px 1px 3px;
|
||||
padding: 1px 10px 1px 10px;
|
||||
max-width: 130px;
|
||||
div span {
|
||||
overflow: hidden;
|
||||
|
@ -278,10 +264,6 @@ input::-webkit-inner-spin-button {
|
|||
.shrink {
|
||||
max-width: 75px;
|
||||
}
|
||||
.number {
|
||||
text-align: right;
|
||||
width: 96px;
|
||||
}
|
||||
.expand {
|
||||
max-width: 400px;
|
||||
}
|
||||
|
@ -310,28 +292,3 @@ input::-webkit-inner-spin-button {
|
|||
.no-visible {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.q-item > .q-item__section:has(.q-checkbox) {
|
||||
max-width: min-content;
|
||||
}
|
||||
|
||||
.row > .column:has(.q-checkbox) {
|
||||
max-width: min-content;
|
||||
}
|
||||
.q-field__inner {
|
||||
.q-field__control {
|
||||
min-height: auto !important;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
padding-bottom: 2px;
|
||||
.q-field__native.row {
|
||||
min-height: auto !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.q-date__header-today {
|
||||
border-radius: 12px;
|
||||
border: 1px solid;
|
||||
box-shadow: 0 4px 6px #00000000;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import getUpdatedValues from './getUpdatedValues';
|
|||
import getParamWhere from './getParamWhere';
|
||||
import parsePhone from './parsePhone';
|
||||
import isDialogOpened from './isDialogOpened';
|
||||
import toCelsius from './toCelsius';
|
||||
|
||||
export {
|
||||
getUpdatedValues,
|
||||
|
@ -37,5 +36,4 @@ export {
|
|||
dashIfEmpty,
|
||||
dateRange,
|
||||
getParamWhere,
|
||||
toCelsius,
|
||||
};
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
export default function toCelsius(value) {
|
||||
return value ? `${value}°C` : '';
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
export default function toDateHourMin(date) {
|
||||
if (!date) return date;
|
||||
return new Date(date).toLocaleDateString('es-ES', {
|
||||
const dateHour = new Date(date).toLocaleDateString('es-ES', {
|
||||
timeZone: 'Europe/Madrid',
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
|
@ -8,4 +7,5 @@ export default function toDateHourMin(date) {
|
|||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
});
|
||||
return dateHour;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
export default function toDateHourMinSec(date) {
|
||||
if (!date) return date;
|
||||
return new Date(date).toLocaleDateString('es-ES', {
|
||||
const dateHour = new Date(date).toLocaleDateString('es-ES', {
|
||||
timeZone: 'Europe/Madrid',
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
|
@ -9,4 +8,5 @@ export default function toDateHourMinSec(date) {
|
|||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
});
|
||||
return dateHour;
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ globals:
|
|||
workCenters: Work centers
|
||||
modes: Modes
|
||||
zones: Zones
|
||||
zonesList: List
|
||||
zonesList: Zones
|
||||
deliveryDays: Delivery days
|
||||
upcomingDeliveries: Upcoming deliveries
|
||||
role: Role
|
||||
|
@ -333,24 +333,11 @@ globals:
|
|||
packing: ITP
|
||||
myTeam: My team
|
||||
departmentFk: Department
|
||||
from: From
|
||||
to: To
|
||||
supplierFk: Supplier
|
||||
supplierRef: Supplier ref
|
||||
serial: Serial
|
||||
amount: Importe
|
||||
awbCode: AWB
|
||||
correctedFk: Rectified
|
||||
correctingFk: Rectificative
|
||||
daysOnward: Days onward
|
||||
countryFk: Country
|
||||
companyFk: Company
|
||||
changePass: Change password
|
||||
setPass: Set password
|
||||
deleteConfirmTitle: Delete selected elements
|
||||
changeState: Change state
|
||||
raid: 'Raid {daysInForward} days'
|
||||
isVies: Vies
|
||||
errors:
|
||||
statusUnauthorized: Access denied
|
||||
statusInternalServerError: An internal server error has ocurred
|
||||
|
@ -389,19 +376,74 @@ cau:
|
|||
subtitle: By sending this ticket, all the data related to the error, the section, the user, etc., are already sent.
|
||||
inputLabel: Explain why this error should not appear
|
||||
askPrivileges: Ask for privileges
|
||||
entry:
|
||||
list:
|
||||
newEntry: New entry
|
||||
tableVisibleColumns:
|
||||
created: Creation
|
||||
supplierFk: Supplier
|
||||
isBooked: Booked
|
||||
isConfirmed: Confirmed
|
||||
isOrdered: Ordered
|
||||
companyFk: Company
|
||||
travelFk: Travel
|
||||
isExcludedFromAvailable: Inventory
|
||||
invoiceAmount: Import
|
||||
summary:
|
||||
commission: Commission
|
||||
currency: Currency
|
||||
invoiceNumber: Invoice number
|
||||
ordered: Ordered
|
||||
booked: Booked
|
||||
excludedFromAvailable: Inventory
|
||||
travelReference: Reference
|
||||
travelAgency: Agency
|
||||
travelShipped: Shipped
|
||||
travelDelivered: Delivered
|
||||
travelLanded: Landed
|
||||
travelReceived: Received
|
||||
buys: Buys
|
||||
stickers: Stickers
|
||||
package: Package
|
||||
packing: Pack.
|
||||
grouping: Group.
|
||||
buyingValue: Buying value
|
||||
import: Import
|
||||
pvp: PVP
|
||||
basicData:
|
||||
travel: Travel
|
||||
currency: Currency
|
||||
commission: Commission
|
||||
observation: Observation
|
||||
booked: Booked
|
||||
excludedFromAvailable: Inventory
|
||||
buys:
|
||||
observations: Observations
|
||||
packagingFk: Box
|
||||
color: Color
|
||||
printedStickers: Printed stickers
|
||||
notes:
|
||||
observationType: Observation type
|
||||
latestBuys:
|
||||
tableVisibleColumns:
|
||||
image: Picture
|
||||
itemFk: Item ID
|
||||
weightByPiece: Weight/Piece
|
||||
isActive: Active
|
||||
family: Family
|
||||
entryFk: Entry
|
||||
freightValue: Freight value
|
||||
comissionValue: Commission value
|
||||
packageValue: Package value
|
||||
isIgnored: Is ignored
|
||||
price2: Grouping
|
||||
price3: Packing
|
||||
minPrice: Min
|
||||
ektFk: Ekt
|
||||
packingOut: Package out
|
||||
landing: Landing
|
||||
isExcludedFromAvailable: Es inventory
|
||||
ticket:
|
||||
params:
|
||||
ticketFk: Ticket ID
|
||||
weekDay: Weekday
|
||||
agencyModeFk: Agency
|
||||
id: Worker
|
||||
state: State
|
||||
created: Created
|
||||
externalId: External ID
|
||||
counter: Counter
|
||||
freightItemName: Freight item name
|
||||
packageItemName: Package item name
|
||||
longName: Long name
|
||||
card:
|
||||
customerId: Customer ID
|
||||
customerCard: Customer card
|
||||
|
@ -452,7 +494,6 @@ invoiceOut:
|
|||
card:
|
||||
issued: Issued
|
||||
customerCard: Customer card
|
||||
ticketList: Ticket List
|
||||
summary:
|
||||
issued: Issued
|
||||
dued: Due
|
||||
|
@ -505,6 +546,27 @@ parking:
|
|||
searchBar:
|
||||
info: You can search by parking code
|
||||
label: Search parking...
|
||||
order:
|
||||
field:
|
||||
salesPersonFk: Sales Person
|
||||
form:
|
||||
clientFk: Client
|
||||
addressFk: Address
|
||||
agencyModeFk: Agency
|
||||
list:
|
||||
newOrder: New Order
|
||||
summary:
|
||||
basket: Basket
|
||||
notConfirmed: Not confirmed
|
||||
created: Created
|
||||
createdFrom: Created From
|
||||
address: Address
|
||||
total: Total
|
||||
items: Items
|
||||
orderTicketList: Order Ticket List
|
||||
amount: Amount
|
||||
confirm: Confirm
|
||||
confirmLines: Confirm lines
|
||||
department:
|
||||
chat: Chat
|
||||
bossDepartment: Boss Department
|
||||
|
@ -537,7 +599,7 @@ worker:
|
|||
fi: DNI/NIE/NIF
|
||||
birth: Birth
|
||||
isFreelance: Freelance
|
||||
isSsDiscounted: SS Bonification
|
||||
isSsDiscounted: Bonificación SS
|
||||
hasMachineryAuthorized: Machinery authorized
|
||||
isDisable: Disable
|
||||
notificationsManager:
|
||||
|
@ -623,11 +685,6 @@ wagon:
|
|||
minHeightBetweenTrays: 'The minimum height between trays is '
|
||||
maxWagonHeight: 'The maximum height of the wagon is '
|
||||
uncompleteTrays: There are incomplete trays
|
||||
params:
|
||||
label: Label
|
||||
plate: Plate
|
||||
volume: Volume
|
||||
name: Name
|
||||
|
||||
supplier:
|
||||
list:
|
||||
|
@ -674,6 +731,7 @@ supplier:
|
|||
sageTransactionTypeFk: Sage transaction type
|
||||
supplierActivityFk: Supplier activity
|
||||
isTrucker: Trucker
|
||||
isVies: Vies
|
||||
billingData:
|
||||
payMethodFk: Billing data
|
||||
payDemFk: Payment deadline
|
||||
|
@ -704,7 +762,6 @@ travel:
|
|||
totalEntries: Total entries
|
||||
totalEntriesTooltip: Total entries
|
||||
daysOnward: Landed days onwards
|
||||
awb: AWB
|
||||
summary:
|
||||
entryId: Entry Id
|
||||
freight: Freight
|
||||
|
@ -789,17 +846,13 @@ components:
|
|||
value: Value
|
||||
# ItemFixedPriceFilter
|
||||
buyerFk: Buyer
|
||||
warehouseFk: Warehouse
|
||||
started: From
|
||||
ended: To
|
||||
mine: For me
|
||||
hasMinPrice: Minimum price
|
||||
# LatestBuysFilter
|
||||
salesPersonFk: Buyer
|
||||
supplierFk: Supplier
|
||||
from: From
|
||||
to: To
|
||||
visible: Is visible
|
||||
active: Is active
|
||||
floramondo: Is floramondo
|
||||
showBadDates: Show future items
|
||||
|
|
|
@ -144,7 +144,7 @@ globals:
|
|||
workCenters: Centros de trabajo
|
||||
modes: Modos
|
||||
zones: Zonas
|
||||
zonesList: Listado
|
||||
zonesList: Zonas
|
||||
deliveryDays: Días de entrega
|
||||
upcomingDeliveries: Próximos repartos
|
||||
role: Role
|
||||
|
@ -336,23 +336,12 @@ globals:
|
|||
SSN: NSS
|
||||
fi: NIF
|
||||
myTeam: Mi equipo
|
||||
from: Desde
|
||||
to: Hasta
|
||||
supplierFk: Proveedor
|
||||
supplierRef: Ref. proveedor
|
||||
serial: Serie
|
||||
amount: Importe
|
||||
awbCode: AWB
|
||||
daysOnward: Días adelante
|
||||
packing: ITP
|
||||
countryFk: País
|
||||
companyFk: Empresa
|
||||
changePass: Cambiar contraseña
|
||||
setPass: Establecer contraseña
|
||||
deleteConfirmTitle: Eliminar los elementos seleccionados
|
||||
changeState: Cambiar estado
|
||||
raid: 'Redada {daysInForward} días'
|
||||
isVies: Vies
|
||||
errors:
|
||||
statusUnauthorized: Acceso denegado
|
||||
statusInternalServerError: Ha ocurrido un error interno del servidor
|
||||
|
@ -389,19 +378,75 @@ cau:
|
|||
subtitle: Al enviar este cau ya se envían todos los datos relacionados con el error, la sección, el usuario, etc
|
||||
inputLabel: Explique el motivo por el que no deberia aparecer este fallo
|
||||
askPrivileges: Solicitar permisos
|
||||
entry:
|
||||
list:
|
||||
newEntry: Nueva entrada
|
||||
tableVisibleColumns:
|
||||
created: Creación
|
||||
supplierFk: Proveedor
|
||||
isBooked: Asentado
|
||||
isConfirmed: Confirmado
|
||||
isOrdered: Pedida
|
||||
companyFk: Empresa
|
||||
travelFk: Envio
|
||||
isExcludedFromAvailable: Inventario
|
||||
invoiceAmount: Importe
|
||||
summary:
|
||||
commission: Comisión
|
||||
currency: Moneda
|
||||
invoiceNumber: Núm. factura
|
||||
ordered: Pedida
|
||||
booked: Contabilizada
|
||||
excludedFromAvailable: Inventario
|
||||
travelReference: Referencia
|
||||
travelAgency: Agencia
|
||||
travelShipped: F. envio
|
||||
travelWarehouseOut: Alm. salida
|
||||
travelDelivered: Enviada
|
||||
travelLanded: F. entrega
|
||||
travelReceived: Recibida
|
||||
buys: Compras
|
||||
stickers: Etiquetas
|
||||
package: Embalaje
|
||||
packing: Pack.
|
||||
grouping: Group.
|
||||
buyingValue: Coste
|
||||
import: Importe
|
||||
pvp: PVP
|
||||
basicData:
|
||||
travel: Envío
|
||||
currency: Moneda
|
||||
observation: Observación
|
||||
commission: Comisión
|
||||
booked: Asentado
|
||||
excludedFromAvailable: Inventario
|
||||
buys:
|
||||
observations: Observaciónes
|
||||
packagingFk: Embalaje
|
||||
color: Color
|
||||
printedStickers: Etiquetas impresas
|
||||
notes:
|
||||
observationType: Tipo de observación
|
||||
latestBuys:
|
||||
tableVisibleColumns:
|
||||
image: Foto
|
||||
itemFk: Id Artículo
|
||||
weightByPiece: Peso (gramos)/tallo
|
||||
isActive: Activo
|
||||
family: Familia
|
||||
entryFk: Entrada
|
||||
freightValue: Porte
|
||||
comissionValue: Comisión
|
||||
packageValue: Embalaje
|
||||
isIgnored: Ignorado
|
||||
price2: Grouping
|
||||
price3: Packing
|
||||
minPrice: Min
|
||||
ektFk: Ekt
|
||||
packingOut: Embalaje envíos
|
||||
landing: Llegada
|
||||
isExcludedFromAvailable: Es inventario
|
||||
ticket:
|
||||
params:
|
||||
ticketFk: ID de ticket
|
||||
weekDay: Salida
|
||||
agencyModeFk: Agencia
|
||||
id: Comercial
|
||||
created: Creado
|
||||
state: Estado
|
||||
externalId: ID externo
|
||||
counter: Contador
|
||||
freightItemName: Nombre
|
||||
packageItemName: Embalaje
|
||||
longName: Descripción
|
||||
card:
|
||||
customerId: ID cliente
|
||||
customerCard: Ficha del cliente
|
||||
|
@ -489,6 +534,30 @@ invoiceOut:
|
|||
comercial: Comercial
|
||||
errors:
|
||||
downloadCsvFailed: Error al descargar CSV
|
||||
order:
|
||||
field:
|
||||
salesPersonFk: Comercial
|
||||
form:
|
||||
clientFk: Cliente
|
||||
addressFk: Dirección
|
||||
agencyModeFk: Agencia
|
||||
list:
|
||||
newOrder: Nuevo Pedido
|
||||
summary:
|
||||
basket: Cesta
|
||||
notConfirmed: No confirmada
|
||||
created: Creado
|
||||
createdFrom: Creado desde
|
||||
address: Dirección
|
||||
total: Total
|
||||
vat: IVA
|
||||
state: Estado
|
||||
alias: Alias
|
||||
items: Artículos
|
||||
orderTicketList: Tickets del pedido
|
||||
amount: Monto
|
||||
confirm: Confirmar
|
||||
confirmLines: Confirmar lineas
|
||||
shelving:
|
||||
list:
|
||||
parking: Parking
|
||||
|
@ -529,15 +598,6 @@ worker:
|
|||
role: Rol
|
||||
sipExtension: Extensión
|
||||
locker: Taquilla
|
||||
fiDueDate: F. caducidad DNI
|
||||
sex: Sexo
|
||||
seniority: Antigüedad
|
||||
fi: DNI/NIE/NIF
|
||||
birth: F. nacimiento
|
||||
isFreelance: Autónomo
|
||||
isSsDiscounted: Bonificación SS
|
||||
hasMachineryAuthorized: Autorizado para maquinaria
|
||||
isDisable: Deshabilitado
|
||||
notificationsManager:
|
||||
activeNotifications: Notificaciones activas
|
||||
availableNotifications: Notificaciones disponibles
|
||||
|
@ -621,11 +681,6 @@ wagon:
|
|||
minHeightBetweenTrays: 'La distancia mínima entre bandejas es '
|
||||
maxWagonHeight: 'La altura máxima del vagón es '
|
||||
uncompleteTrays: Hay bandejas sin completar
|
||||
params:
|
||||
label: Etiqueta
|
||||
plate: Matrícula
|
||||
volume: Volumen
|
||||
name: Nombre
|
||||
supplier:
|
||||
list:
|
||||
payMethod: Método de pago
|
||||
|
@ -671,6 +726,7 @@ supplier:
|
|||
sageTransactionTypeFk: Tipo de transacción sage
|
||||
supplierActivityFk: Actividad proveedor
|
||||
isTrucker: Transportista
|
||||
isVies: Vies
|
||||
billingData:
|
||||
payMethodFk: Forma de pago
|
||||
payDemFk: Plazo de pago
|
||||
|
@ -700,7 +756,6 @@ travel:
|
|||
totalEntries: ∑
|
||||
totalEntriesTooltip: Entradas totales
|
||||
daysOnward: Días de llegada en adelante
|
||||
awb: AWB
|
||||
summary:
|
||||
entryId: Id entrada
|
||||
freight: Porte
|
||||
|
@ -785,19 +840,13 @@ components:
|
|||
value: Valor
|
||||
# ItemFixedPriceFilter
|
||||
buyerFk: Comprador
|
||||
warehouseFk: Almacen
|
||||
started: Desde
|
||||
ended: Hasta
|
||||
mine: Para mi
|
||||
hasMinPrice: Precio mínimo
|
||||
wareHouseFk: Almacén
|
||||
# LatestBuysFilter
|
||||
salesPersonFk: Comprador
|
||||
supplierFk: Proveedor
|
||||
visible: Visible
|
||||
active: Activo
|
||||
from: Desde
|
||||
to: Hasta
|
||||
floramondo: Floramondo
|
||||
showBadDates: Ver items a futuro
|
||||
userPanel:
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
import { Dark, Quasar } from 'quasar';
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { localeEquivalence } from 'src/i18n/index';
|
||||
import quasarLang from 'src/utils/quasarLang';
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
|
||||
|
@ -14,9 +12,18 @@ const userLocale = computed({
|
|||
set(value) {
|
||||
locale.value = value;
|
||||
|
||||
value = localeEquivalence[value] ?? value;
|
||||
if (value === 'en') value = 'en-GB';
|
||||
|
||||
quasarLang(value);
|
||||
// FIXME: Dynamic imports from absolute paths are not compatible with vite:
|
||||
// https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations
|
||||
try {
|
||||
const langList = import.meta.glob('../../node_modules/quasar/lang/*.mjs');
|
||||
langList[`../../node_modules/quasar/lang/${value}.mjs`]().then((lang) => {
|
||||
Quasar.lang.set(lang.default);
|
||||
});
|
||||
} catch (error) {
|
||||
//
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
<script setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ref, computed } from 'vue';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import axios from 'axios';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import { useQuasar } from 'quasar';
|
||||
|
||||
import VnTable from 'components/VnTable/VnTable.vue';
|
||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||
import FetchData from 'src/components/FetchData.vue';
|
||||
import { useValidator } from 'src/composables/useValidator';
|
||||
import VnSection from 'src/components/common/VnSection.vue';
|
||||
|
||||
defineProps({
|
||||
id: {
|
||||
|
@ -20,13 +21,13 @@ defineProps({
|
|||
|
||||
const { notify } = useNotify();
|
||||
const { t } = useI18n();
|
||||
const stateStore = useStateStore();
|
||||
const quasar = useQuasar();
|
||||
|
||||
const tableRef = ref();
|
||||
const roles = ref();
|
||||
const validationsStore = useValidator();
|
||||
const { models } = validationsStore;
|
||||
const dataKey = 'AccountAcls';
|
||||
const exprBuilder = (param, value) => {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
|
@ -133,40 +134,38 @@ const deleteAcl = async ({ id }) => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<VnSearchbar
|
||||
data-key="AccountAcls"
|
||||
url="ACLs"
|
||||
:expr-builder="exprBuilder"
|
||||
:label="t('acls.search')"
|
||||
:info="t('acls.searchInfo')"
|
||||
/>
|
||||
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
|
||||
</QDrawer>
|
||||
<FetchData
|
||||
url="VnRoles?fields=['name']"
|
||||
auto-load
|
||||
@on-fetch="(data) => (roles = data)"
|
||||
/>
|
||||
<VnSection
|
||||
:data-key="dataKey"
|
||||
:columns="columns"
|
||||
prefix="acls"
|
||||
:array-data-props="{
|
||||
url: 'ACLs',
|
||||
order: 'id DESC',
|
||||
exprBuilder,
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
data-key="AccountAcls"
|
||||
:url="`ACLs`"
|
||||
:create="{
|
||||
urlCreate: 'ACLs',
|
||||
title: 'Create ACL',
|
||||
onDataSaved: () => tableRef.reload(),
|
||||
formInitialData: {},
|
||||
}"
|
||||
>
|
||||
<template #body>
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
:data-key="dataKey"
|
||||
:create="{
|
||||
urlCreate: 'ACLs',
|
||||
title: 'Create ACL',
|
||||
onDataSaved: () => tableRef.reload(),
|
||||
formInitialData: {},
|
||||
}"
|
||||
:disable-option="{ card: true }"
|
||||
:columns="columns"
|
||||
default-mode="table"
|
||||
:right-search="false"
|
||||
:is-editable="true"
|
||||
:use-model="true"
|
||||
/>
|
||||
</template>
|
||||
</VnSection>
|
||||
order="id DESC"
|
||||
:disable-option="{ card: true }"
|
||||
:columns="columns"
|
||||
default-mode="table"
|
||||
:right-search="true"
|
||||
:is-editable="true"
|
||||
:use-model="true"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
|
|
|
@ -2,12 +2,21 @@
|
|||
import { useI18n } from 'vue-i18n';
|
||||
import { ref, computed } from 'vue';
|
||||
import VnTable from 'components/VnTable/VnTable.vue';
|
||||
import VnSection from 'src/components/common/VnSection.vue';
|
||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
|
||||
const tableRef = ref();
|
||||
const { t } = useI18n();
|
||||
const dataKey = 'AccountAliasList';
|
||||
const stateStore = useStateStore();
|
||||
|
||||
const exprBuilder = (param, value) => {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
? { id: value }
|
||||
: { alias: { like: `%${value}%` } };
|
||||
}
|
||||
};
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -31,45 +40,40 @@ const columns = computed(() => [
|
|||
create: true,
|
||||
},
|
||||
]);
|
||||
|
||||
const exprBuilder = (param, value) => {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
? { id: value }
|
||||
: { alias: { like: `%${value}%` } };
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnSection
|
||||
:data-key="dataKey"
|
||||
:columns="columns"
|
||||
prefix="mailAlias"
|
||||
:array-data-props="{ url: 'MailAliases', order: 'id DESC', exprBuilder }"
|
||||
>
|
||||
<template #body>
|
||||
<VnTable
|
||||
:data-key="dataKey"
|
||||
ref="tableRef"
|
||||
:create="{
|
||||
urlCreate: 'MailAliases',
|
||||
title: 'Create MailAlias',
|
||||
onDataSaved: ({ id }) => tableRef.redirect(id),
|
||||
formInitialData: {},
|
||||
}"
|
||||
:columns="columns"
|
||||
:disable-option="{ card: true }"
|
||||
default-mode="table"
|
||||
redirect="account/alias"
|
||||
:is-editable="true"
|
||||
:use-model="true"
|
||||
:right-search="false"
|
||||
<template v-if="stateStore.isHeaderMounted()">
|
||||
<Teleport to="#searchbar">
|
||||
<VnSearchbar
|
||||
data-key="AccountAliasList"
|
||||
url="MailAliases"
|
||||
:expr-builder="exprBuilder"
|
||||
:label="t('mailAlias.search')"
|
||||
:info="t('mailAlias.searchInfo')"
|
||||
/>
|
||||
</template>
|
||||
</VnSection>
|
||||
</Teleport>
|
||||
</template>
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
data-key="AccountAliasList"
|
||||
url="MailAliases"
|
||||
:create="{
|
||||
urlCreate: 'MailAliases',
|
||||
title: 'Create MailAlias',
|
||||
onDataSaved: ({ id }) => tableRef.redirect(id),
|
||||
formInitialData: {},
|
||||
}"
|
||||
order="id DESC"
|
||||
:columns="columns"
|
||||
:disable-option="{ card: true }"
|
||||
default-mode="table"
|
||||
redirect="account/alias"
|
||||
:is-editable="true"
|
||||
:use-model="true"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
Id: Id
|
||||
|
|
|
@ -6,7 +6,6 @@ import FormModelPopup from 'components/FormModelPopup.vue';
|
|||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnInputPassword from 'src/components/common/VnInputPassword.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
|
@ -62,10 +61,10 @@ const redirectToAccountBasicData = (_, { id }) => {
|
|||
hide-selected
|
||||
:rules="validate('VnUser.roleFk')"
|
||||
/>
|
||||
<VnInputPassword
|
||||
<VnInput
|
||||
v-model="data.password"
|
||||
:label="t('ldap.password')"
|
||||
:toggle-visibility="true"
|
||||
type="password"
|
||||
:rules="validate('VnUser.password')"
|
||||
/>
|
||||
<QCheckbox
|
||||
|
|
|
@ -8,7 +8,6 @@ import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
|||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import axios from 'axios';
|
||||
import VnInputPassword from 'src/components/common/VnInputPassword.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { notify } = useNotify();
|
||||
|
@ -129,9 +128,10 @@ onMounted(async () => await getInitialLdapConfig());
|
|||
:required="true"
|
||||
:rules="validate('LdapConfig.rdn')"
|
||||
/>
|
||||
<VnInputPassword
|
||||
<VnInput
|
||||
:label="t('ldap.password')"
|
||||
clearable
|
||||
type="password"
|
||||
v-model="data.password"
|
||||
:required="true"
|
||||
:rules="validate('LdapConfig.password')"
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
<script setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { computed, ref } from 'vue';
|
||||
import { ref, computed } from 'vue';
|
||||
import VnTable from 'components/VnTable/VnTable.vue';
|
||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||
import AccountSummary from './Card/AccountSummary.vue';
|
||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||
import VnSection from 'src/components/common/VnSection.vue';
|
||||
import FetchData from 'src/components/FetchData.vue';
|
||||
import VnInputPassword from 'src/components/common/VnInputPassword.vue';
|
||||
|
||||
import AccountFilter from './AccountFilter.vue';
|
||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
const { t } = useI18n();
|
||||
const { viewSummary } = useSummaryDialog();
|
||||
const tableRef = ref();
|
||||
const filter = {
|
||||
include: { relation: 'role', scope: { fields: ['id', 'name'] } },
|
||||
};
|
||||
const dataKey = 'AccountList';
|
||||
const roles = ref([]);
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -49,7 +48,7 @@ const columns = computed(() => [
|
|||
component: 'select',
|
||||
name: 'roleFk',
|
||||
attrs: {
|
||||
options: roles,
|
||||
url: 'VnRoles',
|
||||
optionValue: 'id',
|
||||
optionLabel: 'name',
|
||||
},
|
||||
|
@ -117,8 +116,7 @@ const columns = computed(() => [
|
|||
],
|
||||
},
|
||||
]);
|
||||
|
||||
function exprBuilder(param, value) {
|
||||
const exprBuilder = (param, value) => {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
|
@ -135,50 +133,52 @@ function exprBuilder(param, value) {
|
|||
case 'roleFk':
|
||||
return { [param]: value };
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<FetchData url="VnRoles" @on-fetch="(data) => (roles = data)" auto-load />
|
||||
<VnSection
|
||||
:data-key="dataKey"
|
||||
:columns="columns"
|
||||
prefix="account"
|
||||
:array-data-props="{
|
||||
url: 'VnUsers/preview',
|
||||
userFilter: filter,
|
||||
order: 'id DESC',
|
||||
exprBuilder,
|
||||
}"
|
||||
>
|
||||
<template #body>
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
:data-key="dataKey"
|
||||
:columns="columns"
|
||||
:create="{
|
||||
urlCreate: 'VnUsers',
|
||||
title: t('Create user'),
|
||||
onDataSaved: ({ id }) => $refs.tableRef.redirect(id),
|
||||
formInitialData: {},
|
||||
}"
|
||||
default-mode="table"
|
||||
redirect="account"
|
||||
:use-model="true"
|
||||
:right-search="false"
|
||||
>
|
||||
<template #more-create-dialog="{ data }">
|
||||
<QCardSection>
|
||||
<VnInputPassword
|
||||
:label="t('Password')"
|
||||
v-model="data.password"
|
||||
:required="true"
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
</QCardSection>
|
||||
</template>
|
||||
</VnTable>
|
||||
<VnSearchbar
|
||||
data-key="AccountList"
|
||||
:expr-builder="exprBuilder"
|
||||
:label="t('account.search')"
|
||||
:info="t('account.searchInfo')"
|
||||
:filter="filter"
|
||||
/>
|
||||
<RightMenu>
|
||||
<template #right-panel>
|
||||
<AccountFilter data-key="AccountList" />
|
||||
</template>
|
||||
</VnSection>
|
||||
</RightMenu>
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
data-key="AccountList"
|
||||
url="VnUsers/preview"
|
||||
:create="{
|
||||
urlCreate: 'VnUsers',
|
||||
title: t('Create user'),
|
||||
onDataSaved: ({ id }) => tableRef.redirect(id),
|
||||
formInitialData: {},
|
||||
}"
|
||||
:filter="filter"
|
||||
order="id DESC"
|
||||
:columns="columns"
|
||||
default-mode="table"
|
||||
redirect="account"
|
||||
:use-model="true"
|
||||
:right-search="false"
|
||||
auto-load
|
||||
>
|
||||
<template #more-create-dialog="{ data }">
|
||||
<QCardSection>
|
||||
<VnInput
|
||||
:label="t('Password')"
|
||||
v-model="data.password"
|
||||
type="password"
|
||||
:required="true"
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
</QCardSection>
|
||||
</template>
|
||||
</VnTable>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
|
|
|
@ -8,7 +8,6 @@ import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
|||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import axios from 'axios';
|
||||
import VnInputPassword from 'src/components/common/VnInputPassword.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { notify } = useNotify();
|
||||
|
@ -144,9 +143,10 @@ onMounted(async () => await getInitialSambaConfig());
|
|||
v-model="data.adUser"
|
||||
:rules="validate('SambaConfigs.adUser')"
|
||||
/>
|
||||
<VnInputPassword
|
||||
<VnInput
|
||||
:label="t('samba.passwordAD')"
|
||||
clearable
|
||||
type="password"
|
||||
v-model="data.adPassword"
|
||||
/>
|
||||
<VnInput
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<script setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
||||
import VnCard from 'components/common/VnCard.vue';
|
||||
import AliasDescriptor from './AliasDescriptor.vue';
|
||||
const { t } = useI18n();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnCardBeta
|
||||
<VnCard
|
||||
data-key="Alias"
|
||||
base-url="MailAliases"
|
||||
:descriptor="AliasDescriptor"
|
||||
|
|
|
@ -1,8 +1,20 @@
|
|||
<script setup>
|
||||
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import VnCard from 'components/common/VnCard.vue';
|
||||
import AccountDescriptor from './AccountDescriptor.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnCardBeta data-key="AccountId" :descriptor="AccountDescriptor" />
|
||||
<VnCard
|
||||
data-key="Account"
|
||||
:descriptor="AccountDescriptor"
|
||||
search-data-key="AccountList"
|
||||
:searchbar-props="{
|
||||
url: 'VnUsers/preview',
|
||||
label: t('account.search'),
|
||||
info: t('account.searchInfo'),
|
||||
}"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { ref, computed } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import CardDescriptor from 'components/ui/CardDescriptor.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
import useCardDescription from 'src/composables/useCardDescription';
|
||||
import AccountDescriptorMenu from './AccountDescriptorMenu.vue';
|
||||
import FetchData from 'src/components/FetchData.vue';
|
||||
import VnImg from 'src/components/ui/VnImg.vue';
|
||||
import useHasAccount from 'src/composables/useHasAccount.js';
|
||||
|
||||
const $props = defineProps({
|
||||
id: {
|
||||
|
@ -23,7 +23,6 @@ const entityId = computed(() => {
|
|||
return $props.id || route.params.id;
|
||||
});
|
||||
const data = ref(useCardDescription());
|
||||
const hasAccount = ref();
|
||||
const setData = (entity) => (data.value = useCardDescription(entity.nickname, entity.id));
|
||||
|
||||
const filter = {
|
||||
|
@ -31,13 +30,15 @@ const filter = {
|
|||
fields: ['id', 'nickname', 'name', 'role'],
|
||||
include: { relation: 'role', scope: { fields: ['id', 'name'] } },
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
hasAccount.value = await useHasAccount(entityId.value);
|
||||
});
|
||||
const hasAccount = ref(false);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
:url="`Accounts/${entityId}/exists`"
|
||||
auto-load
|
||||
@on-fetch="(data) => (hasAccount = data.exists)"
|
||||
/>
|
||||
<CardDescriptor
|
||||
ref="descriptor"
|
||||
:url="`VnUsers/preview`"
|
||||
|
@ -49,9 +50,10 @@ onMounted(async () => {
|
|||
:subtitle="data.subtitle"
|
||||
>
|
||||
<template #menu>
|
||||
<AccountDescriptorMenu :entity-id="entityId" />
|
||||
<AccountDescriptorMenu :has-account="hasAccount" />
|
||||
</template>
|
||||
<template #before>
|
||||
<!-- falla id :id="entityId.value" collection="user" size="160x160" -->
|
||||
<VnImg :id="entityId" collection="user" resolution="520x520" class="photo">
|
||||
<template #error>
|
||||
<div
|
||||
|
@ -89,7 +91,7 @@ onMounted(async () => {
|
|||
<QIcon
|
||||
color="primary"
|
||||
name="contact_mail"
|
||||
v-if="hasAccount"
|
||||
v-if="entity.hasAccount"
|
||||
flat
|
||||
round
|
||||
size="sm"
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
<script setup>
|
||||
import axios from 'axios';
|
||||
import { computed, onMounted, ref, toRefs } from 'vue';
|
||||
import { computed, ref, toRefs } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useAcl } from 'src/composables/useAcl';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { useState } from 'src/composables/useState';
|
||||
import VnConfirm from 'src/components/ui/VnConfirm.vue';
|
||||
import VnInputPassword from 'src/components/common/VnInputPassword.vue';
|
||||
import VnChangePassword from 'src/components/common/VnChangePassword.vue';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
const $props = defineProps({
|
||||
hasAccount: {
|
||||
|
@ -20,20 +17,14 @@ const $props = defineProps({
|
|||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
const { hasAccount } = toRefs($props);
|
||||
const { openConfirmationModal } = useVnConfirm();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const state = useState();
|
||||
const user = state.getUser();
|
||||
const { notify } = useQuasar();
|
||||
const account = computed(() => useArrayData('AccountId').store.data[0]);
|
||||
account.value.hasAccount = hasAccount.value;
|
||||
const entityId = computed(() => +route.params.id);
|
||||
const hasitManagementAccess = ref();
|
||||
const hasSysadminAccess = ref();
|
||||
|
||||
async function updateStatusAccount(active) {
|
||||
if (active) {
|
||||
|
@ -45,7 +36,7 @@ async function updateStatusAccount(active) {
|
|||
account.value.hasAccount = active;
|
||||
const status = active ? 'enable' : 'disable';
|
||||
notify({
|
||||
message: t(`account.card.actions.${status}Account.success`),
|
||||
message: t(`account.card.${status}Account.success`),
|
||||
type: 'positive',
|
||||
});
|
||||
}
|
||||
|
@ -58,17 +49,6 @@ async function updateStatusUser(active) {
|
|||
type: 'positive',
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteAccount() {
|
||||
const { data } = await axios.delete(`VnUsers/${entityId.value}`);
|
||||
if (data) {
|
||||
notify({
|
||||
message: t('account.card.actions.delete.success'),
|
||||
type: 'positive',
|
||||
});
|
||||
router.push({ name: 'AccountList' });
|
||||
}
|
||||
}
|
||||
const showSyncDialog = ref(false);
|
||||
const syncPassword = ref(null);
|
||||
const shouldSyncPassword = ref(false);
|
||||
|
@ -83,27 +63,11 @@ async function sync() {
|
|||
type: 'positive',
|
||||
});
|
||||
}
|
||||
const askOldPass = ref(false);
|
||||
const changePassRef = ref();
|
||||
|
||||
const onChangePass = (oldPass) => {
|
||||
askOldPass.value = oldPass;
|
||||
changePassRef.value.show();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
hasitManagementAccess.value = useAcl().hasAny([
|
||||
{ model: 'VnUser', props: 'higherPrivileges', accessType: 'WRITE' },
|
||||
]);
|
||||
hasSysadminAccess.value = useAcl().hasAny([
|
||||
{ model: 'VnUser', props: 'adminUser', accessType: 'WRITE' },
|
||||
]);
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<VnChangePassword
|
||||
ref="changePassRef"
|
||||
:ask-old-pass="askOldPass"
|
||||
:ask-old-pass="true"
|
||||
:submit-fn="
|
||||
async (newPassword, oldPassword) => {
|
||||
await axios.patch(`Accounts/change-password`, {
|
||||
|
@ -133,7 +97,7 @@ onMounted(() => {
|
|||
<QTooltip>{{ t('account.card.actions.sync.tooltip') }}</QTooltip>
|
||||
</QIcon></QCheckbox
|
||||
>
|
||||
<VnInputPassword
|
||||
<QInput
|
||||
v-if="shouldSyncPassword"
|
||||
:label="t('login.password')"
|
||||
v-model="syncPassword"
|
||||
|
@ -145,46 +109,18 @@ onMounted(() => {
|
|||
</template>
|
||||
</VnConfirm>
|
||||
<QItem
|
||||
v-if="hasitManagementAccess"
|
||||
v-ripple
|
||||
clickable
|
||||
@click="
|
||||
openConfirmationModal(
|
||||
t('account.card.actions.disableAccount.title'),
|
||||
t('account.card.actions.disableAccount.subtitle'),
|
||||
() => deleteAccount()
|
||||
)
|
||||
v-if="
|
||||
entityId == account.id &&
|
||||
useAcl().hasAny([{ model: 'Account', props: '*', accessType: 'WRITE' }])
|
||||
"
|
||||
>
|
||||
<QItemSection>{{ t('globals.delete') }}</QItemSection>
|
||||
</QItem>
|
||||
<QItem
|
||||
v-if="hasSysadminAccess"
|
||||
v-ripple
|
||||
clickable
|
||||
@click="user.id === account.id ? onChangePass(true) : onChangePass(false)"
|
||||
@click="$refs.changePassRef.show()"
|
||||
>
|
||||
<QItemSection v-if="user.id === account.id">
|
||||
{{ t('globals.changePass') }}
|
||||
</QItemSection>
|
||||
<QItemSection v-else>{{ t('globals.setPass') }}</QItemSection>
|
||||
<QItemSection>{{ t('globals.changePass') }}</QItemSection>
|
||||
</QItem>
|
||||
<QItem
|
||||
v-if="!account.hasAccount && hasSysadminAccess"
|
||||
v-ripple
|
||||
clickable
|
||||
@click="
|
||||
openConfirmationModal(
|
||||
t('account.card.actions.enableAccount.title'),
|
||||
t('account.card.actions.enableAccount.subtitle'),
|
||||
() => updateStatusAccount(true)
|
||||
)
|
||||
"
|
||||
>
|
||||
<QItemSection>{{ t('account.card.actions.enableAccount.name') }}</QItemSection>
|
||||
</QItem>
|
||||
<QItem
|
||||
v-if="account.hasAccount && hasSysadminAccess"
|
||||
v-if="account.hasAccount"
|
||||
v-ripple
|
||||
clickable
|
||||
@click="
|
||||
|
@ -199,7 +135,7 @@ onMounted(() => {
|
|||
</QItem>
|
||||
|
||||
<QItem
|
||||
v-if="!account.active && hasitManagementAccess"
|
||||
v-if="!account.active"
|
||||
v-ripple
|
||||
clickable
|
||||
@click="
|
||||
|
@ -213,7 +149,7 @@ onMounted(() => {
|
|||
<QItemSection>{{ t('account.card.actions.activateUser.name') }}</QItemSection>
|
||||
</QItem>
|
||||
<QItem
|
||||
v-if="account.active && hasitManagementAccess"
|
||||
v-if="account.active"
|
||||
v-ripple
|
||||
clickable
|
||||
@click="
|
||||
|
@ -226,12 +162,7 @@ onMounted(() => {
|
|||
>
|
||||
<QItemSection>{{ t('account.card.actions.deactivateUser.name') }}</QItemSection>
|
||||
</QItem>
|
||||
<QItem
|
||||
v-if="useAcl().hasAny([{ model: 'VnRole', props: '*', accessType: 'WRITE' }])"
|
||||
v-ripple
|
||||
clickable
|
||||
@click="showSyncDialog = true"
|
||||
>
|
||||
<QItem v-ripple clickable @click="showSyncDialog = true">
|
||||
<QItemSection>{{ t('account.card.actions.sync.name') }}</QItemSection>
|
||||
</QItem>
|
||||
<QSeparator />
|
||||
|
|
|
@ -9,7 +9,6 @@ import AccountMailAliasCreateForm from './AccountMailAliasCreateForm.vue';
|
|||
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import useHasAccount from 'src/composables/useHasAccount.js';
|
||||
import axios from 'axios';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
@ -51,6 +50,16 @@ const columns = computed(() => [
|
|||
},
|
||||
]);
|
||||
|
||||
const fetchAccountExistence = async () => {
|
||||
try {
|
||||
const { data } = await axios.get(`Accounts/${route.params.id}/exists`);
|
||||
return data.exists;
|
||||
} catch (error) {
|
||||
console.error('Error fetching account existence', error);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const deleteMailAlias = async (row) => {
|
||||
await axios.delete(`${urlPath}/${row.id}`);
|
||||
fetchMailAliases();
|
||||
|
@ -70,7 +79,7 @@ const fetchMailAliases = async () => {
|
|||
|
||||
const getAccountData = async (reload = true) => {
|
||||
loading.value = true;
|
||||
hasAccount.value = await useHasAccount(route.params.id);
|
||||
hasAccount.value = await fetchAccountExistence();
|
||||
if (!hasAccount.value) {
|
||||
loading.value = false;
|
||||
store.data = [];
|
||||
|
|
|
@ -9,7 +9,6 @@ import VnRow from 'components/ui/VnRow.vue';
|
|||
import axios from 'axios';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import useHasAccount from 'src/composables/useHasAccount';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
@ -31,9 +30,23 @@ const hasDataChanged = computed(
|
|||
initialData.value.hasData !== hasData.value
|
||||
);
|
||||
|
||||
const fetchAccountExistence = async () => {
|
||||
try {
|
||||
const { data } = await axios.get(`Accounts/${route.params.id}/exists`);
|
||||
return data.exists;
|
||||
} catch (error) {
|
||||
console.error('Error fetching account existence', error);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const fetchMailForwards = async () => {
|
||||
const response = await axios.get(`MailForwards/${route.params.id}`);
|
||||
return response.data;
|
||||
try {
|
||||
const response = await axios.get(`MailForwards/${route.params.id}`);
|
||||
return response.data;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const deleteMailForward = async () => {
|
||||
|
@ -59,7 +72,7 @@ const setInitialData = async () => {
|
|||
loading.value = true;
|
||||
initialData.value.account = route.params.id;
|
||||
formData.value.account = route.params.id;
|
||||
hasAccount.value = await useHasAccount(route.params.id);
|
||||
hasAccount.value = await fetchAccountExistence(route.params.id);
|
||||
if (!hasAccount.value) {
|
||||
loading.value = false;
|
||||
return;
|
||||
|
|
|
@ -7,7 +7,6 @@ import CardSummary from 'components/ui/CardSummary.vue';
|
|||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import AccountDescriptorMenu from './AccountDescriptorMenu.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
|
@ -31,15 +30,13 @@ const filter = {
|
|||
|
||||
<template>
|
||||
<CardSummary
|
||||
data-key="AccountId"
|
||||
data-key="AccountSummary"
|
||||
ref="AccountSummary"
|
||||
url="VnUsers/preview"
|
||||
:filter="filter"
|
||||
@on-fetch="(data) => (account = data)"
|
||||
>
|
||||
<template #header>{{ account.id }} - {{ account.nickname }}</template>
|
||||
<template #menu="">
|
||||
<AccountDescriptorMenu :entity-id="entityId" />
|
||||
</template>
|
||||
<template #body>
|
||||
<QCard class="vn-one">
|
||||
<QCardSection class="q-pa-none">
|
||||
|
|
|
@ -3,13 +3,11 @@ import { useI18n } from 'vue-i18n';
|
|||
import { computed, ref } from 'vue';
|
||||
import VnTable from 'components/VnTable/VnTable.vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||
import RoleSummary from './Card/RoleSummary.vue';
|
||||
import VnSection from 'src/components/common/VnSection.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
const { viewSummary } = useSummaryDialog();
|
||||
const $props = defineProps({
|
||||
id: {
|
||||
type: Number,
|
||||
|
@ -17,10 +15,8 @@ const $props = defineProps({
|
|||
},
|
||||
});
|
||||
const tableRef = ref();
|
||||
const url = 'VnRoles';
|
||||
const dataKey = 'AccountRoleList';
|
||||
|
||||
const entityId = computed(() => $props.id || route.params.id);
|
||||
const { viewSummary } = useSummaryDialog();
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -85,32 +81,30 @@ const exprBuilder = (param, value) => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<VnSection
|
||||
:data-key="dataKey"
|
||||
<VnSearchbar
|
||||
data-key="AccountRolesList"
|
||||
:expr-builder="exprBuilder"
|
||||
:label="t('role.searchRoles')"
|
||||
:info="t('role.searchInfo')"
|
||||
/>
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
data-key="AccountRolesList"
|
||||
:url="`VnRoles`"
|
||||
:create="{
|
||||
urlCreate: 'VnRoles',
|
||||
title: t('Create rol'),
|
||||
onDataSaved: ({ id }) => tableRef.redirect(id),
|
||||
formInitialData: {
|
||||
editorFk: entityId,
|
||||
},
|
||||
}"
|
||||
order="id ASC"
|
||||
:disable-option="{ card: true }"
|
||||
:columns="columns"
|
||||
prefix="role"
|
||||
:array-data-props="{ url, exprBuilder, order: 'id ASC' }"
|
||||
>
|
||||
<template #body>
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
:data-key="dataKey"
|
||||
:create="{
|
||||
urlCreate: 'VnRoles',
|
||||
title: t('Create rol'),
|
||||
onDataSaved: ({ id }) => tableRef.redirect(id),
|
||||
formInitialData: {
|
||||
editorFk: entityId,
|
||||
},
|
||||
}"
|
||||
:disable-option="{ card: true }"
|
||||
:columns="columns"
|
||||
default-mode="table"
|
||||
redirect="account/role"
|
||||
:right-search="false"
|
||||
/>
|
||||
</template>
|
||||
</VnSection>
|
||||
default-mode="table"
|
||||
redirect="account/role"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
|
|
|
@ -1,7 +1,20 @@
|
|||
<script setup>
|
||||
import VnCardBeta from 'components/common/VnCardBeta.vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import VnCard from 'components/common/VnCard.vue';
|
||||
import RoleDescriptor from './RoleDescriptor.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
</script>
|
||||
<template>
|
||||
<VnCardBeta data-key="Role" :descriptor="RoleDescriptor" />
|
||||
<VnCard
|
||||
data-key="Role"
|
||||
:descriptor="RoleDescriptor"
|
||||
search-data-key="AccountRolesList"
|
||||
:searchbar-props="{
|
||||
url: 'VnRoles',
|
||||
label: t('role.searchRoles'),
|
||||
info: t('role.searchInfo'),
|
||||
searchUrl: 'table',
|
||||
}"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -43,14 +43,14 @@ const removeRole = async () => {
|
|||
:filter="filter"
|
||||
module="Role"
|
||||
@on-fetch="setData"
|
||||
data-key="Role"
|
||||
data-key="accountData"
|
||||
:title="data.title"
|
||||
:subtitle="data.subtitle"
|
||||
:summary="$props.summary"
|
||||
>
|
||||
<template #menu>
|
||||
<QItem v-ripple clickable @click="removeRole()">
|
||||
<QItemSection>{{ t('globals.delete') }}</QItemSection>
|
||||
<QItemSection>{{ t('Delete') }}</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
<template #body="{ entity }">
|
||||
|
|
|
@ -27,10 +27,10 @@ const filter = {
|
|||
<template>
|
||||
<CardSummary
|
||||
ref="summary"
|
||||
:url="`VnRoles/${entityId}`"
|
||||
:url="`VnRoles`"
|
||||
:filter="filter"
|
||||
@on-fetch="(data) => (role = data)"
|
||||
data-key="Role"
|
||||
data-key="RoleSummary"
|
||||
>
|
||||
<template #header> {{ role.id }} - {{ role.name }} </template>
|
||||
<template #body>
|
||||
|
|
|
@ -1,18 +1,4 @@
|
|||
account:
|
||||
params:
|
||||
id: Id
|
||||
name: Name
|
||||
roleFk: Role
|
||||
nickname: Nickname
|
||||
password: Password
|
||||
active: Active
|
||||
search: Id
|
||||
description: Description
|
||||
alias: Alias
|
||||
model: Model
|
||||
principalId: Role
|
||||
property: Property
|
||||
accessType: Access
|
||||
card:
|
||||
nickname: User
|
||||
role: Role
|
||||
|
@ -80,7 +66,7 @@ account:
|
|||
mailInputInfo: All emails will be forwarded to the specified address.
|
||||
role:
|
||||
newRole: New role
|
||||
search: Search role
|
||||
searchRoles: Search role
|
||||
searchInfo: Search role by id or name
|
||||
description: Description
|
||||
id: Id
|
||||
|
|
|
@ -1,20 +1,4 @@
|
|||
accessType: Acceso
|
||||
property: Propiedad
|
||||
account:
|
||||
params:
|
||||
id: Id
|
||||
name: Nombre
|
||||
roleFk: Rol
|
||||
nickname: Nickname
|
||||
password: Contraseña
|
||||
active: Activo
|
||||
search: Id
|
||||
description: Descripción
|
||||
alias: Alias
|
||||
model: Modelo
|
||||
principalId: Rol
|
||||
property: Propiedad
|
||||
accessType: Acceso
|
||||
card:
|
||||
nickname: Usuario
|
||||
role: Rol
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue