2022-03-16 11:42:06 +00:00
|
|
|
import ChartOfAccounts from '@/pages/ChartOfAccounts.vue';
|
|
|
|
import Dashboard from '@/pages/Dashboard/Dashboard.vue';
|
|
|
|
import DataImport from '@/pages/DataImport.vue';
|
|
|
|
import GetStarted from '@/pages/GetStarted.vue';
|
|
|
|
import InvoiceForm from '@/pages/InvoiceForm.vue';
|
|
|
|
import JournalEntryForm from '@/pages/JournalEntryForm.vue';
|
|
|
|
import ListView from '@/pages/ListView/ListView.vue';
|
|
|
|
import PrintView from '@/pages/PrintView/PrintView.vue';
|
|
|
|
import QuickEditForm from '@/pages/QuickEditForm.vue';
|
|
|
|
import Report from '@/pages/Report.vue';
|
|
|
|
import Settings from '@/pages/Settings/Settings.vue';
|
2022-02-10 06:41:51 +00:00
|
|
|
import { createRouter, createWebHistory } from 'vue-router';
|
2022-04-18 11:29:20 +00:00
|
|
|
import telemetry from '../frappe/telemetry/telemetry';
|
|
|
|
import { NounEnum, Verb } from '../frappe/telemetry/types';
|
2018-06-27 14:36:42 +00:00
|
|
|
|
2018-10-10 18:51:03 +00:00
|
|
|
const routes = [
|
2019-07-25 09:50:48 +00:00
|
|
|
{
|
|
|
|
path: '/',
|
2021-11-24 09:08:13 +00:00
|
|
|
component: Dashboard,
|
2019-07-25 09:50:48 +00:00
|
|
|
},
|
2019-12-21 14:46:50 +00:00
|
|
|
{
|
|
|
|
path: '/get-started',
|
2021-11-24 09:08:13 +00:00
|
|
|
component: GetStarted,
|
2019-12-21 14:46:50 +00:00
|
|
|
},
|
2019-11-19 19:10:01 +00:00
|
|
|
{
|
|
|
|
path: '/edit/JournalEntry/:name',
|
|
|
|
name: 'JournalEntryForm',
|
|
|
|
components: {
|
|
|
|
default: JournalEntryForm,
|
2021-11-24 09:08:13 +00:00
|
|
|
edit: QuickEditForm,
|
2019-11-19 19:10:01 +00:00
|
|
|
},
|
|
|
|
props: {
|
2021-11-24 09:08:13 +00:00
|
|
|
default: (route) => {
|
2019-12-21 14:46:50 +00:00
|
|
|
// for sidebar item active state
|
|
|
|
route.params.doctype = 'JournalEntry';
|
|
|
|
return {
|
|
|
|
doctype: 'JournalEntry',
|
2021-11-24 09:08:13 +00:00
|
|
|
name: route.params.name,
|
2019-12-21 14:46:50 +00:00
|
|
|
};
|
|
|
|
},
|
2021-11-24 09:08:13 +00:00
|
|
|
edit: (route) => route.query,
|
|
|
|
},
|
2019-11-19 19:10:01 +00:00
|
|
|
},
|
2018-06-27 14:36:42 +00:00
|
|
|
{
|
2019-10-13 21:56:20 +00:00
|
|
|
path: '/edit/:doctype/:name',
|
2019-10-11 09:55:50 +00:00
|
|
|
name: 'InvoiceForm',
|
|
|
|
components: {
|
|
|
|
default: InvoiceForm,
|
2021-11-24 09:08:13 +00:00
|
|
|
edit: QuickEditForm,
|
2019-10-11 09:55:50 +00:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
default: true,
|
2021-11-24 09:08:13 +00:00
|
|
|
edit: (route) => route.query,
|
|
|
|
},
|
2019-10-11 09:55:50 +00:00
|
|
|
},
|
|
|
|
{
|
2022-03-10 06:36:37 +00:00
|
|
|
path: '/list/:doctype/:fieldname?/:value?',
|
2018-10-10 18:51:03 +00:00
|
|
|
name: 'ListView',
|
2019-10-11 09:55:50 +00:00
|
|
|
components: {
|
|
|
|
default: ListView,
|
2021-11-24 09:08:13 +00:00
|
|
|
edit: QuickEditForm,
|
2019-10-04 20:18:10 +00:00
|
|
|
},
|
2019-10-11 09:55:50 +00:00
|
|
|
props: {
|
2021-11-24 09:08:13 +00:00
|
|
|
default: (route) => {
|
2022-03-10 06:36:37 +00:00
|
|
|
let { doctype, filters, fieldname, value } = route.params;
|
|
|
|
if (filters === undefined && fieldname && value) {
|
|
|
|
filters = { [fieldname]: value };
|
|
|
|
}
|
|
|
|
|
2019-10-11 09:55:50 +00:00
|
|
|
return {
|
|
|
|
doctype,
|
2021-11-24 09:08:13 +00:00
|
|
|
filters,
|
2019-10-11 09:55:50 +00:00
|
|
|
};
|
|
|
|
},
|
2021-11-24 09:08:13 +00:00
|
|
|
edit: (route) => route.query,
|
|
|
|
},
|
2018-06-27 14:36:42 +00:00
|
|
|
},
|
2018-10-15 12:05:01 +00:00
|
|
|
{
|
|
|
|
path: '/print/:doctype/:name',
|
|
|
|
name: 'PrintView',
|
|
|
|
component: PrintView,
|
2021-11-24 09:08:13 +00:00
|
|
|
props: true,
|
2018-10-22 18:10:22 +00:00
|
|
|
},
|
2018-06-27 14:36:42 +00:00
|
|
|
{
|
|
|
|
path: '/report/:reportName',
|
|
|
|
name: 'Report',
|
|
|
|
component: Report,
|
2021-11-24 09:08:13 +00:00
|
|
|
props: true,
|
2018-10-10 10:32:56 +00:00
|
|
|
},
|
2019-02-18 05:42:04 +00:00
|
|
|
{
|
2019-12-23 08:26:41 +00:00
|
|
|
path: '/chart-of-accounts',
|
2019-02-18 05:42:04 +00:00
|
|
|
name: 'Chart Of Accounts',
|
2019-10-13 21:18:18 +00:00
|
|
|
components: {
|
|
|
|
default: ChartOfAccounts,
|
2021-11-24 09:08:13 +00:00
|
|
|
edit: QuickEditForm,
|
2019-10-13 21:18:18 +00:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
default: true,
|
2021-11-24 09:08:13 +00:00
|
|
|
edit: (route) => route.query,
|
|
|
|
},
|
|
|
|
},
|
2022-02-21 10:56:57 +00:00
|
|
|
{
|
|
|
|
path: '/data_import',
|
|
|
|
name: 'Data Import',
|
|
|
|
component: DataImport,
|
|
|
|
},
|
2021-11-24 09:08:13 +00:00
|
|
|
{
|
|
|
|
path: '/settings',
|
|
|
|
name: 'Settings',
|
|
|
|
component: Settings,
|
|
|
|
props: true,
|
|
|
|
},
|
2018-10-10 18:51:03 +00:00
|
|
|
];
|
2018-06-27 14:36:42 +00:00
|
|
|
|
2022-02-10 06:41:51 +00:00
|
|
|
let router = createRouter({ routes, history: createWebHistory() });
|
2019-10-03 13:46:12 +00:00
|
|
|
|
2022-03-11 06:14:38 +00:00
|
|
|
function removeDetails(path) {
|
|
|
|
if (!path) {
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
const match = path.match(/edit=1/);
|
|
|
|
if (!match) {
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
return path.slice(0, match.index + 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
router.afterEach((to, from) => {
|
|
|
|
const more = {
|
|
|
|
from: removeDetails(from.fullPath),
|
|
|
|
to: removeDetails(to.fullPath),
|
|
|
|
};
|
|
|
|
|
2022-03-09 10:48:26 +00:00
|
|
|
telemetry.log(Verb.Navigated, NounEnum.Route, more);
|
|
|
|
});
|
|
|
|
|
2019-10-26 14:46:04 +00:00
|
|
|
if (process.env.NODE_ENV === 'development') {
|
2019-11-19 19:10:01 +00:00
|
|
|
window.router = router;
|
2019-10-26 14:46:04 +00:00
|
|
|
}
|
|
|
|
|
2019-10-03 13:46:12 +00:00
|
|
|
export default router;
|