Merge branch 'dev' into 8387-itemTagCrudModelFront
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
9d77c0bc93
14
package.json
14
package.json
|
@ -21,24 +21,24 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@quasar/cli": "^2.3.0",
|
||||
"@quasar/extras": "^1.16.9",
|
||||
"@quasar/extras": "^1.16.14",
|
||||
"axios": "^1.4.0",
|
||||
"chromium": "^3.0.3",
|
||||
"croppie": "^2.6.5",
|
||||
"moment": "^2.30.1",
|
||||
"pinia": "^2.1.3",
|
||||
"quasar": "^2.14.5",
|
||||
"quasar": "^2.17.4",
|
||||
"validator": "^13.9.0",
|
||||
"vue": "^3.3.4",
|
||||
"vue-i18n": "^9.2.2",
|
||||
"vue-router": "^4.2.1"
|
||||
"vue": "^3.5.13",
|
||||
"vue-i18n": "^9.3.0",
|
||||
"vue-router": "^4.2.5"
|
||||
},
|
||||
"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.7.3",
|
||||
"@quasar/app-vite": "^1.11.0",
|
||||
"@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 +52,7 @@
|
|||
"husky": "^8.0.0",
|
||||
"postcss": "^8.4.23",
|
||||
"prettier": "^2.8.8",
|
||||
"vitest": "^0.31.1"
|
||||
"vitest": "^0.34.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20 || ^18 || ^16",
|
||||
|
|
1079
pnpm-lock.yaml
1079
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,9 @@
|
|||
<script setup>
|
||||
import quasarLang from 'src/utils/quasarLang';
|
||||
|
||||
import { onMounted, computed, ref } from 'vue';
|
||||
import { Dark, Quasar } from 'quasar';
|
||||
|
||||
import { Dark } from 'quasar';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
|
@ -31,14 +34,7 @@ const userLocale = computed({
|
|||
|
||||
value = localeEquivalence[value] ?? value;
|
||||
|
||||
try {
|
||||
/* @vite-ignore */
|
||||
import(`../../node_modules/quasar/lang/${value}.mjs`).then((lang) => {
|
||||
Quasar.lang.set(lang.default);
|
||||
});
|
||||
} catch (error) {
|
||||
//
|
||||
}
|
||||
quasarLang(value);
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
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,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -299,11 +299,12 @@ defineExpose({
|
|||
:url="$props.model"
|
||||
:user-filter="dmsFilter"
|
||||
:order="['dmsFk DESC']"
|
||||
:auto-load="true"
|
||||
auto-load
|
||||
@on-fetch="setData"
|
||||
>
|
||||
<template #body>
|
||||
<QTable
|
||||
v-if="rows"
|
||||
:columns="columns"
|
||||
:rows="rows"
|
||||
class="full-width q-mt-md"
|
||||
|
|
|
@ -70,9 +70,6 @@ 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"
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
import RightMenu from './RightMenu.vue';
|
||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||
import VnTableFilter from '../VnTable/VnTableFilter.vue';
|
||||
import { onBeforeMount, computed, ref } from 'vue';
|
||||
import { onBeforeMount, onMounted, onUnmounted, computed, ref } from 'vue';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useHasContent } from 'src/composables/useHasContent';
|
||||
|
||||
const $props = defineProps({
|
||||
|
@ -47,16 +47,12 @@ const $props = defineProps({
|
|||
});
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
let arrayData;
|
||||
const sectionValue = computed(() => $props.section ?? $props.dataKey);
|
||||
const isMainSection = computed(() => {
|
||||
const isSame = sectionValue.value == route.name;
|
||||
if (!isSame && arrayData) {
|
||||
arrayData.reset(['userParams', 'filter']);
|
||||
arrayData.setCurrentFilter();
|
||||
}
|
||||
return isSame;
|
||||
});
|
||||
const isMainSection = ref(false);
|
||||
|
||||
const searchbarId = 'section-searchbar';
|
||||
const hasContent = useHasContent(`#${searchbarId}`);
|
||||
|
||||
|
@ -68,7 +64,23 @@ onBeforeMount(() => {
|
|||
...$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">
|
||||
|
|
|
@ -55,7 +55,7 @@ const url = computed(() => {
|
|||
sort-by="nickname ASC"
|
||||
>
|
||||
<template #prepend v-if="$props.hasAvatar">
|
||||
<VnAvatar :worker-id="value" color="primary" :title="title" />
|
||||
<VnAvatar :worker-id="value" color="primary" v-bind="$attrs" />
|
||||
</template>
|
||||
<template #append v-if="$props.hasInfo">
|
||||
<QIcon name="info" class="cursor-pointer">
|
||||
|
@ -72,7 +72,8 @@ const url = computed(() => {
|
|||
{{ scope.opt.nickname }}
|
||||
</QItemLabel>
|
||||
<QItemLabel caption v-else>
|
||||
#{{ scope.opt.id }}, {{ scope.opt.nickname }}, {{ scope.opt.code }}
|
||||
#{{ scope.opt.id }}, {{ scope.opt.nickname }},
|
||||
{{ scope.opt.code }}
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
|
|
|
@ -175,7 +175,7 @@ async function fetch() {
|
|||
display: inline-block;
|
||||
}
|
||||
.header.link:hover {
|
||||
color: lighten($primary, 20%);
|
||||
color: rgba(var(--q-primary), 0.8);
|
||||
}
|
||||
.q-checkbox {
|
||||
& .q-checkbox__label {
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
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);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -2,6 +2,8 @@
|
|||
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();
|
||||
|
||||
|
@ -12,18 +14,9 @@ const userLocale = computed({
|
|||
set(value) {
|
||||
locale.value = value;
|
||||
|
||||
if (value === 'en') value = 'en-GB';
|
||||
value = localeEquivalence[value] ?? 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) {
|
||||
//
|
||||
}
|
||||
quasarLang(value);
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
const langList = import.meta.glob('../../node_modules/quasar/lang/*.js');
|
||||
import { Quasar } from 'quasar';
|
||||
|
||||
export default function (value) {
|
||||
try {
|
||||
langList[`../../node_modules/quasar/lang/${value}.js`]().then((lang) => {
|
||||
Quasar.lang.set(lang.default);
|
||||
});
|
||||
} catch (error) {
|
||||
//
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue