Uses metaquery instead of authorid for author filter. #330.

This commit is contained in:
Mateus Machado Luna 2019-11-06 16:57:39 -03:00
parent c2d4e1ff83
commit 56e7368262
2 changed files with 40 additions and 9 deletions

View File

@ -89,8 +89,9 @@
:open-on-focus="openOnFocus" :open-on-focus="openOnFocus"
@typing="fetchUsersForFiltering" @typing="fetchUsersForFiltering"
@select="filterActivitiesByUser" @select="filterActivitiesByUser"
:loading="isFetchingUsers"
field="name" field="name"
icon="magnify"> icon="account">
<template slot-scope="props"> <template slot-scope="props">
<div class="media"> <div class="media">
<div <div
@ -445,7 +446,7 @@
moment(dateString[1], this.dateFormat).toDate() moment(dateString[1], this.dateFormat).toDate()
]; ];
}, },
fetchUsersForFiltering(search) { fetchUsersForFiltering: _.debounce(function (search) {
this.isFetchingUsers = true; this.isFetchingUsers = true;
this.fetchUsers({ search: search }) this.fetchUsers({ search: search })
@ -457,7 +458,7 @@
this.$console.error(error); this.$console.error(error);
this.isFetchingPages = false; this.isFetchingPages = false;
}); });
} }, 500)
}, },
computed: { computed: {
activities(){ activities(){

View File

@ -21,8 +21,18 @@ export const fetchActivities = ({ commit }, { page, activitiesPerPage, search, s
endpoint += '&' + qs.stringify(dateQuery); endpoint += '&' + qs.stringify(dateQuery);
} }
if (authorId != undefined && authorId != null) if (authorId != undefined && authorId != null) {
endpoint += `&authorid=${authorId}`; let metaQuery = {
metaquery: [
{
value: authorId,
key: 'user_id',
compare: '='
}
]
};
endpoint += '&' + qs.stringify(metaQuery);
}
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.tainacan.get(endpoint) axios.tainacan.get(endpoint)
@ -60,8 +70,18 @@ export const fetchCollectionActivities = ({ commit }, { page, activitiesPerPage,
endpoint += '&' + qs.stringify(dateQuery); endpoint += '&' + qs.stringify(dateQuery);
} }
if (authorId != undefined && authorId != null) if (authorId != undefined && authorId != null) {
endpoint += `&authorid=${authorId}`; let metaQuery = {
metaquery: [
{
value: authorId,
key: 'user_id',
compare: '='
}
]
};
endpoint += '&' + qs.stringify(metaQuery);
}
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.tainacan.get(endpoint) axios.tainacan.get(endpoint)
@ -86,8 +106,18 @@ export const fetchItemActivities = ({ commit }, { page, activitiesPerPage, itemI
if (search != undefined && search != '') if (search != undefined && search != '')
endpoint += `&search=${search}`; endpoint += `&search=${search}`;
if (authorId != undefined && authorId != null) if (authorId != undefined && authorId != null) {
endpoint += `&authorid=${authorId}`; let metaQuery = {
metaquery: [
{
value: authorId,
key: 'user_id',
compare: '='
}
]
};
endpoint += '&' + qs.stringify(metaQuery);
}
if (searchDates && searchDates[0] != null && searchDates[1] != null) { if (searchDates && searchDates[0] != null && searchDates[1] != null) {
let dateQuery = { let dateQuery = {