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

This commit is contained in:
Javi Gallego 2024-12-29 09:09:30 +00:00
commit 286e460638
154 changed files with 2189 additions and 1492 deletions

View File

@ -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(); //destoy watcher
if (watchChanges.value) watchChanges.value(); //destroy watcher
watchChanges.value = watch(formData, () => (hasChanges.value = true), { deep: true });
}
@ -270,10 +270,8 @@ function getChanges() {
function isEmpty(obj) {
if (obj == null) return true;
if (obj === undefined) return true;
if (Object.keys(obj).length === 0) return true;
if (obj.length > 0) return false;
if (Array.isArray(obj)) return !obj.length;
return !Object.keys(obj).length;
}
async function reload(params) {

View File

@ -92,15 +92,15 @@ function findMatches(search, item) {
}
function addChildren(module, route, parent) {
if (route.menus) {
const mainMenus = route.menus[props.source];
const matches = findMatches(mainMenus, route);
const menus = route?.meta?.menu ?? route?.menus?.[props.source]; //backwards compatible
if (!menus) return;
const matches = findMatches(menus, route);
for (const child of matches) {
navigation.addMenuItem(module, child, parent);
}
}
}
function getRoutes() {
if (props.source === 'main') {
@ -122,16 +122,26 @@ function getRoutes() {
if (props.source === 'card') {
const currentRoute = route.matched[1];
const currentModule = toLowerCamel(currentRoute.name);
const moduleDef = routes.find(
let 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();

View File

@ -17,12 +17,10 @@ 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">
@ -59,22 +57,13 @@ const pinnedModulesRef = ref();
'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"
@ -106,7 +95,6 @@ const pinnedModulesRef = ref();
<VnBreadcrumbs v-if="$q.screen.lt.md" class="q-ml-md" />
</QHeader>
</template>
<style lang="scss" scoped>
.searchbar {
width: max-content;
@ -115,9 +103,3 @@ const pinnedModulesRef = ref();
background-color: var(--vn-section-color);
}
</style>
<i18n>
en:
Go to Salix: Go to Salix
es:
Go to Salix: Ir a Salix
</i18n>

View File

@ -32,7 +32,10 @@ const $props = defineProps({
defineExpose({ addFilter, props: $props });
const model = defineModel(undefined, { required: true });
const arrayData = useArrayData($props.dataKey, { searchUrl: $props.searchUrl });
const arrayData = useArrayData(
$props.dataKey,
$props.searchUrl ? { searchUrl: $props.searchUrl } : null
);
const columnFilter = computed(() => $props.column?.columnFilter);
const updateEvent = { 'update:modelValue': addFilter };

View File

@ -1,20 +1,21 @@
<script setup>
import { ref, onBeforeMount, onMounted, computed, watch } from 'vue';
import { ref, onBeforeMount, onMounted, computed, watch, useAttrs } 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: {
@ -33,6 +34,10 @@ const $props = defineProps({
type: Boolean,
default: true,
},
rightSearchIcon: {
type: Boolean,
default: true,
},
rowClick: {
type: [Function, Boolean],
default: null,
@ -101,10 +106,6 @@ const $props = defineProps({
type: String,
default: '90vh',
},
chipLocale: {
type: String,
default: null,
},
footer: {
type: Boolean,
default: false,
@ -119,22 +120,21 @@ 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,6 +150,7 @@ const tableModes = [
disable: $props.disableOption?.card,
},
];
onBeforeMount(() => {
const urlParams = route.query[$props.searchUrl];
hasParams.value = urlParams && Object.keys(urlParams).length !== 0;
@ -183,41 +184,8 @@ watch(
{ immediate: true }
);
watch(
() => route.query[$props.searchUrl],
(val) => setUserParams(val),
{ immediate: true, deep: true }
);
const isTableMode = computed(() => mode.value == TABLE_MODE);
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;
}
const showRightIcon = computed(() => $props.rightSearch || $props.rightSearchIcon);
function splitColumns(columns) {
splittedColumns.value = {
@ -298,17 +266,6 @@ 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,
@ -357,61 +314,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
show-if-above
>
<QScrollArea class="fit">
<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>
<VnTableFilter :data-key="$attrs['data-key']" :columns="columns" />
</QScrollArea>
</QDrawer>
<CrudModel
@ -467,7 +370,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
:options="tableModes.filter((mode) => !mode.disable)"
/>
<QBtn
v-if="$props.rightSearch"
v-if="showRightIcon"
icon="filter_alt"
class="bg-vn-section-color q-ml-sm"
dense
@ -481,7 +384,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
:class="col.headerClass"
>
<div
class="column self-start q-ml-xs ellipsis"
class="column ellipsis"
:class="`text-${col?.align ?? 'left'}`"
:style="$props.columnSearch ? 'height: 75px' : ''"
>
@ -523,7 +426,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
<!-- Columns -->
<QTd
auto-width
class="no-margin q-px-xs"
class="no-margin"
:class="[getColAlign(col), col.columnClass]"
:style="col.style"
v-if="col.visible ?? true"
@ -658,13 +561,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
:key="col.name"
class="fields"
>
<VnLv
:label="
!col.component && col.label
? `${col.label}:`
: ''
"
>
<VnLv :label="col.label + ':'">
<template #value>
<span
@click="stopEventPropagation($event)"
@ -805,7 +702,7 @@ es:
.grid-three {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(400px, max-content));
grid-template-columns: repeat(auto-fit, minmax(350px, max-content));
max-width: 100%;
grid-gap: 20px;
margin: 0 auto;
@ -854,21 +751,6 @@ 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;

View File

@ -0,0 +1,72 @@
<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
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,
},
chipLocale: {
type: String,
default: null,
},
searchUrl: {
type: [String, Boolean],
default: 'table',
},
});
const { t } = useI18n();
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 }" v-if="chipLocale">
<div class="q-gutter-x-xs">
<strong>{{ t(`${chipLocale}.${tag.label}`) }}: </strong>
<span>{{ formatFn(tag.value) }}</span>
</div>
</template>
</VnFilterPanel>
</template>

View File

@ -1,4 +1,4 @@
import { describe, expect, it, beforeAll, beforeEach } from 'vitest';
import { describe, expect, it, beforeAll, beforeEach, vi } from 'vitest';
import { createWrapper } from 'app/test/vitest/helper';
import VnTable from 'src/components/VnTable/VnTable.vue';
@ -13,6 +13,15 @@ describe('VnTable', () => {
},
});
vm = wrapper.vm;
vi.mock('src/composables/useFilterParams', () => {
return {
useFilterParams: vi.fn(() => ({
params: {},
orders: {},
})),
};
});
});
beforeEach(() => (vm.selected = []));

View File

@ -0,0 +1,248 @@
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)));
});
});
});

View File

@ -0,0 +1,149 @@
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,
});
}

View File

@ -2,7 +2,11 @@
import { ref, onMounted, useSlots } from 'vue';
import { useI18n } from 'vue-i18n';
import { useStateStore } from 'stores/useStateStore';
import { useQuasar } from 'quasar';
const { t } = useI18n();
const quasar = useQuasar();
const stateStore = useStateStore();
const slots = useSlots();
const hasContent = ref(false);
const rightPanel = ref(null);
@ -11,7 +15,6 @@ onMounted(() => {
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;
});
@ -21,12 +24,9 @@ onMounted(() => {
childList: true,
attributes: true,
});
if (!slots['right-panel'] && !hasContent.value) stateStore.rightDrawer = false;
if ((!slots['right-panel'] && !hasContent.value) || quasar.platform.is.mobile)
stateStore.rightDrawer = false;
});
const { t } = useI18n();
const stateStore = useStateStore();
</script>
<template>
<Teleport to="#actions-append" v-if="stateStore.isHeaderMounted()">
@ -45,7 +45,7 @@ const stateStore = useStateStore();
</QBtn>
</div>
</Teleport>
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256">
<QScrollArea class="fit">
<div id="right-panel"></div>
<slot v-if="!hasContent" name="right-panel" />

