Merge branch 'dev' into warmFix_customerDescriptorActions
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Javier Segarra 2024-11-14 12:22:33 +00:00
commit 61cd8c49c6
16 changed files with 65 additions and 82 deletions

View File

@ -4,8 +4,9 @@ import { Router } from 'src/router';
import useNotify from 'src/composables/useNotify.js';
import { useStateQueryStore } from 'src/stores/useStateQueryStore';
let session, notify, stateQuery;
const session = useSession();
const { notify } = useNotify();
const stateQuery = useStateQueryStore();
const baseUrl = '/api/';
axios.defaults.baseURL = baseUrl;
@ -50,15 +51,9 @@ const onResponseError = (error) => {
return Promise.reject(error);
};
export function setupAxios() {
session = useSession();
notify = useNotify().notify;
stateQuery = useStateQueryStore();
axios.interceptors.request.use(onRequest, onRequestError);
axios.interceptors.response.use(onResponse, onResponseError);
axiosNoError.interceptors.request.use(onRequest);
axiosNoError.interceptors.response.use(onResponse);
}
axios.interceptors.request.use(onRequest, onRequestError);
axios.interceptors.response.use(onResponse, onResponseError);
axiosNoError.interceptors.request.use(onRequest);
axiosNoError.interceptors.response.use(onResponse);
export { onRequest, onResponseError, axiosNoError };

View File

@ -1,7 +1,6 @@
import { boot } from 'quasar/wrappers';
import qFormMixin from './qformMixin';
import keyShortcut from './keyShortcut';
import { setupAxios } from 'src/boot/axios';
import useNotify from 'src/composables/useNotify.js';
import { CanceledError } from 'axios';
@ -49,5 +48,4 @@ export default boot(({ app }) => {
notify(message ?? 'globals.error', 'negative', 'error');
};
setupAxios();
});

View File

