mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
fix: disable dynamic list in contacts resource.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { check, param, query, body, ValidationChain } from 'express-validator';
|
||||
import { Router, Request, Response, NextFunction } from 'express';
|
||||
import { Inject, Service } from 'typedi';
|
||||
import * as R from 'ramda';
|
||||
import BaseController from 'api/controllers/BaseController';
|
||||
import ContactsService from 'services/Contacts/ContactsService';
|
||||
import DynamicListingService from 'services/DynamicListing/DynamicListService';
|
||||
@@ -87,9 +88,6 @@ export default class ContactsController extends BaseController {
|
||||
limit: 10,
|
||||
...this.matchedQueryData(req),
|
||||
};
|
||||
if (filter.stringifiedFilterRoles) {
|
||||
filter.filterRoles = JSON.parse(filter.stringifiedFilterRoles);
|
||||
}
|
||||
try {
|
||||
const contacts = await this.contactsService.autocompleteContacts(
|
||||
tenantId,
|
||||
|
||||
@@ -84,13 +84,13 @@ export default class ResourceController extends BaseController {
|
||||
const { resource_model: resourceModel } = req.params;
|
||||
|
||||
try {
|
||||
const resourceFields = this.resourcesService.getResourceFields(
|
||||
tenantId,
|
||||
resourceModel
|
||||
);
|
||||
// const resourceFields = this.resourcesService.getResourceFields(
|
||||
// tenantId,
|
||||
// resourceModel
|
||||
// );
|
||||
|
||||
return res.status(200).send({
|
||||
resource_fields: this.transfromToResponse(resourceFields),
|
||||
resource_fields: [],
|
||||
});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { difference, upperFirst, omit } from 'lodash';
|
||||
import moment from 'moment';
|
||||
import * as R from 'ramda';
|
||||
import { ServiceError } from 'exceptions';
|
||||
import TenancyService from 'services/Tenancy/TenancyService';
|
||||
import DynamicListingService from 'services/DynamicListing/DynamicListService';
|
||||
@@ -205,6 +206,16 @@ export default class ContactsService {
|
||||
return this.getContactByIdOrThrowError(tenantId, contactId, contactService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parsees accounts list filter DTO.
|
||||
* @param filterDTO
|
||||
*/
|
||||
private parseAutocompleteListFilterDTO(filterDTO) {
|
||||
return R.compose(
|
||||
this.dynamicListService.parseStringifiedFilter
|
||||
)(filterDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve auto-complete contacts list.
|
||||
* @param {number} tenantId -
|
||||
@@ -213,23 +224,26 @@ export default class ContactsService {
|
||||
*/
|
||||
async autocompleteContacts(
|
||||
tenantId: number,
|
||||
contactsFilter: IContactsAutoCompleteFilter
|
||||
query: IContactsAutoCompleteFilter
|
||||
) {
|
||||
const { Contact } = this.tenancy.models(tenantId);
|
||||
|
||||
// Parses auto-complete list filter DTO.
|
||||
const filter = this.parseAutocompleteListFilterDTO(query);
|
||||
|
||||
// Dynamic list.
|
||||
const dynamicList = await this.dynamicListService.dynamicList(
|
||||
tenantId,
|
||||
Contact,
|
||||
contactsFilter
|
||||
);
|
||||
// const dynamicList = await this.dynamicListService.dynamicList(
|
||||
// tenantId,
|
||||
// Contact,
|
||||
// filter
|
||||
// );
|
||||
// Retrieve contacts list by the given query.
|
||||
const contacts = await Contact.query().onBuild((builder) => {
|
||||
if (contactsFilter.keyword) {
|
||||
builder.where('display_name', 'LIKE', `%${contactsFilter.keyword}%`);
|
||||
if (filter.keyword) {
|
||||
builder.where('display_name', 'LIKE', `%${filter.keyword}%`);
|
||||
}
|
||||
dynamicList.buildQuery()(builder);
|
||||
builder.limit(contactsFilter.limit);
|
||||
// dynamicList.buildQuery()(builder);
|
||||
builder.limit(filter.limit);
|
||||
});
|
||||
return contacts;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user