From 0f8972077037107ac25d42a1dcd9824c0dee6bd8 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Sun, 6 Oct 2019 03:12:08 +0530 Subject: [PATCH] feat: Customer/Supplier doctype based on Party --- models/doctype/Party/Customer.js | 8 +++++++ models/doctype/Party/CustomerList.js | 7 ++---- models/doctype/Party/Party.js | 6 +++++ models/doctype/Party/Supplier.js | 8 +++++++ models/doctype/Party/SupplierList.js | 7 ++---- models/index.js | 2 ++ src/components/Icons/Search.vue | 11 ++++++++++ src/components/PageHeader.vue | 23 +++---------------- src/components/SearchBar.vue | 10 +++++---- src/pages/ListView/index.vue | 33 ++++++++++++++++++++-------- src/pages/ListView/listConfig.js | 2 ++ 11 files changed, 74 insertions(+), 43 deletions(-) create mode 100644 models/doctype/Party/Customer.js create mode 100644 models/doctype/Party/Supplier.js create mode 100644 src/components/Icons/Search.vue diff --git a/models/doctype/Party/Customer.js b/models/doctype/Party/Customer.js new file mode 100644 index 00000000..cd0ef17c --- /dev/null +++ b/models/doctype/Party/Customer.js @@ -0,0 +1,8 @@ +module.exports = { + name: 'Customer', + label: 'Customer', + basedOn: 'Party', + filters: { + customer: 1 + } +}; diff --git a/models/doctype/Party/CustomerList.js b/models/doctype/Party/CustomerList.js index 94877ae0..dd44ec60 100644 --- a/models/doctype/Party/CustomerList.js +++ b/models/doctype/Party/CustomerList.js @@ -1,10 +1,7 @@ import { _ } from 'frappejs/utils'; export default { - doctype: 'Party', + doctype: 'Customer', title: _('Customer'), - columns: ['name', 'defaultAccount', 'address'], - filters: { - customer: 1 - } + columns: ['name', 'defaultAccount', 'address'] }; diff --git a/models/doctype/Party/Party.js b/models/doctype/Party/Party.js index c4895c26..7ee860e8 100644 --- a/models/doctype/Party/Party.js +++ b/models/doctype/Party/Party.js @@ -51,6 +51,12 @@ module.exports = { } ], + quickEditFields: [ + 'address', + 'defaultAccount', + 'currency' + ], + getFormTitle(doc) { if (doc.customer) return 'Customer'; return 'Supplier'; diff --git a/models/doctype/Party/Supplier.js b/models/doctype/Party/Supplier.js new file mode 100644 index 00000000..7c6f2008 --- /dev/null +++ b/models/doctype/Party/Supplier.js @@ -0,0 +1,8 @@ +module.exports = { + name: 'Supplier', + label: 'Supplier', + basedOn: 'Party', + filters: { + supplier: 1 + } +}; diff --git a/models/doctype/Party/SupplierList.js b/models/doctype/Party/SupplierList.js index 88e0e7c3..c3ea2569 100644 --- a/models/doctype/Party/SupplierList.js +++ b/models/doctype/Party/SupplierList.js @@ -1,10 +1,7 @@ import { _ } from 'frappejs/utils'; export default { - doctype: 'Party', + doctype: 'Supplier', title: _('Supplier'), - columns: ['name', 'defaultAccount', 'address'], - filters: { - supplier: 1 - } + columns: ['name', 'defaultAccount', 'address'] }; diff --git a/models/index.js b/models/index.js index 22352c81..012556a2 100644 --- a/models/index.js +++ b/models/index.js @@ -10,6 +10,8 @@ module.exports = { CompanySettings: require('./doctype/CompanySettings/CompanySettings'), AccountingLedgerEntry: require('./doctype/AccountingLedgerEntry/AccountingLedgerEntry.js'), Party: require('./doctype/Party/Party.js'), + Customer: require('./doctype/Party/Customer'), + Supplier: require('./doctype/Party/Supplier'), Payment: require('./doctype/Payment/Payment.js'), PaymentFor: require('./doctype/PaymentFor/PaymentFor.js'), diff --git a/src/components/Icons/Search.vue b/src/components/Icons/Search.vue new file mode 100644 index 00000000..9e391ddb --- /dev/null +++ b/src/components/Icons/Search.vue @@ -0,0 +1,11 @@ + diff --git a/src/components/PageHeader.vue b/src/components/PageHeader.vue index acdff9eb..1e57ea31 100644 --- a/src/components/PageHeader.vue +++ b/src/components/PageHeader.vue @@ -1,25 +1,8 @@ - diff --git a/src/components/SearchBar.vue b/src/components/SearchBar.vue index eaa81872..856829b1 100644 --- a/src/components/SearchBar.vue +++ b/src/components/SearchBar.vue @@ -1,12 +1,12 @@ @@ -15,6 +23,9 @@ import frappe from 'frappejs'; import Observable from 'frappejs/utils/observable'; import PageHeader from '@/components/PageHeader'; +import Button from '@/components/Button'; +import Add from '@/components/Icons/Add'; +import SearchBar from '@/components/SearchBar'; import List from './List'; import listConfigs from './listConfig'; @@ -23,7 +34,10 @@ export default { props: ['listName', 'filters'], components: { PageHeader, - List + List, + Button, + Add, + SearchBar }, created() { frappe.listView = new Observable(); @@ -38,9 +52,9 @@ export default { if (this.filters) { doc.set(this.filters); } - this.$router.push(`/edit/${doctype}/${doc.name}`); + this.$router.push(`/list/${this.listName}/${doc.name}`); doc.on('afterInsert', () => { - this.$router.push(`/edit/${doctype}/${doc.name}`); + this.$router.push(`/list/${this.listName}/${doc.name}`); }); } }, @@ -60,11 +74,12 @@ export default { } }, title() { - try { - return this.listConfig.title(this.filters); - } catch (e) { - return this.listConfig.title; + if (this.listConfig) { + return typeof this.listConfig.title === 'function' + ? this.listConfig.title(this.filters) + : this.listConfig.title; } + return this.listName; } } }; diff --git a/src/pages/ListView/listConfig.js b/src/pages/ListView/listConfig.js index 80cd53ac..4e57d3f7 100644 --- a/src/pages/ListView/listConfig.js +++ b/src/pages/ListView/listConfig.js @@ -2,6 +2,7 @@ import SalesInvoice from '../../../models/doctype/SalesInvoice/SalesInvoiceList' import PurchaseInvoice from '../../../models/doctype/PurchaseInvoice/PurchaseInvoiceList'; import Customer from '../../../models/doctype/Party/CustomerList'; import Supplier from '../../../models/doctype/Party/SupplierList'; +import Party from '../../../models/doctype/Party/PartyList'; import Item from '../../../models/doctype/Item/ItemList'; import Payment from '../../../models/doctype/Payment/PaymentList'; import Tax from '../../../models/doctype/Tax/TaxList'; @@ -14,6 +15,7 @@ export default { PurchaseInvoice, Customer, Supplier, + Party, Item, Payment, Tax,