2
0
mirror of https://github.com/frappe/books.git synced 2024-09-20 03:29:00 +00:00

Merge pull request #251 from piyushsinghania/fix/error-message-while-navigating

Prevented error message on navigation
This commit is contained in:
Alan 2021-11-23 10:35:01 +05:30 committed by GitHub
commit 50371b1a56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 46 additions and 45 deletions

View File

@ -52,6 +52,7 @@
<script>
import frappe from 'frappejs';
import { getStatusColumn } from '../Transaction/Transaction';
import { routeTo } from '@/utils';
export default {
name: 'PartyWidget',
@ -99,7 +100,7 @@ export default {
return statusColumn.render(doc);
},
routeToForm(doc) {
this.$router.push(`/edit/${this.invoiceDoctype}/${doc.name}`);
routeTo(`/edit/${this.invoiceDoctype}/${doc.name}`);
},
fullyPaid(invoice) {
return invoice.outstandingAmount == 0;

View File

@ -1,6 +1,6 @@
import frappe from 'frappejs';
import utils from '../../../accounting/utils';
import { openQuickEdit, getInvoiceStatus, statusColor } from '@/utils';
import { openQuickEdit, getInvoiceStatus, statusColor, routeTo } from '@/utils';
import Badge from '@/components/Badge';
export function getStatusColumn() {
@ -56,8 +56,8 @@ export function getActions(doctype) {
{
label: 'Print',
condition: (doc) => doc.submitted,
action(doc, router) {
router.push(`/print/${doc.doctype}/${doc.name}`);
action(doc) {
routeTo(`/print/${doc.doctype}/${doc.name}`);
},
},
utils.ledgerLink,

View File

@ -40,6 +40,7 @@
import frappe from 'frappejs';
import reports from '../../reports/view';
import Dropdown from '@/components/Dropdown';
import { routeTo } from '@/utils'
export default {
data() {
@ -81,7 +82,8 @@ export default {
let searchList = [...doctypes, ...reports, ...views];
this.searchList = searchList.map(d => {
if (d.route) {
d.action = () => this.routeTo(d.route);
d.action = () => routeTo(d.route);
this.inputValue = '';
}
return d;
});
@ -118,10 +120,6 @@ export default {
group: 'List'
}
];
},
routeTo(route) {
this.$router.push(route);
this.inputValue = '';
}
}
};

View File

@ -3,7 +3,7 @@
<div class="window-no-drag">
<WindowControls v-if="platform === 'Mac'" class="px-3 mb-6" />
<div class="px-3">
<h6 class="text-lg font-semibold" @click="$router.push('/')">
<h6 class="text-lg font-semibold" @click="routeTo('/')">
{{ companyName }}
</h6>
</div>
@ -46,6 +46,7 @@
<script>
import sidebarConfig from '../sidebarConfig';
import WindowControls from './WindowControls';
import { routeTo } from '@/utils';
export default {
data() {
@ -84,6 +85,7 @@ export default {
}
},
methods: {
routeTo,
itemActiveClass(item) {
let { path: currentRoute, params } = this.$route;
let routeMatch = currentRoute === item.route;
@ -98,7 +100,7 @@ export default {
group.action();
}
if (group.route) {
this.routeTo(group.route);
routeTo(group.route);
}
this.activeGroup = group;
},
@ -107,11 +109,8 @@ export default {
item.action();
}
if (item.route) {
this.routeTo(item.route);
routeTo(item.route);
}
},
routeTo(route) {
this.$router.push(route);
}
}
};

View File

@ -73,6 +73,7 @@ import Button from '@/components/Button';
import PeriodSelector from './PeriodSelector';
import SectionHeader from './SectionHeader';
import { getDatesAndPeriodicity } from './getDatesAndPeriodicity';
import { routeTo } from '@/utils'
export default {
name: 'UnpaidInvoices',
@ -144,7 +145,7 @@ export default {
},
async newInvoice(invoice) {
let doc = await frappe.getNewDoc(invoice.doctype);
this.$router.push(`/edit/${invoice.doctype}/${doc.name}`);
routeTo(`/edit/${invoice.doctype}/${doc.name}`);
}
}
};

View File

@ -90,6 +90,7 @@ import Button from '@/components/Button';
import { openSettings } from '@/utils';
import { ipcRenderer } from 'electron';
import { IPC_MESSAGES } from '@/messages';
import { routeTo } from '@/utils';
export default {
name: 'GetStarted',
@ -149,7 +150,7 @@ export default {
description:
'Review your chart of accounts, add any account or tax heads as needed',
action: () => {
this.$router.push('/chart-of-accounts');
routeTo('/chart-of-accounts');
this.updateChecks({ chartOfAccountsReviewed: 1 });
},
fieldname: 'chartOfAccountsReviewed',
@ -171,7 +172,7 @@ export default {
icon: 'percentage',
description:
'Setup your tax templates for your sales or purchase transactions',
action: () => this.$router.push('/list/Tax'),
action: () => routeTo('/list/Tax'),
documentation:
'https://frappebooks.com/docs/setting-up#2-add-taxes'
}
@ -187,7 +188,7 @@ export default {
icon: 'item',
description:
'Add products or services that you sell to your customers',
action: () => this.$router.push('/list/Item'),
action: () => routeTo('/list/Item'),
fieldname: 'itemCreated',
documentation:
'https://frappebooks.com/docs/setting-up#3-add-items'
@ -197,7 +198,7 @@ export default {
label: _('Add Customers'),
icon: 'customer',
description: 'Add a few customers to create your first invoice',
action: () => this.$router.push('/list/Customer'),
action: () => routeTo('/list/Customer'),
fieldname: 'customerCreated',
documentation:
'https://frappebooks.com/docs/setting-up#4-add-customers'
@ -208,7 +209,7 @@ export default {
icon: 'sales-invoice',
description:
'Create your first invoice and mail it to your customer',
action: () => this.$router.push('/list/SalesInvoice'),
action: () => routeTo('/list/SalesInvoice'),
fieldname: 'invoiceCreated',
documentation: 'https://frappebooks.com/docs/invoices'
}
@ -224,7 +225,7 @@ export default {
icon: 'item',
description:
'Add products or services that you buy from your suppliers',
action: () => this.$router.push('/list/Item'),
action: () => routeTo('/list/Item'),
fieldname: 'itemCreated'
},
{
@ -232,7 +233,7 @@ export default {
label: _('Add Suppliers'),
icon: 'supplier',
description: 'Add a few suppliers to create your first bill',
action: () => this.$router.push('/list/Supplier'),
action: () => routeTo('/list/Supplier'),
fieldname: 'supplierCreated'
},
{
@ -241,7 +242,7 @@ export default {
icon: 'purchase-invoice',
description:
'Create your first bill and mail it to your supplier',
action: () => this.$router.push('/list/PurchaseInvoice'),
action: () => routeTo('/list/PurchaseInvoice'),
fieldname: 'billCreated',
documentation: 'https://frappebooks.com/docs/bills'
}

View File

@ -8,7 +8,7 @@
v-if="doc.submitted"
class="text-gray-900 text-xs ml-2"
:icon="true"
@click="$router.push(`/print/${doc.doctype}/${doc.name}`)"
@click="routeTo(`/print/${doc.doctype}/${doc.name}`)"
>
Print
</Button>
@ -201,6 +201,7 @@ import {
getActionsForDocument,
getInvoiceStatus,
showMessageDialog,
routeTo
} from '@/utils';
export default {
@ -256,7 +257,7 @@ export default {
window.d = this.doc;
} catch (error) {
if (error instanceof frappe.errors.NotFoundError) {
this.routeToList();
routeTo(`/list/${this.doctype}`);
return;
}
this.handleError(error);
@ -276,6 +277,7 @@ export default {
this.status = getInvoiceStatus(this.doc);
},
methods: {
routeTo,
async onSaveClick() {
await this.doc.set(
'items',
@ -310,9 +312,6 @@ export default {
openInvoiceSettings() {
openSettings('Invoice');
},
routeToList() {
this.$router.push(`/list/${this.doctype}`);
},
formattedValue(fieldname, doc) {
if (!doc) {
doc = this.doc;

View File

@ -127,7 +127,7 @@ import DropdownWithActions from '@/components/DropdownWithActions';
import FormControl from '@/components/Controls/FormControl';
import BackLink from '@/components/BackLink';
import StatusBadge from '@/components/StatusBadge';
import { handleErrorWithDialog, getActionsForDocument } from '@/utils';
import { handleErrorWithDialog, getActionsForDocument, routeTo } from '@/utils';
export default {
name: 'JournalEntryForm',
@ -187,7 +187,7 @@ export default {
window.je = this.doc;
} catch (error) {
if (error instanceof frappe.errors.NotFoundError) {
this.$router.push(`/list/${this.doctype}`);
routeTo(`/list/${this.doctype}`);
return;
}
this.handleError(error);

View File

@ -60,7 +60,7 @@ import frappe from 'frappejs';
import Row from '@/components/Row';
import ListCell from './ListCell';
import Avatar from '@/components/Avatar';
import { openQuickEdit } from '@/utils';
import { openQuickEdit, routeTo } from '@/utils';
import Button from '@/components/Button';
export default {
@ -108,7 +108,7 @@ export default {
},
openForm(doc) {
if (this.listConfig.formRoute) {
this.$router.push(this.listConfig.formRoute(doc.name));
routeTo(this.listConfig.formRoute(doc.name));
return;
}
openQuickEdit({

View File

@ -35,6 +35,7 @@ import List from './List';
import listConfigs from './listConfig';
// import Icon from '@/components/Icon';
import FilterDropdown from '@/components/FilterDropdown';
import { routeTo } from '@/utils'
export default {
name: 'ListView',
@ -63,7 +64,7 @@ export default {
doc.set(this.filters);
}
let path = this.getFormPath(doc.name);
this.$router.push(path);
routeTo(path);
doc.on('afterInsert', () => {
let path = this.getFormPath(doc.name);
this.$router.replace(path);

View File

@ -2,7 +2,6 @@ import frappe from 'frappejs';
import { openSettings } from '@/utils';
import { _ } from 'frappejs/utils';
import Icon from './components/Icon';
import router from './router';
const config = {
getTitle: async () => {
@ -23,9 +22,7 @@ const config = {
{
title: _('Sales'),
icon: getIcon('sales'),
action() {
router.push('/list/SalesInvoice');
},
route: '/list/SalesInvoice',
items: [
{
label: _('Invoices'),
@ -57,9 +54,7 @@ const config = {
{
title: _('Purchases'),
icon: getIcon('purchase'),
action() {
router.push('/list/PurchaseInvoice');
},
route: '/list/PurchaseInvoice',
items: [
{
label: _('Bills'),
@ -91,9 +86,7 @@ const config = {
{
title: _('Reports'),
icon: getIcon('reports'),
action() {
router.push('/report/general-ledger');
},
route: '/report/general-ledger',
items: [
{
label: _('General Ledger'),
@ -116,6 +109,7 @@ const config = {
{
title: _('Setup'),
icon: getIcon('settings'),
route: '/chart-of-accounts',
items: [
{
label: _('Chart of Accounts'),

View File

@ -212,6 +212,7 @@ export function openQuickEdit({ doctype, name, hideFields, defaults = {} }) {
// editing another document of the same doctype
method = 'replace';
}
if (query.name === name) return
router[method]({
query: {
edit: 1,
@ -260,7 +261,7 @@ export function getActionsForDocument(doc) {
action: () =>
deleteDocWithPrompt(doc).then((res) => {
if (res) {
router.push(`/list/${doc.doctype}`);
routeTo(`/list/${doc.doctype}`);
}
}),
};
@ -334,3 +335,9 @@ export function getInvoiceStatus(doc) {
}
return status;
}
export function routeTo(route) {
if (route !== router.currentRoute.fullPath) {
router.push(route);
}
}