mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
feat: services quick search.
This commit is contained in:
@@ -11,10 +11,12 @@ import ModelSettings from './ModelSetting';
|
||||
import { ACCOUNT_TYPES } from 'data/AccountTypes';
|
||||
import CustomViewBaseModel from './CustomViewBaseModel';
|
||||
import { DEFAULT_VIEWS } from 'services/Accounts/constants';
|
||||
import ModelSearchable from './ModelSearchable';
|
||||
|
||||
export default class Account extends mixin(TenantModel, [
|
||||
ModelSettings,
|
||||
CustomViewBaseModel,
|
||||
ModelSearchable,
|
||||
]) {
|
||||
/**
|
||||
* Table name.
|
||||
@@ -257,7 +259,17 @@ export default class Account extends mixin(TenantModel, [
|
||||
/**
|
||||
* Retrieve the default custom views, roles and columns.
|
||||
*/
|
||||
static get defaultViews() {
|
||||
static get defaultViews() {
|
||||
return DEFAULT_VIEWS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model search roles.
|
||||
*/
|
||||
static get searchRoles() {
|
||||
return [
|
||||
{ condition: 'or', fieldKey: 'name', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'code', comparator: 'like' },
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,12 @@ import BillSettings from './Bill.Settings';
|
||||
import ModelSetting from './ModelSetting';
|
||||
import CustomViewBaseModel from './CustomViewBaseModel';
|
||||
import { DEFAULT_VIEWS } from 'services/Purchases/constants';
|
||||
import ModelSearchable from './ModelSearchable';
|
||||
|
||||
export default class Bill extends mixin(TenantModel, [
|
||||
ModelSetting,
|
||||
CustomViewBaseModel,
|
||||
ModelSearchable
|
||||
]) {
|
||||
/**
|
||||
* Table name
|
||||
@@ -315,4 +317,15 @@ export default class Bill extends mixin(TenantModel, [
|
||||
static get defaultViews() {
|
||||
return DEFAULT_VIEWS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model search attributes.
|
||||
*/
|
||||
static get searchRoles() {
|
||||
return [
|
||||
{ fieldKey: 'bill_number', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'reference_no', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'amount', comparator: 'equals' },
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,12 @@ import ModelSetting from './ModelSetting';
|
||||
import BillPaymentSettings from './BillPayment.Settings';
|
||||
import CustomViewBaseModel from './CustomViewBaseModel';
|
||||
import { DEFAULT_VIEWS } from 'services/Sales/PaymentReceives/constants';
|
||||
import ModelSearchable from './ModelSearchable';
|
||||
|
||||
export default class BillPayment extends mixin(TenantModel, [
|
||||
ModelSetting,
|
||||
CustomViewBaseModel,
|
||||
ModelSearchable,
|
||||
]) {
|
||||
/**
|
||||
* Table name
|
||||
@@ -90,4 +92,15 @@ export default class BillPayment extends mixin(TenantModel, [
|
||||
static get defaultViews() {
|
||||
return DEFAULT_VIEWS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model search attributes.
|
||||
*/
|
||||
static get searchRoles() {
|
||||
return [
|
||||
{ fieldKey: 'payment_number', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'reference_no', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'amount', comparator: 'equals' },
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,69 +1,67 @@
|
||||
export default {
|
||||
fields: {
|
||||
first_name: {
|
||||
name: 'First name',
|
||||
column: 'first_name',
|
||||
fieldType: 'text',
|
||||
},
|
||||
last_name: {
|
||||
name: 'Last name',
|
||||
column: 'last_name',
|
||||
fieldType: 'text',
|
||||
},
|
||||
display_name: {
|
||||
name: 'Display name',
|
||||
column: 'display_name',
|
||||
fieldType: 'text',
|
||||
columnable: true,
|
||||
},
|
||||
email: {
|
||||
name: 'Email',
|
||||
column: 'email',
|
||||
fieldType: 'text',
|
||||
columnable: true,
|
||||
},
|
||||
work_phone: {
|
||||
name: 'Work phone',
|
||||
column: 'work_phone',
|
||||
fieldType: 'text',
|
||||
columnable: true,
|
||||
},
|
||||
personal_phone: {
|
||||
name: 'Personal phone',
|
||||
column: 'personal_phone',
|
||||
fieldType: 'text',
|
||||
columnable: true,
|
||||
},
|
||||
company_name: {
|
||||
name: 'Company name',
|
||||
column: 'company_name',
|
||||
fieldType: 'text',
|
||||
columnable: true,
|
||||
},
|
||||
website: {
|
||||
name: 'Website',
|
||||
column: 'website',
|
||||
fieldType: 'text',
|
||||
columnable: true,
|
||||
},
|
||||
created_at: {
|
||||
name: 'Created at',
|
||||
column: 'created_at',
|
||||
fieldType: 'date',
|
||||
columnable: true,
|
||||
},
|
||||
balance: {
|
||||
name: 'Balance',
|
||||
column: 'balance',
|
||||
fieldType: 'number',
|
||||
columnable: true,
|
||||
},
|
||||
opening_balance: {
|
||||
name: 'Opening balance',
|
||||
column: 'opening_balance',
|
||||
fieldType: 'number',
|
||||
columnable: true,
|
||||
},
|
||||
opening_balance_at: {
|
||||
name: 'Opening balance at',
|
||||
column: 'opening_balance_at',
|
||||
filterable: false,
|
||||
fieldType: 'date',
|
||||
columnable: true,
|
||||
},
|
||||
currency_code: {
|
||||
column: 'currency_code',
|
||||
columnable: true,
|
||||
fieldType: 'text',
|
||||
},
|
||||
status: {
|
||||
@@ -74,7 +72,6 @@ export default {
|
||||
{ key: 'overdue', label: 'Overdue' },
|
||||
{ key: 'unpaid', label: 'Unpaid' },
|
||||
],
|
||||
columnable: true,
|
||||
filterCustomQuery: statusFieldFilterQuery,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -5,6 +5,7 @@ import ModelSetting from './ModelSetting';
|
||||
import CustomerSettings from './Customer.Settings';
|
||||
import CustomViewBaseModel from './CustomViewBaseModel';
|
||||
import { DEFAULT_VIEWS } from 'services/Contacts/Customers/constants';
|
||||
import ModelSearchable from './ModelSearchable';
|
||||
|
||||
class CustomerQueryBuilder extends PaginationQueryBuilder {
|
||||
constructor(...args) {
|
||||
@@ -21,6 +22,7 @@ class CustomerQueryBuilder extends PaginationQueryBuilder {
|
||||
export default class Customer extends mixin(TenantModel, [
|
||||
ModelSetting,
|
||||
CustomViewBaseModel,
|
||||
ModelSearchable
|
||||
]) {
|
||||
/**
|
||||
* Query builder.
|
||||
@@ -149,4 +151,20 @@ export default class Customer extends mixin(TenantModel, [
|
||||
static get defaultViews() {
|
||||
return DEFAULT_VIEWS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model search attributes.
|
||||
*/
|
||||
static get searchRoles() {
|
||||
return [
|
||||
{ fieldKey: 'display_name', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'first_name', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'last_name', comparator: 'equals' },
|
||||
{ condition: 'or', fieldKey: 'company_name', comparator: 'equals' },
|
||||
{ condition: 'or', fieldKey: 'email', comparator: 'equals' },
|
||||
{ condition: 'or', fieldKey: 'work_phone', comparator: 'equals' },
|
||||
{ condition: 'or', fieldKey: 'personal_phone', comparator: 'equals' },
|
||||
{ condition: 'or', fieldKey: 'website', comparator: 'equals' },
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@ import ModelSetting from './ModelSetting';
|
||||
import ExpenseSettings from './Expense.Settings';
|
||||
import CustomViewBaseModel from './CustomViewBaseModel';
|
||||
import { DEFAULT_VIEWS } from 'services/Expenses/constants';
|
||||
import ModelSearchable from './ModelSearchable';
|
||||
|
||||
export default class Expense extends mixin(TenantModel, [
|
||||
ModelSetting,
|
||||
CustomViewBaseModel,
|
||||
ModelSearchable,
|
||||
]) {
|
||||
/**
|
||||
* Table name
|
||||
@@ -160,4 +162,14 @@ export default class Expense extends mixin(TenantModel, [
|
||||
static get defaultViews() {
|
||||
return DEFAULT_VIEWS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model search attributes.
|
||||
*/
|
||||
static get searchRoles() {
|
||||
return [
|
||||
{ fieldKey: 'reference_no', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'amount', comparator: 'equals' },
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@ import ItemSettings from './Item.Settings';
|
||||
import ModelSetting from './ModelSetting';
|
||||
import CustomViewBaseModel from './CustomViewBaseModel';
|
||||
import { DEFAULT_VIEWS } from 'services/Items/constants';
|
||||
import ModelSearchable from './ModelSearchable';
|
||||
|
||||
export default class Item extends mixin(TenantModel, [
|
||||
ModelSetting,
|
||||
CustomViewBaseModel,
|
||||
ModelSearchable,
|
||||
]) {
|
||||
/**
|
||||
* Table name
|
||||
@@ -128,4 +130,14 @@ export default class Item extends mixin(TenantModel, [
|
||||
static get defaultViews() {
|
||||
return DEFAULT_VIEWS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model search roles.
|
||||
*/
|
||||
static get searchRoles() {
|
||||
return [
|
||||
{ fieldKey: 'name', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'code', comparator: 'like' },
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,11 @@ import ModelSetting from './ModelSetting';
|
||||
import ManualJournalSettings from './ManualJournal.Settings';
|
||||
import CustomViewBaseModel from './CustomViewBaseModel';
|
||||
import { DEFAULT_VIEWS } from 'services/ManualJournals/constants';
|
||||
import ModelSearchable from './ModelSearchable';
|
||||
export default class ManualJournal extends mixin(TenantModel, [
|
||||
ModelSetting,
|
||||
CustomViewBaseModel,
|
||||
ModelSearchable,
|
||||
]) {
|
||||
/**
|
||||
* Table name.
|
||||
@@ -115,4 +117,15 @@ export default class ManualJournal extends mixin(TenantModel, [
|
||||
static get defaultViews() {
|
||||
return DEFAULT_VIEWS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model search attributes.
|
||||
*/
|
||||
static get searchRoles() {
|
||||
return [
|
||||
{ fieldKey: 'journal_number', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'reference', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'amount', comparator: 'equals' },
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
18
server/src/models/ModelSearchable.ts
Normal file
18
server/src/models/ModelSearchable.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { IModelMeta, ISearchRole } from 'interfaces';
|
||||
|
||||
export default (Model) =>
|
||||
class ModelSearchable extends Model {
|
||||
/**
|
||||
* Searchable model.
|
||||
*/
|
||||
static get searchable(): IModelMeta {
|
||||
throw true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search roles.
|
||||
*/
|
||||
static get searchRoles(): ISearchRole[] {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
@@ -4,10 +4,12 @@ import ModelSetting from './ModelSetting';
|
||||
import PaymentReceiveSettings from './PaymentReceive.Settings';
|
||||
import CustomViewBaseModel from './CustomViewBaseModel';
|
||||
import { DEFAULT_VIEWS } from 'services/Sales/PaymentReceives/constants';
|
||||
import ModelSearchable from './ModelSearchable';
|
||||
|
||||
export default class PaymentReceive extends mixin(TenantModel, [
|
||||
ModelSetting,
|
||||
CustomViewBaseModel,
|
||||
ModelSearchable
|
||||
]) {
|
||||
/**
|
||||
* Table name.
|
||||
@@ -94,4 +96,15 @@ export default class PaymentReceive extends mixin(TenantModel, [
|
||||
static get defaultViews() {
|
||||
return DEFAULT_VIEWS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model search attributes.
|
||||
*/
|
||||
static get searchRoles() {
|
||||
return [
|
||||
{ fieldKey: 'payment_receive_no', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'reference_no', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'amount', comparator: 'equals' },
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,12 @@ import SaleEstimateSettings from './SaleEstimate.Settings';
|
||||
import ModelSetting from './ModelSetting';
|
||||
import CustomViewBaseModel from './CustomViewBaseModel';
|
||||
import { DEFAULT_VIEWS } from 'services/Sales/Estimates/constants';
|
||||
import ModelSearchable from './ModelSearchable';
|
||||
|
||||
export default class SaleEstimate extends mixin(TenantModel, [
|
||||
ModelSetting,
|
||||
CustomViewBaseModel,
|
||||
ModelSearchable,
|
||||
]) {
|
||||
/**
|
||||
* Table name
|
||||
@@ -210,4 +212,15 @@ export default class SaleEstimate extends mixin(TenantModel, [
|
||||
static get defaultViews() {
|
||||
return DEFAULT_VIEWS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model search roles.
|
||||
*/
|
||||
static get searchRoles() {
|
||||
return [
|
||||
{ fieldKey: 'amount', comparator: 'equals' },
|
||||
{ condition: 'or', fieldKey: 'estimate_number', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'reference_no', comparator: 'contains' },
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@ import ModelSetting from './ModelSetting';
|
||||
import SaleInvoiceMeta from './SaleInvoice.Settings';
|
||||
import CustomViewBaseModel from './CustomViewBaseModel';
|
||||
import { DEFAULT_VIEWS } from 'services/Sales/constants';
|
||||
import ModelSearchable from './ModelSearchable';
|
||||
|
||||
export default class SaleInvoice extends mixin(TenantModel, [
|
||||
ModelSetting,
|
||||
CustomViewBaseModel,
|
||||
ModelSearchable,
|
||||
]) {
|
||||
/**
|
||||
* Table name
|
||||
@@ -371,4 +373,22 @@ export default class SaleInvoice extends mixin(TenantModel, [
|
||||
static get defaultViews() {
|
||||
return DEFAULT_VIEWS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Model searchable.
|
||||
*/
|
||||
static get searchable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model search attributes.
|
||||
*/
|
||||
static get searchRoles() {
|
||||
return [
|
||||
{ fieldKey: 'invoice_no', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'reference_no', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'amount', comparator: 'equals' },
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,12 @@ import ModelSetting from './ModelSetting';
|
||||
import SaleReceiptSettings from './SaleReceipt.Settings';
|
||||
import CustomViewBaseModel from './CustomViewBaseModel';
|
||||
import { DEFAULT_VIEWS } from 'services/Sales/Receipts/constants';
|
||||
import ModelSearchable from './ModelSearchable';
|
||||
|
||||
export default class SaleReceipt extends mixin(TenantModel, [
|
||||
ModelSetting,
|
||||
CustomViewBaseModel,
|
||||
ModelSearchable,
|
||||
]) {
|
||||
/**
|
||||
* Table name
|
||||
@@ -159,4 +161,15 @@ export default class SaleReceipt extends mixin(TenantModel, [
|
||||
static get defaultViews() {
|
||||
return DEFAULT_VIEWS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model search attributes.
|
||||
*/
|
||||
static get searchRoles() {
|
||||
return [
|
||||
{ fieldKey: 'receipt_number', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'reference_no', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'amount', comparator: 'equals' },
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,16 @@ export default {
|
||||
sortField: 'created_at',
|
||||
},
|
||||
fields: {
|
||||
first_name: {
|
||||
name: 'First name',
|
||||
column: 'first_name',
|
||||
fieldType: 'text',
|
||||
},
|
||||
last_name: {
|
||||
name: 'Last name',
|
||||
column: 'last_name',
|
||||
fieldType: 'text',
|
||||
},
|
||||
'display_name': {
|
||||
name: 'Display name',
|
||||
column: 'display_name',
|
||||
|
||||
@@ -5,6 +5,7 @@ import ModelSetting from './ModelSetting';
|
||||
import VendorSettings from './Vendor.Settings';
|
||||
import CustomViewBaseModel from './CustomViewBaseModel';
|
||||
import { DEFAULT_VIEWS } from 'services/Contacts/Vendors/constants';
|
||||
import ModelSearchable from './ModelSearchable';
|
||||
|
||||
class VendorQueryBuilder extends PaginationQueryBuilder {
|
||||
constructor(...args) {
|
||||
@@ -21,6 +22,7 @@ class VendorQueryBuilder extends PaginationQueryBuilder {
|
||||
export default class Vendor extends mixin(TenantModel, [
|
||||
ModelSetting,
|
||||
CustomViewBaseModel,
|
||||
ModelSearchable
|
||||
]) {
|
||||
/**
|
||||
* Query builder.
|
||||
@@ -148,4 +150,20 @@ export default class Vendor extends mixin(TenantModel, [
|
||||
static get defaultViews() {
|
||||
return DEFAULT_VIEWS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model search attributes.
|
||||
*/
|
||||
static get searchRoles() {
|
||||
return [
|
||||
{ fieldKey: 'display_name', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'first_name', comparator: 'contains' },
|
||||
{ condition: 'or', fieldKey: 'last_name', comparator: 'equals' },
|
||||
{ condition: 'or', fieldKey: 'company_name', comparator: 'equals' },
|
||||
{ condition: 'or', fieldKey: 'email', comparator: 'equals' },
|
||||
{ condition: 'or', fieldKey: 'work_phone', comparator: 'equals' },
|
||||
{ condition: 'or', fieldKey: 'personal_phone', comparator: 'equals' },
|
||||
{ condition: 'or', fieldKey: 'website', comparator: 'equals' },
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user