Skip to content

Commit

Permalink
fix paging
Browse files Browse the repository at this point in the history
  • Loading branch information
web2solutions committed Aug 16, 2023
1 parent cc6ea0b commit a159fb3
Show file tree
Hide file tree
Showing 8 changed files with 173 additions and 8 deletions.
28 changes: 26 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "domain-designer",
"version": "0.0.1",
"version": "0.0.2",
"private": true,
"scripts": {
"dev": "vite",
Expand All @@ -25,6 +25,7 @@
"vue-router": "^4.2.4"
},
"devDependencies": {
"@faker-js/faker": "^8.0.2",
"@rushstack/eslint-patch": "^1.3.2",
"@tsconfig/node18": "^18.2.0",
"@types/jsdom": "^21.1.1",
Expand Down
42 changes: 40 additions & 2 deletions src/components/Application/NavBarMain.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
<script setup lang="ts">
import { faker } from '@faker-js/faker';
import { useLanguageStore, useSessionStore, session } from '@/stores';
const languageStore: any = useLanguageStore();
const sessionStore: any = useSessionStore()
// console.log(languageStore.default.application, languageStore.language)
const sessionStore: any = useSessionStore();
import { domainsData } from'@/stores/domains';
import { entitiesData } from'@/stores/entities';
import type { IDomainCreateDTO } from '@/models/IDomainCreateDTO';
import { useDomainsStore } from '@/stores';
import { useEntitiesStore } from '@/stores';
const domainStore = useDomainsStore();
const entityStore = useEntitiesStore();
function createRandomDomain(): IDomainCreateDTO {
return {
name: faker.commerce.department(),
description: faker.lorem.lines(2),
};
}
function onClickLanguage (e: Event) {
e.stopPropagation();
Expand All @@ -13,6 +33,18 @@ function onClickLanguage (e: Event) {
sessionStore.setLanguage(target.innerText)
}
async function AddInitialData(e: any) {
e.stopPropagation();
e.preventDefault();
for(const domain of domainsData) {
await domainStore.create(domain);
}
for(const entity of entitiesData as any) {
entity.domain_id = domainStore.records[0].id
await entityStore.create(entity);
}
}
</script>

<template>
Expand Down Expand Up @@ -67,6 +99,12 @@ function onClickLanguage (e: Event) {
<span class="icon"><i class="mdi mdi-chevron-down"></i></span>
</a>
<div class="navbar-dropdown">
<a @click="AddInitialData($event)"
class="navbar-item">
<span class="icon"><i class="mdi mdi-email"></i></span>
<span>{{ languageStore.default.application.AddInitialData }}</span>
</a>
<hr class="navbar-divider">
<router-link to="/profile" class="navbar-item">
<span class="icon"><i class="mdi mdi-account"></i></span>
<span>{{ languageStore.default.application.MyProfile }}</span>
Expand Down
5 changes: 3 additions & 2 deletions src/components/CRUD/CrudListTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const props = defineProps<{
}>()
const route = useRoute();
console.log(router.currentRoute)
function onChangePageSize (size: number) {
// const id = route.params.id ? route.params.id.toString() : undefined;
Expand All @@ -22,7 +23,7 @@ function onChangePageSize (size: number) {
// if (previousFilter) query.filters = previousFilter
if (previousPage) query.page = previousPage;
console.log('onChangePageSize', query)
router.push({ path: '/domains/list', query: query as LocationQueryRaw })
router.push({ path: router.currentRoute.value.fullPath, query: query as LocationQueryRaw })
}
function onChangePageNumber (page: number) {
Expand All @@ -37,7 +38,7 @@ function onChangePageNumber (page: number) {
if (previousSize) query.size = previousSize;
console.log('onChangePageNumber', query)
props.store.changePage(page)
router.push({ path: '/domains/list', query: query as LocationQueryRaw })
router.push({ path: router.currentRoute.value.fullPath, query: query as LocationQueryRaw })
}
</script>
<template>
Expand Down
14 changes: 14 additions & 0 deletions src/stores/domains.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const domainsData = [
{
name: 'Products',
description: 'Products Management',
},
{
name: 'Services',
description: 'Services Management',
},
{
name: 'Staff',
description: 'Staff Management',
},
]
2 changes: 1 addition & 1 deletion src/stores/entities.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const useEntitiesStore = defineStore({
type: 'string',
},
{
name: 'domain',
name: 'domain_id',
label: 'Domain',
type: 'string',
},
Expand Down
85 changes: 85 additions & 0 deletions src/stores/entities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
export const entitiesData = [{
name: 'Clothing',
description: 'Minima rerum voluptates deserunt.\nDistinctio molestias ducimus commodi dicta illo veniam animi.'
},
{
name: 'Beauty',
description: 'Deserunt incidunt vero itaque quae repellat quibus…electus.\nEveniet ipsum qui nulla accusantium sit.'
},
{
name: 'Movies',
description: 'Omnis magni deserunt.\nBlanditiis debitis neque pro…ent architecto eligendi quia harum doloribus nam.'
},
{
name: 'Garden',
description: 'Qui nisi voluptas quis dolor ipsum officia cupidit…squam recusandae deleniti error ipsum alias iure.'
},
{
name: 'Kids',
description: 'Consequuntur modi veritatis occaecati qui dolore e…ndi libero exercitationem quo impedit distinctio.'
},
{
name: 'Sports',
description: 'Quae dolor temporibus sint dolores.\nMollitia natus quo officia eos pariatur eos facere veritatis.'
},
{
name: 'Automotive',
description: 'Omnis id eveniet nostrum optio voluptatibus soluta…sunt voluptatum doloremque pariatur nobis beatae.'
},
{
name: 'Baby',
description: 'Autem mollitia repellat voluptatem nesciunt iste a…da.\nPossimus mollitia adipisci eius itaque atque.'
},
{
name: 'Electronics',
description: 'Est cupiditate aperiam praesentium velit eveniet e…tam modi saepe asperiores accusantium enim ullam.'
},
{
name: 'Home',
description: 'Fugit eum nesciunt doloribus maxime.\nProvident dol…es tempora ipsum nobis rerum aut voluptate harum.'
},
{
name: 'Computers',
description: 'Saepe cumque aliquid error consequatur odit aut.\nE…anditiis voluptatem dolorem rem voluptates dicta.'
},
{
name: 'Music',
description: 'Inventore fugit sunt quisquam natus fugiat distinc…m velit omnis praesentium minus numquam officiis.'
},
{
name: 'Toys',
description: 'Eos facere veniam.\nLaudantium sit ullam est harum ducimus tempora.'
},
{
name: 'Tools',
description: 'Asperiores iusto quod culpa in rerum distinctio nostrum expedita.\nEx dicta voluptate.'
},
{
name: 'Health',
description: 'Nobis quaerat ipsam.\nNam quibusdam soluta mollitia facere iure.'
},
{
name: 'Games',
description: 'Excepturi temporibus eligendi saepe quos labore.\nE…ratione est distinctio deserunt laboriosam rerum.'
},
{
name: 'Jewelery',
description: 'Vel quae rem provident quia.\nUnde reprehenderit cum unde eius vel exercitationem.'
},
{
name: 'Shoes',
description: 'Est corporis placeat tempora nisi possimus.\nDicta repellat odit possimus optio vero.'
},
{
name: 'Grocery',
description: 'Libero rerum doloribus quasi debitis dolorem ad ne…pariatur optio iure maiores aspernatur accusamus.'
},
{
name: 'Outdoors',
description: 'Ut molestiae at quaerat consectetur debitis cum.\nAutem beatae quisquam a vitae excepturi eaque non.'
},
{
name: 'Books',
description: 'Alias soluta cupiditate soluta iure veritatis quib…m voluptatum deserunt dolores excepturi voluptas.'
},
]
2 changes: 2 additions & 0 deletions src/stores/language.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const enUS: Record<string, any> = {
Home: 'Home',
Dashboard: 'Dashboard',
Applications: 'Applications',
AddInitialData: 'Add Demo Data',
},
dashboard: {
Customers: 'Customers',
Expand All @@ -30,6 +31,7 @@ const ptBR: Record<string, any> = {
Home: 'Início',
Dashboard: 'Dashboard',
Applications: 'Aplicações',
AddInitialData: 'Adicionar Demo Data',
},
dashboard: {
Customers: 'Clientes',
Expand Down

0 comments on commit a159fb3

Please sign in to comment.