@ -17,19 +17,12 @@ const config = reactive({
const type = Object.keys(config).find((key) => key in useAttrs()) || 'sip';
onBeforeMount(async () => {
let url;
let { channel } = config[type];
if (type === 'say-simple') {
url = (await axios.get('SaySimpleConfigs/findOne')).data.url;
if (!channel)
channel = (
await axios.get('SaySimpleCountries/findOne', {
params: {
filter: { fields: ['channel'], where: { countryFk: 0 } },
},
})
).data?.channel;
const { url, defaultChannel } = (await axios.get('SaySimpleConfigs/findOne'))
.data;
if (!channel) channel = defaultChannel;
config[
type

View File

@ -247,6 +247,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
}
function updateStateParams() {
if (!route?.path) return;
const newUrl = { path: route.path, query: { ...(route.query ?? {}) } };
if (store?.searchUrl)
newUrl.query[store.searchUrl] = JSON.stringify(store.currentFilter);

View File

@ -8,13 +8,9 @@ import useNotify from './useNotify';
import { useTokenConfig } from './useTokenConfig';
const TOKEN_MULTIMEDIA = 'tokenMultimedia';
const TOKEN = 'token';
let router;
export default {
setup() {
router = useRouter();
},
};
export function useSession() {
const router = useRouter();
const { notify } = useNotify();
let isCheckingToken = false;
let intervalId = null;

View File

@ -2,10 +2,9 @@
import { computed, onBeforeMount, ref, watch, nextTick } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import VnInputDate from 'components/common/VnInputDate.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnRow from 'components/ui/VnRow.vue';
import axios from 'axios';
import useNotify from 'src/composables/useNotify';
import { useStateStore } from 'stores/useStateStore';

View File

@ -194,14 +194,14 @@ const getItemPackagingType = (ticketSales) => {
redirect="ticket"
>
<template #column-nickname="{ row }">
<span class="link">
<span class="link" @click.stop>
{{ row.nickname }}
<CustomerDescriptorProxy :id="row.clientFk" />
</span>
</template>
<template #column-routeFk="{ row }">
<span class="link">
<span class="link" @click.stop>
{{ row.routeFk }}
<RouteDescriptorProxy :id="row.routeFk" />
</span>
@ -218,7 +218,7 @@ const getItemPackagingType = (ticketSales) => {
<span v-else> {{ toCurrency(row.totalWithVat) }}</span>
</template>
<template #column-state="{ row }">
<span v-if="row.invoiceOut">
<span v-if="row.invoiceOut" @click.stop>
<span :class="{ link: row.invoiceOut.ref }">
{{ row.invoiceOut.ref }}
<InvoiceOutDescriptorProxy :id="row.invoiceOut.id" />

View File

@ -99,7 +99,7 @@ const travelDialogRef = ref(false);
const tableRef = ref();
const travel = ref(null);
const userParams = ref({
dated: Date.vnNew(),
dated: Date.vnNew().toJSON(),
});
const filter = ref({
@ -219,6 +219,7 @@ function round(value) {
data-key="StockBoughts"
url="StockBoughts/getStockBought"
save-url="StockBoughts/crud"
search-url="StockBoughts"
order="reserve DESC"
:right-search="false"
:is-editable="true"

View File

@ -18,7 +18,7 @@ const $props = defineProps({
required: true,
},
});
const customUrl = `StockBoughts/getStockBoughtDetail?workerFk=${$props.workerFk}&date=${$props.dated}`;
const customUrl = `StockBoughts/getStockBoughtDetail?workerFk=${$props.workerFk}&dated=${$props.dated}`;
const columns = [
{
align: 'left',

View File

@ -27,7 +27,7 @@ onMounted(async () => {
<VnFilterPanel
:data-key="props.dataKey"
:search-button="true"
search-url="table"
search-url="StockBoughts"
@set-user-params="setUserParams"
>
<template #tags="{ tag, formatFn }">
@ -36,12 +36,19 @@ onMounted(async () => {
<span>{{ formatFn(tag.value) }}</span>
</div>
</template>
<template #body="{ params }">
<template #body="{ params, searchFn }">
<QItem class="q-my-sm">
<QItemSection>
<VnInputDate
id="date"
v-model="params.dated"
@update:model-value="
(value) => {
params.dated = value;
setUserParams(params);
searchFn();
}
"
:label="t('Date')"
is-outlined
/>

View File

@ -268,6 +268,7 @@ onMounted(() => (stateStore.rightDrawer = false));
:label="t('basicData.price')"
type="number"
min="0"
step="any"
/>
</template>
</VnTable>

View File

@ -105,11 +105,14 @@ watch(
<template #option="{ itemProps, opt }">
<QItem v-bind="itemProps">
<QItemSection v-if="opt.code">
<QItemLabel>{{ opt.code }}</QItemLabel>
<QItemLabel caption
>{{ opt.town?.province?.name }},
{{ opt.town?.province?.country?.name }}</QItemLabel
>
<QItemLabel>
{{ `${opt.code}, ${opt.town?.name}` }}
</QItemLabel>
<QItemLabel caption>
{{
`${opt.town?.province?.name}, ${opt.town?.province?.country?.name}`
}}
</QItemLabel>
</QItemSection>
</QItem>
</template>

View File

@ -22,7 +22,12 @@ const agencies = ref([]);
</script>
<template>
<FetchData url="agencies" @on-fetch="(data) => (agencies = data)" auto-load />
<FetchData
url="AgencyModes"
:filter="{ fields: ['id', 'name'] }"
@on-fetch="(data) => (agencies = data)"
auto-load
/>
<VnFilterPanel
:data-key="props.dataKey"
:search-button="true"

View File

@ -73,6 +73,7 @@ const columns = computed(() => [
inWhere: true,
attrs: {
url: 'AgencyModes',
fields: ['id', 'name'],
},
},
columnField: {

View File

@ -14,8 +14,8 @@ import { useUserConfig } from 'src/composables/useUserConfig';
import { useTokenConfig } from 'src/composables/useTokenConfig';
import { useAcl } from 'src/composables/useAcl';
let state, session;
const state = useState();
const session = useSession();
const { t, te } = i18n.global;
const createHistory = process.env.SERVER
@ -43,10 +43,8 @@ const Router = createRouter({
* with the Router instance.
*/
export { Router };
export default route((/* { store, ssrContext } */) => {
export default route(function (/* { store, ssrContext } */) {
Router.beforeEach(async (to, from, next) => {
state = useState();
session = useSession();
const { isLoggedIn } = session;
const outLayout = Router.options.routes[0].children.map((r) => r.name);
if (!isLoggedIn() && !outLayout.includes(to.name)) {

View File

@ -1,38 +1,23 @@
import { describe, it, expect, beforeEach, vi } from 'vitest';
import { setupAxios, onRequest, onResponseError } from 'src/boot/axios';
import { useSession } from 'src/composables/useSession';
import useNotify from 'src/composables/useNotify';
import { useStateQueryStore } from 'src/stores/useStateQueryStore';
import { Notify } from 'quasar';
import { onRequest, onResponseError } from 'src/boot/axios';
import { describe, expect, it, vi } from 'vitest';
vi.mock('src/composables/useSession');
vi.mock('src/composables/useNotify');
vi.mock('src/stores/useStateQueryStore');
vi.mock('src/composables/useSession', () => ({
useSession: () => ({
getToken: () => 'DEFAULT_TOKEN',
isLoggedIn: () => vi.fn(),
destroy: () => vi.fn(),
}),
}));
vi.mock('src/stores/useStateQueryStore', () => ({
useStateQueryStore: () => ({
add: () => vi.fn(),
remove: () => vi.fn(),
}),
}));
describe('Axios boot', () => {
let sessionMock, notifyMock, stateQueryMock;
beforeEach(() => {
sessionMock = {
getToken: vi.fn().mockReturnValue('DEFAULT_TOKEN'),
isLoggedIn: vi.fn().mockReturnValue(true),
destroy: vi.fn(),
};
notifyMock = {
notify: vi.fn(),
};
stateQueryMock = {
add: vi.fn(),
remove: vi.fn(),
};
useSession.mockReturnValue(sessionMock);
useNotify.mockReturnValue(notifyMock);
useStateQueryStore.mockReturnValue(stateQueryMock);
setupAxios();
});
describe('onRequest()', async () => {
it('should set the "Authorization" property on the headers', async () => {
const config = { headers: {} };