mirror of
https://github.com/frappe/books.git
synced 2024-12-24 20:00:29 +00:00
e008028b14
- temporarily disable filters
137 lines
3.2 KiB
TypeScript
137 lines
3.2 KiB
TypeScript
import { ModelNameEnum } from 'models/types';
|
|
import ChartOfAccounts from 'src/pages/ChartOfAccounts.vue';
|
|
import Dashboard from 'src/pages/Dashboard/Dashboard.vue';
|
|
import DataImport from 'src/pages/DataImport.vue';
|
|
import GetStarted from 'src/pages/GetStarted.vue';
|
|
import InvoiceForm from 'src/pages/InvoiceForm.vue';
|
|
import JournalEntryForm from 'src/pages/JournalEntryForm.vue';
|
|
import ListView from 'src/pages/ListView/ListView.vue';
|
|
import PrintView from 'src/pages/PrintView/PrintView.vue';
|
|
import QuickEditForm from 'src/pages/QuickEditForm.vue';
|
|
import Report from 'src/pages/Report.vue';
|
|
import Settings from 'src/pages/Settings/Settings.vue';
|
|
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
|
|
|
|
const routes: RouteRecordRaw[] = [
|
|
{
|
|
path: '/',
|
|
component: Dashboard,
|
|
},
|
|
{
|
|
path: '/get-started',
|
|
component: GetStarted,
|
|
},
|
|
{
|
|
path: '/edit/JournalEntry/:name',
|
|
name: 'JournalEntryForm',
|
|
components: {
|
|
default: JournalEntryForm,
|
|
edit: QuickEditForm,
|
|
},
|
|
props: {
|
|
default: (route) => {
|
|
// for sidebar item active state
|
|
route.params.schemaName = 'JournalEntry';
|
|
return {
|
|
schemaName: 'JournalEntry',
|
|
name: route.params.name,
|
|
};
|
|
},
|
|
edit: (route) => route.query,
|
|
},
|
|
},
|
|
{
|
|
path: '/edit/:schemaName/:name',
|
|
name: 'InvoiceForm',
|
|
components: {
|
|
default: InvoiceForm,
|
|
edit: QuickEditForm,
|
|
},
|
|
props: {
|
|
default: true,
|
|
edit: (route) => route.query,
|
|
},
|
|
},
|
|
{
|
|
path: '/list/:schemaName/:fieldname?/:value?/:pageTitle?',
|
|
name: 'ListView',
|
|
components: {
|
|
default: ListView,
|
|
edit: QuickEditForm,
|
|
},
|
|
props: {
|
|
default: (route) => {
|
|
const { schemaName, fieldname, value, pageTitle } = route.params;
|
|
let { filters } = route.params;
|
|
|
|
if (filters === undefined && fieldname && value) {
|
|
// @ts-ignore
|
|
filters = { [fieldname as string]: value };
|
|
}
|
|
|
|
return {
|
|
schemaName,
|
|
filters,
|
|
pageTitle: pageTitle ?? '',
|
|
};
|
|
},
|
|
edit: (route) => {
|
|
return route.query;
|
|
},
|
|
},
|
|
},
|
|
{
|
|
path: '/print/:schemaName/:name',
|
|
name: 'PrintView',
|
|
component: PrintView,
|
|
props: true,
|
|
},
|
|
{
|
|
path: '/report/:reportClassName',
|
|
name: 'Report',
|
|
component: Report,
|
|
props: true,
|
|
},
|
|
{
|
|
path: '/chart-of-accounts',
|
|
name: 'Chart Of Accounts',
|
|
components: {
|
|
default: ChartOfAccounts,
|
|
edit: QuickEditForm,
|
|
},
|
|
props: {
|
|
default: true,
|
|
edit: (route) => route.query,
|
|
},
|
|
},
|
|
{
|
|
path: '/data-import',
|
|
name: 'Data Import',
|
|
component: DataImport,
|
|
},
|
|
{
|
|
path: '/settings',
|
|
name: 'Settings',
|
|
component: Settings,
|
|
props: true,
|
|
},
|
|
];
|
|
|
|
export function getEntryRoute(schemaName: string, name: string) {
|
|
if (
|
|
[
|
|
ModelNameEnum.SalesInvoice,
|
|
ModelNameEnum.PurchaseInvoice,
|
|
ModelNameEnum.JournalEntry,
|
|
].includes(schemaName as ModelNameEnum)
|
|
) {
|
|
return `/edit/${schemaName}/${name}`;
|
|
}
|
|
|
|
return `/list/${schemaName}?edit=1&schemaName=${schemaName}&name=${name}`;
|
|
}
|
|
|
|
const router = createRouter({ routes, history: createWebHistory() });
|
|
|
|
export default router;
|