mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 02:44:55 +00:00
Fix filter for decimal
This commit is contained in:
parent
88d5cc2c37
commit
3847fd8c67
@ -8,7 +8,7 @@ import React from 'react';
|
||||
import moment from 'moment';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import PropTypes from 'prop-types';
|
||||
import { toString, upperFirst } from 'lodash';
|
||||
import { get, toString, upperFirst } from 'lodash';
|
||||
import Flex from './Flex';
|
||||
import Remove from './Remove';
|
||||
import Separator from './Separator';
|
||||
@ -17,7 +17,7 @@ import Separator from './Separator';
|
||||
function Filter({ filter, index, onClick, onClickOpen, schema }) {
|
||||
let value = filter.value;
|
||||
|
||||
if (schema[filter.attr].type === 'date') {
|
||||
if (get(schema, [filter.attr, 'type']) === 'date') {
|
||||
const format = filter.value
|
||||
.slice(0, -1)
|
||||
.split('T')[1]
|
||||
|
||||
@ -1,44 +1 @@
|
||||
{
|
||||
"fuck": {
|
||||
"attributes": {
|
||||
"bool": {
|
||||
"appearance": ""
|
||||
},
|
||||
"datra": {
|
||||
"appearance": ""
|
||||
},
|
||||
"data": {
|
||||
"appearance": ""
|
||||
}
|
||||
}
|
||||
},
|
||||
"fevzilyaguk": {
|
||||
"attributes": {
|
||||
"razeiugeryeizla": {
|
||||
"appearance": ""
|
||||
}
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"attributes": {
|
||||
"string": {
|
||||
"appearance": ""
|
||||
},
|
||||
"int": {
|
||||
"appearance": ""
|
||||
},
|
||||
"float": {
|
||||
"appearance": ""
|
||||
},
|
||||
"decimal": {
|
||||
"appearance": ""
|
||||
},
|
||||
"date": {
|
||||
"appearance": ""
|
||||
},
|
||||
"json": {
|
||||
"appearance": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{}
|
||||
|
||||
@ -20,8 +20,15 @@ module.exports = {
|
||||
if (params.limit) {
|
||||
qb.limit(params.limit);
|
||||
}
|
||||
|
||||
if (params.sort) {
|
||||
if (params.sort.key) {
|
||||
qb.orderBy(params.sort.key, params.sort.order);
|
||||
} else {
|
||||
qb.orderBy(params.sort);
|
||||
}
|
||||
}
|
||||
})
|
||||
.orderBy(params.sort.key, params.sort.order)
|
||||
.fetchAll({
|
||||
withRelated: populate || _.keys(_.groupBy(_.reject(this.associations, { autoPopulate: false }), 'alias'))
|
||||
});
|
||||
|
||||
@ -445,11 +445,12 @@ module.exports = {
|
||||
|
||||
_.forEach(params, (value, key) => {
|
||||
let result;
|
||||
const formattedValue = !_.isNaN(_.toNumber(value)) ? _.toNumber(value) : value;
|
||||
|
||||
if (_.includes(['_start', '_limit'], key)) {
|
||||
result = convertor(value, key);
|
||||
result = convertor(formattedValue, key);
|
||||
} else if (key === '_sort') {
|
||||
const [attr, order = 'ASC'] = value.split(':');
|
||||
const [attr, order = 'ASC'] = formattedValue.split(':');
|
||||
result = convertor(order, key, attr);
|
||||
} else {
|
||||
const suffix = key.split('_');
|
||||
@ -463,7 +464,7 @@ module.exports = {
|
||||
type = '=';
|
||||
}
|
||||
|
||||
result = convertor(value, type, key);
|
||||
result = convertor(formattedValue, type, key);
|
||||
}
|
||||
|
||||
_.set(convertParams, result.key, result.value);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user