mirror of
https://github.com/directus/directus.git
synced 2026-02-19 06:14:23 -05:00
Allow empty field for metric
This commit is contained in:
@@ -27,6 +27,7 @@ export default definePanel({
|
||||
collectionField: 'collection',
|
||||
typeAllowList: ['integer', 'bigInteger', 'float', 'decimal'],
|
||||
allowPrimaryKey: true,
|
||||
allowNone: true,
|
||||
},
|
||||
width: 'half',
|
||||
},
|
||||
|
||||
@@ -122,14 +122,18 @@ export default defineComponent({
|
||||
const res = await api.get(`/items/${props.options.collection}`, {
|
||||
params: {
|
||||
aggregate: {
|
||||
[props.options.function]: [props.options.field],
|
||||
[props.options.function]: [props.options.field || '*'],
|
||||
},
|
||||
filter: props.options.filter,
|
||||
sort: sort,
|
||||
},
|
||||
});
|
||||
|
||||
metric.value = Number(res.data.data[0][`${props.options.field}_${props.options.function}`]);
|
||||
if (props.options.field) {
|
||||
metric.value = Number(res.data.data[0][`${props.options.field}_${props.options.function}`]);
|
||||
} else {
|
||||
metric.value = Number(res.data.data[0][props.options.function]);
|
||||
}
|
||||
} catch (err) {
|
||||
// oh no
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user