View File

@ -15,7 +15,7 @@ let root = ref(null);
watchEffect(() => {
matched.value = currentRoute.value.matched.filter(
(matched) => Object.keys(matched.meta).length
(matched) => !!matched?.meta?.title || !!matched?.meta?.icon
);
breadcrumbs.value.length = 0;
if (!matched.value[0]) return;

View File

@ -0,0 +1,67 @@
<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>

View File

@ -106,7 +106,7 @@ const manageDate = (date) => {
:class="{ required: isRequired }"
:rules="mixinRules"
:clearable="false"
@click="isPopupOpen = true"
@click="isPopupOpen = !isPopupOpen"
hide-bottom-space
>
<template #append>
@ -125,13 +125,6 @@ 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"
@ -151,15 +144,6 @@ 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

View File

@ -80,7 +80,7 @@ function dateToTime(newDate) {
:class="{ required: isRequired }"
style="min-width: 100px"
:rules="mixinRules"
@click="isPopupOpen = false"
@click="isPopupOpen = !isPopupOpen"
type="time"
hide-bottom-space
>
@ -100,12 +100,6 @@ 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"

View File

@ -26,7 +26,7 @@ const locationProperties = [
(obj) => obj.country?.name,
];
const formatLocation = (obj, properties) => {
const formatLocation = (obj, properties = locationProperties) => {
const parts = properties.map((prop) => {
if (typeof prop === 'string') {
return obj[prop];

View File

@ -1,8 +1,8 @@
<script setup>
import { useStateStore } from 'stores/useStateStore';
import LeftMenu from 'components/LeftMenu.vue';
import { onMounted } from 'vue';
import { onMounted, ref } from 'vue';
import { useQuasar } from 'quasar';
import LeftMenu from '../LeftMenu.vue';
const stateStore = useStateStore();
const $props = defineProps({
@ -14,12 +14,30 @@ 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) {
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">
<LeftMenu />
<div id="left-panel" ref="teleportRef"></div>
<LeftMenu v-if="!hasContent" />
</QScrollArea>
</QDrawer>
<QPageContainer>

View File

@ -0,0 +1,79 @@
<script setup>
import RightMenu from './RightMenu.vue';
import VnSearchbar from 'components/ui/VnSearchbar.vue';
import VnTableFilter from '../VnTable/VnTableFilter.vue';
import { onBeforeMount, computed } from 'vue';
import { useArrayData } from 'src/composables/useArrayData';
const $props = defineProps({
section: {
type: String,
required: true,
},
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,
},
});
const sectionValue = computed(() => $props.section ?? $props.dataKey);
let arrayData;
onBeforeMount(() => {
if ($props.dataKey)
arrayData = useArrayData($props.dataKey, {
searchUrl: 'table',
...$props.arrayDataProps,
navigate: $props.redirect,
});
});
</script>
<template>
<slot name="searchbar">
<VnSearchbar
v-if="searchBar"
v-bind="arrayDataProps"
:data-key="dataKey"
:label="$t(`${prefix}.search`)"
:info="$t(`${prefix}.searchInfo`)"
/>
</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="sectionValue == $route.name" />
<RouterView v-else />
</template>

View File

@ -224,7 +224,7 @@ async function fetchFilter(val) {
const fetchOptions = { where, include, limit };
if (fields) fetchOptions.fields = fields;
if (sortBy) fetchOptions.order = sortBy;
arrayData.reset(['skip', 'filter.skip', 'page']);
arrayData.resetPagination();
const { data } = await arrayData.applyFilter({ filter: fetchOptions });
setOptions(data);
@ -379,7 +379,8 @@ function handleKeyDown(event) {
</template>
<template #option="{ opt, itemProps }">
<QItem v-bind="itemProps">
<QItemSection v-if="opt[optionValue] == opt[optionLabel]">
<QItemSection v-if="typeof opt !== 'object'"> {{ opt }}</QItemSection>
<QItemSection v-else-if="opt[optionValue] == opt[optionLabel]">
<QItemLabel>{{ opt[optionLabel] }}</QItemLabel>
</QItemSection>
<QItemSection v-else>

View File

@ -0,0 +1,87 @@
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);
});
});
});

View File

@ -0,0 +1,91 @@
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');
});
});

View File

@ -1,10 +1,10 @@
<script setup>
import { ref, computed, watch, onBeforeMount } from 'vue';
import { ref, computed, watch, onBeforeMount, onMounted } 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 { useStateStore } from 'src/stores/useStateStore';
const props = defineProps({
url: {
@ -40,6 +40,7 @@ const { store } = arrayData;
const entity = computed(() => (Array.isArray(store.data) ? store.data[0] : store.data));
const isLoading = ref(false);
const stateStore = useStateStore();
defineExpose({
entity,
fetch,
@ -51,6 +52,9 @@ onBeforeMount(async () => {
watch(props, async () => await fetch());
});
onMounted(() => {
stateStore.rightDrawerChangeValue(false);
});
async function fetch() {
store.url = props.url;
store.filter = props.filter ?? {};
@ -60,7 +64,6 @@ async function fetch() {
isLoading.value = false;
}
</script>
<template>
<div class="summary container">
<QCard class="cardSummary">
@ -81,7 +84,7 @@ async function fetch() {
<span v-else></span>
</slot>
<slot name="header" :entity="entity" dense>
<VnLv :label="`${entity.id} -`" :value="entity.name" />
{{ entity.id + ' - ' + entity.name }}
</slot>
<slot name="header-right" :entity="entity">
<span></span>
@ -94,7 +97,6 @@ async function fetch() {
</QCard>
</div>
</template>
<style lang="scss">
.summary.container {
display: flex;

View File

@ -16,7 +16,13 @@ const $props = defineProps({
required: false,
default: 'value',
},
columns: {
type: Number,
required: false,
default: null,
},
});
const tags = computed(() => {
return Object.keys($props.item)
.filter((i) => i.startsWith(`${$props.tag}`))
@ -28,10 +34,21 @@ 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">
<div class="wrap" :style="columnStyle">
<div
v-for="(val, key) in tags"
:key="key"
@ -39,37 +56,43 @@ const tags = computed(() => {
:title="`${key}: ${val}`"
:class="{ empty: !val }"
>
{{ val }}
<span class="text">{{ val }} </span>
</div>
</div>
</div>
</template>
<style lang="scss" scoped>
.fetchedTags {
align-items: center;
.wrap {
width: 100%;
flex-wrap: wrap;
display: flex;
display: grid;
}
.inline-tag {
display: flex;
align-items: center;
justify-content: center;
height: 1rem;
margin: 0.05rem;
color: $color-font-secondary;
color: var(--vn-label-color);
text-align: center;
font-size: smaller;
padding: 1px;
flex: 1;
border: 1px solid $color-spacer;
border: 1px solid var(--vn-label-color);
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 #2b2b2b;
border: 1px solid var(--vn-empty-tag);
}
}
</style>

View File

@ -1,12 +1,14 @@
<script setup>
import { onMounted, ref, computed, watch } from 'vue';
import { ref, computed } 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 $props = defineProps({
modelValue: {
type: Object,
@ -55,6 +57,10 @@ const $props = defineProps({
type: Boolean,
default: true,
},
arrayData: {
type: Object,
default: null,
},
});
const emit = defineEmits([
@ -67,52 +73,19 @@ const emit = defineEmits([
'setUserParams',
]);
const arrayData = useArrayData($props.dataKey, {
const arrayData =
$props.arrayData ??
useArrayData($props.dataKey, {
exprBuilder: $props.exprBuilder,
searchUrl: $props.searchUrl,
navigate: $props.redirect ? {} : null,
});
const route = useRoute();
const store = arrayData.store;
const userParams = ref({});
const userParams = ref(useFilterParams($props.dataKey).params);
const userOrders = ref(useFilterParams($props.dataKey).orders);
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 ?? {})
);
defineExpose({ search, params: userParams, remove });
const isLoading = ref(false);
async function search(evt) {
@ -123,10 +96,9 @@ async function search(evt) {
isLoading.value = true;
const filter = { ...userParams.value, ...$props.modelValue };
store.userParamsChanged = true;
const { params: newParams } = await arrayData.addFilter({
await arrayData.addFilter({
params: filter,
});
userParams.value = newParams;
if (!$props.showAll && !Object.values(filter).length) store.data = [];
emit('search');
@ -139,7 +111,7 @@ async function clearFilters() {
try {
isLoading.value = true;
store.userParamsChanged = true;
arrayData.reset(['skip', 'filter.skip', 'page']);
arrayData.resetPagination();
// Filtrar los params no removibles
const removableFilters = Object.keys(userParams.value).filter((param) =>
$props.unremovableParams.includes(param)
@ -149,9 +121,8 @@ async function clearFilters() {
for (const key of removableFilters) {
newParams[key] = userParams.value[key];
}
userParams.value = {};
userParams.value = { ...newParams }; // Actualizar los params con los removibles
await arrayData.applyFilter({ params: userParams.value });
await arrayData.applyFilter({ params: { ...newParams } });
if (!$props.showAll) {
store.data = [];
@ -214,21 +185,6 @@ function formatValue(value) {
return `"${value}"`;
}
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;
}
const getLocale = (label) => {
const param = label.split('.').at(-1);
const globalLocale = `globals.params.${param}`;
@ -313,8 +269,9 @@ const getLocale = (label) => {
<QList dense class="list q-gutter-y-sm q-mt-sm">
<slot
name="body"
:params="sanitizer(userParams)"
:get-locale="getLocale"
:params="userParams"
:orders="userOrders"
:search-fn="search"
></slot>
</QList>

View File

@ -39,7 +39,7 @@ const val = computed(() => $props.value);
<template v-else>
<div v-if="label || $slots.label" class="label">
<slot name="label">
<span>{{ label }}</span>
<span style="color: var(--vn-label-color)">{{ label }}</span>
</slot>
</div>
<div class="value">

View File

@ -106,10 +106,13 @@ const store = arrayData.store;
onMounted(async () => {
if (props.autoLoad && !store.data?.length) await fetch();
else emit('onFetch', store.data);
mounted.value = true;
});
onBeforeUnmount(() => arrayData.reset());
onBeforeUnmount(() => {
arrayData.resetPagination();
});
watch(
() => props.data,
@ -137,8 +140,8 @@ const addFilter = async (filter, params) => {
async function fetch(params) {
useArrayData(props.dataKey, params);
arrayData.reset(['filter.skip', 'skip', 'page']);
await arrayData.fetch({ append: false, updateRouter: mounted.value });
arrayData.resetPagination();
await arrayData.fetch({ append: false });
return emitStoreData();
}
@ -200,13 +203,20 @@ async function onLoad(index, done) {
done(isDone);
}
defineExpose({ fetch, update, addFilter, paginate });
defineExpose({
fetch,
update,
addFilter,
paginate,
userParams: arrayData.store.userParams,
currentFilter: arrayData.store.currentFilter,
});
</script>
<template>
<div class="full-width">
<div
v-if="!props.autoLoad && !store.data && !isLoading"
v-if="!store.data && !store.data?.length && !isLoading"
class="info-row q-pa-md text-center"
>
<h5>

View File

@ -63,6 +63,10 @@ const props = defineProps({
type: Function,
default: undefined,
},
searchRemoveParams: {
type: Boolean,
default: true,
},
});
const searchText = ref();
@ -96,17 +100,25 @@ onMounted(() => {
});
async function search() {
const staticParams = Object.entries(store.userParams);
arrayData.reset(['skip', 'page']);
const staticParams = Object.keys(store.userParams ?? {}).length
? store.userParams
: store.defaultParams;
arrayData.resetPagination();
const filter = {
params: {
...Object.fromEntries(staticParams),
search: searchText.value,
},
...{ filter: props.filter },
filter: props.filter,
};
if (!props.searchRemoveParams || !searchText.value) {
filter.params = {
...staticParams,
search: searchText.value,
};
}
if (props.whereFilter) {
filter.filter = {
where: props.whereFilter(searchText.value),

View File

@ -25,11 +25,14 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
const searchUrl = store.searchUrl;
if (query[searchUrl]) {
const params = JSON.parse(query[searchUrl]);
const filter = params?.filter && JSON.parse(params?.filter ?? '{}');
const filter =
params?.filter && typeof params?.filter == 'object'
? params?.filter
: JSON.parse(params?.filter ?? '{}');
delete params.filter;
store.userParams = { ...store.userParams, ...params };
store.userFilter = { ...filter, ...store.userFilter };
store.filter = { ...filter, ...store.userFilter };
if (filter?.order) store.order = filter.order;
}
});
@ -61,6 +64,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
store[option] = userOptions.keepOpts?.includes(option)
? Object.assign(defaultOpts, store[option])
: defaultOpts;
if (option === 'userParams') store.defaultParams = store[option];
}
}
}
@ -75,7 +79,6 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
const filter = {
limit: store.limit,
};
let userParams = { ...store.userParams };
Object.assign(filter, store.userFilter);
@ -143,6 +146,10 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
if (arrayDataStore.get(key)) arrayDataStore.reset(key, opts);
}
function resetPagination() {
if (arrayDataStore.get(key)) arrayDataStore.resetPagination(key);
}
function cancelRequest() {
if (canceller) {
canceller.abort();
@ -166,7 +173,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
userParams = sanitizerParams(userParams, store?.exprBuilder);
store.userParams = userParams;
reset(['skip', 'filter.skip', 'page']);
resetPagination();
await fetch({});
return { filter, params };
@ -193,7 +200,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
}
store.order = order;
reset(['skip', 'filter.skip', 'page']);
resetPagination();
fetch({});
index++;
@ -276,7 +283,6 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
const pushUrl = { path: to };
if (to.endsWith('/list') || to.endsWith('/'))
pushUrl.query = newUrl.query;
else destroy();
return router.push(pushUrl);
}
}
@ -328,5 +334,6 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
isLoading,
deleteOption,
reset,
resetPagination,
};
}

View File

@ -0,0 +1,65 @@
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 (!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 };
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,
};
}

View File

@ -11,6 +11,7 @@ body.body--light {
--vn-text-color: var(--font-color);
--vn-label-color: #5f5f5f;
--vn-accent-color: #e7e3e3;
--vn-empty-tag: #acacac;
background-color: var(--vn-page-color);
@ -26,6 +27,7 @@ body.body--dark {
--vn-text-color: white;
--vn-label-color: #a8a8a8;
--vn-accent-color: #424242;
--vn-empty-tag: #2d2d2d;
background-color: var(--vn-page-color);
}
@ -240,7 +242,7 @@ input::-webkit-inner-spin-button {
.q-table {
th,
td {
padding: 1px 10px 1px 10px;
padding: 1px 3px 1px 3px;
max-width: 130px;
div span {
overflow: hidden;
@ -296,3 +298,20 @@ input::-webkit-inner-spin-button {
.no-visible {
visibility: hidden;
}
.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;
}

View File

@ -142,7 +142,7 @@ globals:
workCenters: Work centers
modes: Modes
zones: Zones
zonesList: Zones
zonesList: List
deliveryDays: Delivery days
upcomingDeliveries: Upcoming deliveries
role: Role
@ -861,6 +861,7 @@ components:
ended: To
mine: For me
hasMinPrice: Minimum price
warehouseFk: Warehouse
# LatestBuysFilter
salesPersonFk: Buyer
from: From

View File

@ -144,7 +144,7 @@ globals:
workCenters: Centros de trabajo
modes: Modos
zones: Zonas
zonesList: Zonas
zonesList: Listado
deliveryDays: Días de entrega
upcomingDeliveries: Próximos repartos
role: Role
@ -853,6 +853,7 @@ components:
ended: Hasta
mine: Para mi
hasMinPrice: Precio mínimo
wareHouseFk: Almacén
# LatestBuysFilter
salesPersonFk: Comprador
active: Activo

View File

@ -1,16 +1,15 @@
<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: {
@ -21,13 +20,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':
@ -134,39 +133,41 @@ 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,
}"
>
<template #body>
<VnTable
ref="tableRef"
data-key="AccountAcls"
:url="`ACLs`"
:data-key="dataKey"
:create="{
urlCreate: 'ACLs',
title: 'Create ACL',
onDataSaved: () => tableRef.reload(),
formInitialData: {},
}"
order="id DESC"
:disable-option="{ card: true }"
:columns="columns"
default-mode="table"
:right-search="true"
:right-search="false"
:is-editable="true"
:use-model="true"
/>
</template>
</VnSection>
</template>
<i18n>
es:

View File

@ -2,21 +2,12 @@
import { useI18n } from 'vue-i18n';
import { ref, computed } from 'vue';
import VnTable from 'components/VnTable/VnTable.vue';
import VnSearchbar from 'components/ui/VnSearchbar.vue';
import { useStateStore } from 'stores/useStateStore';
import VnSection from 'src/components/common/VnSection.vue';
const tableRef = ref();
const { t } = useI18n();
const stateStore = useStateStore();
const dataKey = 'AccountAliasList';
const exprBuilder = (param, value) => {
switch (param) {
case 'search':
return /^\d+$/.test(value)
? { id: value }
: { alias: { like: `%${value}%` } };
}
};
const columns = computed(() => [
{
align: 'left',
@ -40,40 +31,45 @@ const columns = computed(() => [
create: true,
},
]);
const exprBuilder = (param, value) => {
switch (param) {
case 'search':
return /^\d+$/.test(value)
? { id: value }
: { alias: { like: `%${value}%` } };
}
};
</script>
<template>
<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')"
/>
</Teleport>
</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"
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"
:right-search="false"
/>
</template>
</VnSection>
</template>
<i18n>
es:
Id: Id

View File

@ -1,19 +1,20 @@
<script setup>
import { useI18n } from 'vue-i18n';
import { ref, computed } from 'vue';
import { computed, ref } 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 AccountFilter from './AccountFilter.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnSection from 'src/components/common/VnSection.vue';
import FetchData from 'src/components/FetchData.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',
@ -48,7 +49,7 @@ const columns = computed(() => [
component: 'select',
name: 'roleFk',
attrs: {
url: 'VnRoles',
options: roles,
optionValue: 'id',
optionLabel: 'name',
},
@ -116,7 +117,8 @@ const columns = computed(() => [
],
},
]);
const exprBuilder = (param, value) => {
function exprBuilder(param, value) {
switch (param) {
case 'search':
return /^\d+$/.test(value)
@ -133,39 +135,36 @@ const exprBuilder = (param, value) => {
case 'roleFk':
return { [param]: value };
}
};
}
</script>
<template>
<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>
</RightMenu>
<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="AccountList"
url="VnUsers/preview"
:data-key="dataKey"
:columns="columns"
:create="{
urlCreate: 'VnUsers',
title: t('Create user'),
onDataSaved: ({ id }) => tableRef.redirect(id),
onDataSaved: ({ id }) => $refs.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>
@ -180,6 +179,8 @@ const exprBuilder = (param, value) => {
</template>
</VnTable>
</template>
</VnSection>
</template>
<i18n>
es:

View File

@ -1,12 +1,12 @@
<script setup>
import { useI18n } from 'vue-i18n';
import VnCard from 'components/common/VnCard.vue';
import VnCardBeta from 'components/common/VnCardBeta.vue';
import AliasDescriptor from './AliasDescriptor.vue';
const { t } = useI18n();
</script>
<template>
<VnCard
<VnCardBeta
data-key="Alias"
base-url="MailAliases"
:descriptor="AliasDescriptor"

View File

@ -1,20 +1,8 @@
<script setup>
import { useI18n } from 'vue-i18n';
import VnCard from 'components/common/VnCard.vue';
import VnCardBeta from 'components/common/VnCardBeta.vue';
import AccountDescriptor from './AccountDescriptor.vue';
const { t } = useI18n();
</script>
<template>
<VnCard
data-key="Account"
:descriptor="AccountDescriptor"
search-data-key="AccountList"
:searchbar-props="{
url: 'VnUsers/preview',
label: t('account.search'),
info: t('account.searchInfo'),
}"
/>
<VnCardBeta data-key="AccountId" :descriptor="AccountDescriptor" />
</template>

View File

@ -41,7 +41,7 @@ const hasAccount = ref(false);
/>
<CardDescriptor
ref="descriptor"
:url="`VnUsers/preview`"
url="VnUsers/preview"
:filter="filter"
module="Account"
@on-fetch="setData"
@ -53,7 +53,6 @@ const hasAccount = ref(false);
<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
@ -75,7 +74,7 @@ const hasAccount = ref(false);
<VnLv :label="t('account.card.nickname')" :value="entity.name" />
<VnLv :label="t('account.card.role')" :value="entity.role.name" />
</template>
<template #actions="{ entity }">
<template #icons="{ entity }">
<QCardActions class="q-gutter-x-md">
<QIcon
v-if="!entity.active"
@ -83,7 +82,7 @@ const hasAccount = ref(false);
name="vn:disabled"
flat
round
size="sm"
size="xs"
class="fill-icon"
>
<QTooltip>{{ t('account.card.deactivated') }}</QTooltip>
@ -91,10 +90,10 @@ const hasAccount = ref(false);
<QIcon
color="primary"
name="contact_mail"
v-if="entity.hasAccount"
v-if="hasAccount"
flat
round
size="sm"
size="xs"
class="fill-icon"
>
<QTooltip>{{ t('account.card.enabled') }}</QTooltip>

View File

@ -30,7 +30,7 @@ const filter = {
<template>
<CardSummary
data-key="AccountSummary"
data-key="AccountId"
ref="AccountSummary"
url="VnUsers/preview"
:filter="filter"

View File

@ -3,11 +3,13 @@ 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,
@ -15,8 +17,10 @@ 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',
@ -81,16 +85,16 @@ const exprBuilder = (param, value) => {
</script>
<template>
<VnSearchbar
data-key="AccountRolesList"
:expr-builder="exprBuilder"
:label="t('role.searchRoles')"
:info="t('role.searchInfo')"
/>
<VnSection
:data-key="dataKey"
:columns="columns"
prefix="role"
:array-data-props="{ url, exprBuilder, order: 'id ASC' }"
>
<template #body>
<VnTable
ref="tableRef"
data-key="AccountRolesList"
:url="`VnRoles`"
:data-key="dataKey"
:create="{
urlCreate: 'VnRoles',
title: t('Create rol'),
@ -99,13 +103,15 @@ const exprBuilder = (param, value) => {
editorFk: entityId,
},
}"
order="id ASC"
:disable-option="{ card: true }"
:columns="columns"
default-mode="table"
redirect="account/role"
:right-search="false"
/>
</template>
</VnSection>
</template>
<i18n>
es:

View File

@ -1,20 +1,7 @@
<script setup>
import { useI18n } from 'vue-i18n';
import VnCard from 'components/common/VnCard.vue';
import VnCardBeta from 'components/common/VnCardBeta.vue';
import RoleDescriptor from './RoleDescriptor.vue';
const { t } = useI18n();
</script>
<template>
<VnCard
data-key="Role"
:descriptor="RoleDescriptor"
search-data-key="AccountRolesList"
:searchbar-props="{
url: 'VnRoles',
label: t('role.searchRoles'),
info: t('role.searchInfo'),
searchUrl: 'table',
}"
/>
<VnCardBeta data-key="Role" :descriptor="RoleDescriptor" />
</template>

View File

@ -43,7 +43,7 @@ const removeRole = async () => {
:filter="filter"
module="Role"
@on-fetch="setData"
data-key="accountData"
data-key="Role"
:title="data.title"
:subtitle="data.subtitle"
:summary="$props.summary"

View File

@ -27,10 +27,10 @@ const filter = {
<template>
<CardSummary
ref="summary"
:url="`VnRoles`"
:url="`VnRoles/${entityId}`"
:filter="filter"
@on-fetch="(data) => (role = data)"
data-key="RoleSummary"
data-key="Role"
>
<template #header> {{ role.id }} - {{ role.name }} </template>
<template #body>

View File

@ -66,7 +66,7 @@ account:
mailInputInfo: All emails will be forwarded to the specified address.
role:
newRole: New role
searchRoles: Search role
search: Search role
searchInfo: Search role by id or name
description: Description
id: Id

View File

@ -164,19 +164,7 @@ const columns = computed(() => [
:autofocus="col.tabIndex == 1"
input-debounce="0"
hide-selected
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{ scope.opt?.name }}</QItemLabel>
<QItemLabel caption>
{{ scope.opt?.nickname }}
{{ scope.opt?.code }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelectWorker>
/>
<VnSelect
v-else
v-model="row[col.model]"

View File

@ -230,7 +230,7 @@ async function saveWhenHasChanges() {
</QTd>
</template>
<template #body-cell-discount="{ row, value, rowIndex }">
<QTd auto-width align="right" class="text-primary shrink">
<QTd auto-width align="right" class="link shrink">
{{ value }}
<VnDiscount
:quantity="row.quantity"

View File

@ -30,7 +30,7 @@ defineExpose({ states });
<span>{{ formatFn(tag.value) }}</span>
</div>
</template>
<template #body="{ params, searchFn }">
<template #body="{ params }">
<div class="q-pa-sm q-gutter-y-sm">
<VnInput
:label="t('claim.customerId')"
@ -49,12 +49,9 @@ defineExpose({ states });
<VnSelect
:label="t('Salesperson')"
v-model="params.salesPersonFk"
@update:model-value="searchFn()"
url="Workers/activeWithInheritedRole"
:filter="{ where: { role: 'salesPerson' } }"
:use-like="false"
option-value="id"
option-label="name"
option-filter="firstName"
dense
outlined
@ -63,12 +60,9 @@ defineExpose({ states });
<VnSelect
:label="t('claim.attendedBy')"
v-model="params.attenderFk"
@update:model-value="searchFn()"
url="Workers/activeWithInheritedRole"
:filter="{ where: { role: 'salesPerson' } }"
:use-like="false"
option-value="id"
option-label="name"
option-filter="firstName"
dense
outlined
@ -77,9 +71,7 @@ defineExpose({ states });
<VnSelect
:label="t('claim.state')"
v-model="params.claimStateFk"
@update:model-value="searchFn()"
:options="states"
option-value="id"
option-label="description"
dense
outlined
@ -87,7 +79,6 @@ defineExpose({ states });
/>
<VnInputDate
v-model="params.created"
@update:model-value="searchFn()"
:label="t('claim.created')"
outlined
rounded
@ -96,10 +87,7 @@ defineExpose({ states });
<VnSelect
:label="t('Item')"
v-model="params.itemFk"
@update:model-value="searchFn()"
url="Items/withName"
option-value="id"
option-label="name"
:use-like="false"
sort-by="id DESC"
outlined
@ -118,21 +106,26 @@ defineExpose({ states });
<VnSelect
:label="t('claim.responsible')"
v-model="params.claimResponsibleFk"
@update:model-value="searchFn()"
url="Workers/activeWithInheritedRole"
:filter="{ where: { role: 'salesPerson' } }"
:use-like="false"
option-value="id"
option-label="name"
option-filter="firstName"
dense
outlined
rounded
/>
<VnSelect
:label="t('claim.zone')"
v-model="params.zoneFk"
url="Zones"
:use-like="false"
outlined
rounded
dense
/>
<QCheckbox
v-model="params.myTeam"
:label="t('params.myTeam')"
@update:model-value="searchFn()"
toggle-indeterminate
/>
</div>
@ -153,6 +146,7 @@ en:
created: Created
myTeam: My team
itemFk: Item
zoneFk: Zone
es:
params:
search: Contiene
@ -165,6 +159,7 @@ es:
created: Creada
myTeam: Mi equipo
itemFk: Artículo
zoneFk: Zona
Client Name: Nombre del cliente
Salesperson: Comercial
Item: Artículo

View File

@ -10,6 +10,7 @@ import ClaimSummary from './Card/ClaimSummary.vue';
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import RightMenu from 'src/components/common/RightMenu.vue';
import VnTable from 'src/components/VnTable/VnTable.vue';
import ZoneDescriptorProxy from '../Zone/Card/ZoneDescriptorProxy.vue';
const { t } = useI18n();
const { viewSummary } = useSummaryDialog();
@ -95,7 +96,12 @@ const columns = computed(() => [
optionLabel: 'description',
},
},
orderBy: 'priority',
orderBy: 'cs.priority',
},
{
align: 'left',
label: t('claim.zone'),
name: 'zoneFk',
},
{
align: 'right',
@ -105,6 +111,7 @@ const columns = computed(() => [
title: t('components.smartCard.viewSummary'),
icon: 'preview',
action: (row) => viewSummary(row.id, ClaimSummary),
isPrimary: true,
},
],
},
@ -131,11 +138,10 @@ const STATE_COLOR = {
<VnTable
data-key="ClaimList"
url="Claims/filter"
:order="['priority ASC', 'created ASC']"
:order="['cs.priority ASC', 'created ASC']"
:columns="columns"
redirect="claim"
:right-search="false"
auto-load
>
<template #column-clientFk="{ row }">
<span class="link" @click.stop>
@ -148,6 +154,12 @@ const STATE_COLOR = {
<VnUserLink :name="row.workerName" :worker-id="row.workerFk" />
</span>
</template>
<template #column-zoneFk="{ row }">
<span class="link" @click.stop>
{{ row.zoneName }}
<ZoneDescriptorProxy :id="row.zoneId" />
</span>
</template>
</VnTable>
</template>

View File

@ -16,14 +16,17 @@ const { t } = useI18n();
const businessTypes = ref([]);
const contactChannels = ref([]);
const handleSalesModelValue = (val) => ({
const handleSalesModelValue = (val) => {
if (!val) val = '';
return {
or: [
{ id: val },
{ name: val },
{ nickname: { like: '%' + val + '%' } },
{ code: { like: `${val}%` } },
],
});
};
};
const exprBuilder = (param, value) => {
return {

View File

@ -1,5 +1,5 @@
<script setup>
import { ref, computed } from 'vue';
import { ref, computed, onMounted } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
@ -14,7 +14,12 @@ import CustomerDescriptorMenu from './CustomerDescriptorMenu.vue';
import { useState } from 'src/composables/useState';
const state = useState();
const customer = computed(() => state.get('customer'));
const customer = ref();
onMounted(async () => {
customer.value = state.get('customer');
if (customer.value) customer.value.webAccess = data.value?.account?.isActive;
});
const $props = defineProps({
id: {
@ -38,7 +43,6 @@ const entityId = computed(() => {
const data = ref(useCardDescription());
const setData = (entity) => {
data.value = useCardDescription(entity?.name, entity?.id);
if (customer.value) customer.value.webAccess = data.value?.account?.isActive;
};
const debtWarning = computed(() => {
return customer.value?.debt > customer.value?.credit ? 'negative' : 'primary';

View File

@ -12,14 +12,17 @@ defineProps({
required: true,
},
});
const handleSalesModelValue = (val) => ({
const handleSalesModelValue = (val) => {
if (!val) val = '';
return {
or: [
{ id: val },
{ name: val },
{ nickname: { like: '%' + val + '%' } },
{ code: { like: `${val}%` } },
],
});
};
};
const exprBuilder = (param, value) => {
return {

View File

@ -2,22 +2,21 @@
import { ref, computed, markRaw } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import { toDate } from 'src/filters';
import RightMenu from 'src/components/common/RightMenu.vue';
import CustomerSummary from './Card/CustomerSummary.vue';
import CustomerFilter from './CustomerFilter.vue';
import VnTable from 'components/VnTable/VnTable.vue';
import VnLocation from 'src/components/common/VnLocation.vue';
import VnSearchbar from 'components/ui/VnSearchbar.vue';
import CustomerSummary from './Card/CustomerSummary.vue';
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import RightMenu from 'src/components/common/RightMenu.vue';
import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue';
import { toDate } from 'src/filters';
import CustomerFilter from './CustomerFilter.vue';
import VnSelectWorker from 'src/components/common/VnSelectWorker.vue';
const { t } = useI18n();
const router = useRouter();
const tableRef = ref();
const columns = computed(() => [
{
align: 'left',
@ -405,6 +404,7 @@ function handleLocation(data, location) {
ref="tableRef"
data-key="CustomerList"
url="Clients/filter"
order="id DESC"
:create="{
urlCreate: 'Clients/createWithUser',
title: t('globals.pageTitles.customerCreate'),
@ -414,11 +414,9 @@ function handleLocation(data, location) {
isEqualizated: false,
},
}"
order="id DESC"
:columns="columns"
redirect="customer"
:right-search="false"
auto-load
redirect="customer"
>
<template #more-create-dialog="{ data }">
<VnSelectWorker
@ -431,7 +429,26 @@ function handleLocation(data, location) {
:id-value="data.salesPersonFk"
emit-value
auto-load
>
<template #prepend>
<VnAvatar
:worker-id="data.salesPersonFk"
color="primary"
:title="title"
/>
</template>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{ scope.opt?.name }}</QItemLabel>
<QItemLabel caption
>{{ scope.opt?.nickname }},
{{ scope.opt?.code }}</QItemLabel
>
</QItemSection>
</QItem>
</template>
</VnSelectWorker>
<VnLocation
:acls="[{ model: 'Province', props: '*', accessType: 'WRITE' }]"
v-model="data.location"
@ -452,7 +469,7 @@ function handleLocation(data, location) {
</template>
<i18n>
es:
Web user: Usuario Web
Web user: Usuario web
</i18n>
<style lang="scss" scoped>
.col-content {

View File

@ -107,7 +107,7 @@ const setParams = (params) => {
const getPreview = async () => {
const params = {
recipientId: entityId,
recipientId: entityId.value,
};
const validationMessage = validateMessage();
if (validationMessage) return notify(t(validationMessage), 'negative');

View File

@ -52,7 +52,7 @@ const { t } = useI18n();
<VnSelectWorker
:label="t('department.bossDepartment')"
v-model="data.workerFk"
:rules="validate('department.workerFk')"
:rules="validate('department.bossDepartment')"
/>
<VnSelect
:label="t('department.selfConsumptionCustomer')"

View File

@ -1,8 +1,6 @@
<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { onMounted } from 'vue';
import { useStateStore } from 'stores/useStateStore';
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
@ -20,11 +18,6 @@ const props = defineProps({
const currenciesOptions = ref([]);
const companiesOptions = ref([]);
const stateStore = useStateStore();
onMounted(async () => {
stateStore.rightDrawer = true;
});
</script>
<template>

View File

@ -49,8 +49,10 @@ const columns = computed(() => [
align: 'left',
label: t('globals.id'),
name: 'id',
isTitle: true,
cardVisible: true,
isId: true,
chip: {
condition: () => true,
},
},
{
align: 'left',
@ -177,9 +179,6 @@ const columns = computed(() => [
],
},
]);
onMounted(async () => {
stateStore.rightDrawer = true;
});
</script>
<template>
<VnSearchbar
@ -207,7 +206,6 @@ onMounted(async () => {
order="id DESC"
:columns="columns"
redirect="entry"
auto-load
:right-search="false"
>
<template #column-status="{ row }">

View File

@ -116,6 +116,7 @@ function deleteFile(dmsFk) {
<template #form="{ data }">
<VnRow>
<VnSelect
:required="true"
:label="t('supplierFk')"
v-model="data.supplierFk"
option-value="id"
@ -244,6 +245,8 @@ function deleteFile(dmsFk) {
</VnRow>
<VnRow>
<VnSelect
:required="true"
:is-clearable="false"
:label="t('Currency')"
v-model="data.currencyFk"
:options="currencies"
@ -253,6 +256,8 @@ function deleteFile(dmsFk) {
/>
<VnSelect
:required="true"
:is-clearable="false"
v-if="companiesRef"
:label="t('Company')"
v-model="data.companyFk"

View File

@ -1,7 +1,6 @@
<script setup>
import { ref, computed, onMounted, onUnmounted } from 'vue';
import { ref, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { useStateStore } from 'stores/useStateStore';
import { useState } from 'src/composables/useState';
import { downloadFile } from 'src/composables/downloadFile';
import { toDate, toCurrency } from 'src/filters/index';
@ -17,14 +16,10 @@ import VnInput from 'src/components/common/VnInput.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue';
import FetchData from 'src/components/FetchData.vue';
const stateStore = useStateStore();
const user = useState().getUser();
const { viewSummary } = useSummaryDialog();
const { t } = useI18n();
onMounted(async () => (stateStore.rightDrawer = true));
onUnmounted(() => (stateStore.rightDrawer = false));
const tableRef = ref();
const companies = ref([]);
const cols = computed(() => [
@ -38,6 +33,10 @@ const cols = computed(() => [
align: 'left',
name: 'id',
label: 'Id',
isId: true,
chip: {
condition: () => true,
},
},
{
align: 'left',
@ -51,6 +50,7 @@ const cols = computed(() => [
},
},
columnClass: 'expand',
cardVisible: true,
},
{
align: 'left',
@ -81,6 +81,7 @@ const cols = computed(() => [
component: 'date',
},
format: (row, dashIfEmpty) => dashIfEmpty(toDate(row.dueDated)),
cardVisible: true,
},
{
align: 'left',
@ -92,6 +93,7 @@ const cols = computed(() => [
name: 'amount',
label: t('InvoiceIn.list.amount'),
format: ({ amount }) => toCurrency(amount),
cardVisible: true,
},
{
name: 'companyFk',
@ -114,6 +116,7 @@ const cols = computed(() => [
title: t('components.smartCard.openSummary'),
icon: 'preview',
type: 'submit',
isPrimary: true,
action: (row) => viewSummary(row.id, InvoiceInSummary),
},
{

View File

@ -1,5 +1,5 @@
<script setup>
import { onMounted, onUnmounted, ref, computed, watchEffect } from 'vue';
import { ref, computed, watchEffect } from 'vue';
import { useI18n } from 'vue-i18n';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue';
@ -10,7 +10,6 @@ import { usePrintService } from 'src/composables/usePrintService';
import VnTable from 'src/components/VnTable/VnTable.vue';
import InvoiceOutSummary from './Card/InvoiceOutSummary.vue';
import { toCurrency, toDate } from 'src/filters/index';
import { useStateStore } from 'stores/useStateStore';
import { QBtn } from 'quasar';
import axios from 'axios';
import RightMenu from 'src/components/common/RightMenu.vue';
@ -21,7 +20,6 @@ import VnInput from 'src/components/common/VnInput.vue';
import CustomerDescriptorProxy from '../Customer/Card/CustomerDescriptorProxy.vue';
const { t } = useI18n();
const stateStore = useStateStore();
const { viewSummary } = useSummaryDialog();
const tableRef = ref();
const invoiceOutSerialsOptions = ref([]);
@ -147,8 +145,6 @@ const columns = computed(() => [
],
},
]);
onMounted(() => (stateStore.rightDrawer = true));
onUnmounted(() => (stateStore.rightDrawer = false));
function openPdf(id) {
openReport(`${MODEL}/${id}/download`);
@ -214,7 +210,6 @@ watchEffect(selectedRows);
order="id DESC"
:columns="columns"
redirect="invoice-out"
auto-load
:table="{
'row-key': 'id',
selection: 'multiple',

View File

@ -466,7 +466,7 @@ function handleOnDataSave({ CrudModelRef }) {
</span>
<span class="subName">{{ row.subName }}</span>
<ItemDescriptorProxy :id="row.itemFk" />
<FetchedTags :item="row" />
<FetchedTags :item="row" :columns="3" />
</template>
<template #column-rate2="props">
<QTd class="col">

View File

@ -32,7 +32,7 @@ const itemTypeWorkersOptions = ref([]);
<QItem class="q-my-md">
<QItemSection>
<VnSelect
:label="t('components.itemsFilterPanel.buyerFk')"
:label="t('params.buyerFk')"
v-model="params.buyerFk"
:options="itemTypeWorkersOptions"
option-value="id"
@ -51,7 +51,7 @@ const itemTypeWorkersOptions = ref([]);
url="Warehouses"
auto-load
:filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }"
:label="t('globals.warehouse')"
:label="t('params.warehouseFk')"
v-model="params.warehouseFk"
option-label="name"
option-value="id"
@ -66,7 +66,7 @@ const itemTypeWorkersOptions = ref([]);
<QItem class="q-my-md">
<QItemSection>
<VnInputDate
:label="t('components.itemsFilterPanel.started')"
:label="t('params.started')"
v-model="params.started"
is-outlined
@update:model-value="searchFn()"
@ -76,7 +76,7 @@ const itemTypeWorkersOptions = ref([]);
<QItem class="q-my-md">
<QItemSection>
<VnInputDate
:label="t('components.itemsFilterPanel.ended')"
:label="t('params.ended')"
v-model="params.ended"
is-outlined
@update:model-value="searchFn()"
@ -86,7 +86,7 @@ const itemTypeWorkersOptions = ref([]);
<QItem>
<QItemSection>
<QCheckbox
:label="t('components.itemsFilterPanel.mine')"
:label="t('params.mine')"
v-model="params.mine"
toggle-indeterminate
@update:model-value="searchFn()"
@ -94,14 +94,14 @@ const itemTypeWorkersOptions = ref([]);
<QCheckbox
v-model="params.showBadDates"
:label="t(`components.itemsFilterPanel.showBadDates`)"
:label="t(`params.showBadDates`)"
toggle-indeterminate
@update:model-value="searchFn()"
>
</QCheckbox>
<QCheckbox
:label="t('components.itemsFilterPanel.hasMinPrice')"
:label="t('params.hasMinPrice')"
v-model="params.hasMinPrice"
toggle-indeterminate
@update:model-value="searchFn()"
@ -111,3 +111,23 @@ const itemTypeWorkersOptions = ref([]);
</template>
</ItemsFilterPanel>
</template>
<i18n>
en:
params:
buyerFk: Buyer
warehouseFk: Warehouse
started: Started
ended: Ended
mine: Mine
showBadDates: Show future items
hasMinPrice: Has Min Price
es:
params:
buyerFk: Comprador
warehouseFk: Almacén
started: Desde
ended: Hasta
mine: Para mi
showBadDates: Ver items a futuro
hasMinPrice: Precio mínimo
</i18n>

View File

@ -11,6 +11,7 @@ import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import ItemSummary from '../Item/Card/ItemSummary.vue';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import ItemDescriptorProxy from './Card/ItemDescriptorProxy.vue';
import ItemTypeDescriptorProxy from './ItemType/Card/ItemTypeDescriptorProxy.vue';
import { cloneItem } from 'src/pages/Item/composables/cloneItem';
import RightMenu from 'src/components/common/RightMenu.vue';
import ItemListFilter from './ItemListFilter.vue';
@ -56,7 +57,6 @@ const columns = computed(() => [
name: 'image',
align: 'left',
columnFilter: false,
cardVisible: true,
},
{
label: t('item.list.id'),
@ -94,7 +94,7 @@ const columns = computed(() => [
columnFilter: {
name: 'search',
},
cardVisible: true,
columnClass: 'expand',
},
{
label: t('item.list.stems'),
@ -132,10 +132,13 @@ const columns = computed(() => [
fields: ['id', 'name'],
},
},
columnField: {
component: null,
},
create: true,
visible: false,
},
{
label: t('item.list.typeName'),
name: 'typeName',
align: 'left',
},
{
label: t('item.list.category'),
@ -220,7 +223,6 @@ const columns = computed(() => [
label: t('item.list.weight'),
toolTip: t('item.list.weightByPiece'),
name: 'weightByPiece',
align: 'left',
component: 'input',
columnField: {
component: null,
@ -296,7 +298,6 @@ const columns = computed(() => [
},
]);
</script>
<template>
<VnSearchbar
data-key="ItemList"
@ -341,6 +342,13 @@ const columns = computed(() => [
<ItemDescriptorProxy :id="row.id" />
</span>
</template>
<template #column-typeName="{ row }">
<span class="link" @click.stop>
{{ row.typeName }}
{{ row.typeFk }}
<ItemTypeDescriptorProxy :id="row.typeFk" />
</span>
</template>
<template #column-userName="{ row }">
<span class="link" @click.stop>
{{ row.userName }}
@ -354,15 +362,15 @@ const columns = computed(() => [
{{ row?.subName.toUpperCase() }}
</div>
</div>
<FetchedTags :item="row" :max-length="6" />
<FetchedTags :item="row" :columns="3" />
</template>
</VnTable>
</template>
<style lang="scss" scoped>
.subName {
text-transform: uppercase;
color: var(--vn-label-color);
font-size: small;
}
</style>
<i18n>

View File

@ -6,13 +6,11 @@ import { useI18n } from 'vue-i18n';
import CardDescriptor from 'components/ui/CardDescriptor.vue';
import VnLv from 'src/components/ui/VnLv.vue';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import useCardDescription from 'src/composables/useCardDescription';
const $props = defineProps({
id: {
type: Number,
required: false,
default: null,
},
summary: {
@ -24,6 +22,10 @@ const $props = defineProps({
const route = useRoute();
const { t } = useI18n();
const entityId = computed(() => {
return $props.id || route.params.id;
});
const itemTypeFilter = {
include: [
{ relation: 'worker' },
@ -33,10 +35,6 @@ const itemTypeFilter = {
],
};
const entityId = computed(() => {
return $props.id || route.params.id;
});
const data = ref(useCardDescription());
const setData = (entity) => (data.value = useCardDescription(entity.code, entity.id));
</script>
@ -48,8 +46,8 @@ const setData = (entity) => (data.value = useCardDescription(entity.code, entity
:filter="itemTypeFilter"
:title="data.title"
:subtitle="data.subtitle"
data-key="itemTypeDescriptor"
@on-fetch="setData"
data-key="entry"
>
<template #body="{ entity }">
<VnLv :label="t('shared.code')" :value="entity.code" />

View File

@ -0,0 +1,17 @@
<script setup>
import ItemTypeDescriptor from './ItemTypeDescriptor.vue';
import ItemTypeSummary from './ItemTypeSummary.vue';
const $props = defineProps({
id: {
type: Number,
required: true,
},
});
</script>
<template>
<QPopupProxy>
<ItemTypeDescriptor v-if="$props.id" :id="$props.id" :summary="ItemTypeSummary" />
</QPopupProxy>
</template>

View File

@ -135,7 +135,7 @@ item:
origin: Orig.
userName: Buyer
weight: Weight
weightByPiece: Weight/Piece
weightByPiece: Weight/stem
stemMultiplier: Multiplier
producer: Producer
landed: Landed

View File

@ -136,7 +136,7 @@ item:
size: Medida
origin: Orig.
weight: Peso
weightByPiece: Peso (gramos)/tallo
weightByPiece: Peso/tallo
userName: Comprador
stemMultiplier: Multiplicador
producer: Productor

View File

@ -281,6 +281,7 @@ en:
problems: With problems
pending: Pending
alertLevel: Grouped State
department: Department
FREE: Free
DELIVERED: Delivered
ON_PREPARATION: On preparation
@ -300,6 +301,7 @@ es:
problems: Con problemas
pending: Pendiente
alertLevel: Estado agrupado
department: Departamento
FREE: Libre
DELIVERED: Servido
ON_PREPARATION: En preparación

View File

@ -86,6 +86,7 @@ watch(
url="Orders/CatalogFilter"
:label="t('Search items')"
:info="t('You can search items by name or id')"
:search-remove-params="false"
/>
<Teleport to="#right-panel" v-if="stateStore.isHeaderMounted()">
<OrderCatalogFilter

View File

@ -71,9 +71,11 @@ onMounted(async () => (stateStore.rightDrawer = false));
auto-load
/>
<QCard v-if="volumeSummary" class="order-volume-summary q-pa-lg">
<VnLv :label="t('total')" :value="`${volumeSummary?.totalVolume} m³`" />
<VnLv
:label="t('boxes')"
:label="`${t('total')}: `"
:value="`${volumeSummary?.totalVolume} m³`" />
<VnLv
:label="`${t('boxes')}: `"
:value="`${dashIfEmpty(volumeSummary?.totalBoxes)} U`"
/>
</QCard>
@ -111,12 +113,12 @@ onMounted(async () => (stateStore.rightDrawer = false));
</VnTable>
</template>
<style lang="scss">
<style lang="scss" scoped>
.order-volume-summary {
.vn-label-value {
display: flex;
justify-content: flex-end;
gap: 2%;
gap: 0.5%;
.label {
color: var(--vn-label-color);

View File

@ -1,20 +1,22 @@
<script setup>
import axios from 'axios';
import { useI18n } from 'vue-i18n';
import { computed, ref, onMounted } from 'vue';
import { dashIfEmpty, toCurrency, toDate } from 'src/filters';
import OrderSummary from 'pages/Order/Card/OrderSummary.vue';
import { toDateTimeFormat } from 'src/filters/date';
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import { useRoute } from 'vue-router';
import axios from 'axios';
import OrderSummary from 'pages/Order/Card/OrderSummary.vue';
import OrderSearchbar from './Card/OrderSearchbar.vue';
import OrderFilter from './Card/OrderFilter.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import CustomerDescriptorProxy from '../Customer/Card/CustomerDescriptorProxy.vue';
import WorkerDescriptorProxy from '../Worker/Card/WorkerDescriptorProxy.vue';
import VnTable from 'src/components/VnTable/VnTable.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import OrderSearchbar from './Card/OrderSearchbar.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import OrderFilter from './Card/OrderFilter.vue';
import CustomerDescriptorProxy from '../Customer/Card/CustomerDescriptorProxy.vue';
import WorkerDescriptorProxy from '../Worker/Card/WorkerDescriptorProxy.vue';
import { toDateTimeFormat } from 'src/filters/date';
import { useRoute } from 'vue-router';
const { t } = useI18n();
const { viewSummary } = useSummaryDialog();
@ -171,9 +173,9 @@ const getDateColor = (date) => {
today.setHours(0, 0, 0, 0);
const timeTicket = new Date(date);
timeTicket.setHours(0, 0, 0, 0);
const comparation = today - timeTicket;
if (comparation == 0) return 'bg-warning';
if (comparation < 0) return 'bg-success';
const difference = today - timeTicket;
if (difference == 0) return 'bg-warning';
if (difference < 0) return 'bg-success';
};
</script>
<template>
@ -201,8 +203,8 @@ const getDateColor = (date) => {
},
}"
:user-params="{ showEmpty: false }"
:right-search="false"
:columns="columns"
:right-search="false"
redirect="order"
>
<template #column-clientFk="{ row }">

View File

@ -26,7 +26,7 @@ const routeFilter = {
};
const columns = computed(() => [
{
align: 'left',
align: 'right',
isId: true,
name: 'id',
label: 'Id',

View File

@ -43,7 +43,7 @@ const filter = {
data-key="ShelvingSummary"
>
<template #header="{ entity }">
<div>{{ entity.code }}</div>
<div>{{ entity.id }} - {{ entity.code }}</div>
</template>
<template #body="{ entity }">
<QCard class="vn-one">

View File

@ -1,8 +1,6 @@
<script setup>
import VnPaginate from 'components/ui/VnPaginate.vue';
import { useStateStore } from 'stores/useStateStore';
import { useI18n } from 'vue-i18n';
import { onMounted } from 'vue';
import CardList from 'components/ui/CardList.vue';
import VnLv from 'components/ui/VnLv.vue';
import { useRouter } from 'vue-router';
@ -12,7 +10,6 @@ import ShelvingSearchbar from 'pages/Shelving/Card/ShelvingSearchbar.vue';
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import RightMenu from 'src/components/common/RightMenu.vue';
const stateStore = useStateStore();
const router = useRouter();
const { t } = useI18n();
const { viewSummary } = useSummaryDialog();
@ -20,8 +17,6 @@ const filter = {
include: [{ relation: 'parking' }],
};
onMounted(() => (stateStore.rightDrawer = true));
function navigate(id) {
router.push({ path: `/shelving/${id}` });
}

View File

@ -14,10 +14,10 @@ import axios from 'axios';
import useNotify from 'src/composables/useNotify.js';
import { useQuasar } from 'quasar';
const quasar = useQuasar();
const { notify } = useNotify();
const route = useRoute();
const { t } = useI18n();
const { notify } = useNotify();
const quasar = useQuasar();
const route = useRoute();
const bankEntitiesRef = ref(null);
const supplier = ref(null);

View File

@ -6,9 +6,11 @@ import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnSelectWorker from 'src/components/common/VnSelectWorker.vue';
import { useArrayData } from 'src/composables/useArrayData';
const route = useRoute();
const { t } = useI18n();
const arrayData = useArrayData();
const companySizes = [
{ id: 'small', name: t('globals.small'), size: '1-5' },
{ id: 'medium', name: t('globals.medium'), size: '6-50' },
@ -22,6 +24,7 @@ const companySizes = [
model="supplier"
auto-load
:clear-store-on-unmount="false"
@on-data-saved="arrayData.fetch({})"
>
<template #form="{ data, validate }">
<VnRow>

View File

@ -9,7 +9,7 @@ import VnLv from 'src/components/ui/VnLv.vue';
import { toDateString } from 'src/filters';
import useCardDescription from 'src/composables/useCardDescription';
import { getUrl } from 'src/composables/getUrl';
import { useState } from 'src/composables/useState';
import { useArrayData } from 'src/composables/useArrayData';
const $props = defineProps({
id: {
@ -26,7 +26,7 @@ const $props = defineProps({
const route = useRoute();
const { t } = useI18n();
const url = ref();
const state = useState();
const arrayData = useArrayData();
const filter = {
fields: [
@ -77,7 +77,7 @@ const setData = (entity) => {
data.value = useCardDescription(entity.ref, entity.id);
};
const supplier = computed(() => state.get('supplier'));
const supplier = computed(() => arrayData.store.data);
const getEntryQueryParams = (supplier) => {
if (!supplier) return null;

View File

@ -41,7 +41,7 @@ const getUrl = (section) => `#/supplier/${entityId.value}/${section}`;
data-key="SupplierSummary"
>
<template #header>
<span>{{ supplier.name }} - {{ supplier.id }}</span>
<span>{{ supplier.id }} - {{ supplier.name }}</span>
</template>
<template #body>

Some files were not shown because too many files have changed in this diff Show More