fix(sorting): add the missing the resources columns.

This commit is contained in:
a.bouhuolia
2021-03-06 14:11:28 +02:00
parent 32e5695950
commit b03a27aefb
9 changed files with 84 additions and 7 deletions

View File

@@ -5,12 +5,16 @@ import asyncMiddleware from 'api/middleware/asyncMiddleware';
import BaseController from './BaseController';
import { ServiceError } from 'exceptions';
import ExchangeRatesService from 'services/ExchangeRates/ExchangeRatesService';
import DynamicListingService from 'services/DynamicListing/DynamicListService';
@Service()
export default class ExchangeRatesController extends BaseController {
@Inject()
exchangeRatesService: ExchangeRatesService;
@Inject()
dynamicListService: DynamicListingService;
/**
* Constructor method.
*/
@@ -22,7 +26,8 @@ export default class ExchangeRatesController extends BaseController {
[...this.exchangeRatesListSchema],
this.validationResult,
asyncMiddleware(this.exchangeRates.bind(this)),
this.handleServiceError
this.dynamicListService.handlerErrorsToResponse,
this.handleServiceError,
);
router.post(
'/',
@@ -59,6 +64,9 @@ export default class ExchangeRatesController extends BaseController {
return [
query('page').optional().isNumeric().toInt(),
query('page_size').optional().isNumeric().toInt(),
query('column_sort_by').optional(),
query('sort_order').optional().isIn(['desc', 'asc']),
];
}
@@ -96,8 +104,14 @@ export default class ExchangeRatesController extends BaseController {
const filter = {
page: 1,
pageSize: 100,
...req.query,
filterRoles: [],
columnSortBy: 'created_at',
sortOrder: 'asc',
...this.matchedQueryData(req),
};
if (filter.stringifiedFilterRoles) {
filter.filterRoles = JSON.parse(filter.stringifiedFilterRoles);
}
try {
const exchangeRates = await this.exchangeRatesService.listExchangeRates(
tenantId,