Added selectable tag function for actors. Implemented experimental filtering by tag.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import config from 'config';
|
||||
import { graphql, get } from '../api';
|
||||
import {
|
||||
releaseFields,
|
||||
@@ -8,7 +9,7 @@ import {
|
||||
import { curateActor, curateRelease } from '../curate';
|
||||
import getDateRange from '../get-date-range';
|
||||
|
||||
function initActorActions(store, _router) {
|
||||
function initActorActions(store, router) {
|
||||
async function fetchActorById({ _commit }, {
|
||||
actorId,
|
||||
limit = 10,
|
||||
@@ -16,6 +17,7 @@ function initActorActions(store, _router) {
|
||||
range = 'latest',
|
||||
}) {
|
||||
const { before, after, orderBy } = getDateRange(range);
|
||||
const includeTags = router.currentRoute.query.tags ? router.currentRoute.query.tags.split(',') : [];
|
||||
|
||||
const { actor, connection: { releases, totalCount } } = await graphql(`
|
||||
query Actor(
|
||||
@@ -25,7 +27,9 @@ function initActorActions(store, _router) {
|
||||
$after:Date = "1900-01-01",
|
||||
$before:Date = "2100-01-01",
|
||||
$orderBy:[ReleasesActorsOrderBy!]
|
||||
$exclude: [String!]
|
||||
$selectableTags: [String],
|
||||
$excludeTags: [String!]
|
||||
${includeTags.length > 0 ? '$includeTags: [String!]' : ''}
|
||||
) {
|
||||
actor(id: $actorId) {
|
||||
id
|
||||
@@ -139,22 +143,28 @@ function initActorActions(store, _router) {
|
||||
name
|
||||
slug
|
||||
}
|
||||
tags(selectableTags: $selectableTags) {
|
||||
id
|
||||
name
|
||||
slug
|
||||
priority
|
||||
}
|
||||
releasesConnection: releasesActorsConnection(
|
||||
filter: {
|
||||
release: {
|
||||
date: {
|
||||
lessThan: $before,
|
||||
greaterThan: $after,
|
||||
},
|
||||
releasesTagsConnection: {
|
||||
none: {
|
||||
tag: {
|
||||
slug: {
|
||||
in: $exclude
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
releasesTagsConnection: {
|
||||
none: {
|
||||
tag: {
|
||||
slug: {
|
||||
in: $excludeTags
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
first: $limit
|
||||
@@ -191,10 +201,10 @@ function initActorActions(store, _router) {
|
||||
first: $limit
|
||||
offset: $offset
|
||||
orderBy: $orderBy
|
||||
condition: {
|
||||
actorId: $actorId
|
||||
}
|
||||
filter: {
|
||||
actorId: {
|
||||
equalTo: $actorId
|
||||
}
|
||||
or: [
|
||||
{
|
||||
release: {
|
||||
@@ -205,6 +215,17 @@ function initActorActions(store, _router) {
|
||||
}
|
||||
},
|
||||
]
|
||||
${includeTags.length > 0 ? `release: {
|
||||
releasesTagsConnection: {
|
||||
some: {
|
||||
tag: {
|
||||
slug: {
|
||||
in: $includeTags
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}` : ''}
|
||||
}
|
||||
) {
|
||||
releases: nodes {
|
||||
@@ -221,8 +242,10 @@ function initActorActions(store, _router) {
|
||||
offset: Math.max(0, (pageNumber - 1)) * limit,
|
||||
after,
|
||||
before,
|
||||
selectableTags: config.selectableTags,
|
||||
orderBy: orderBy === 'DATE_DESC' ? 'RELEASE_BY_RELEASE_ID__DATE_DESC' : 'RELEASE_BY_RELEASE_ID__DATE_ASC',
|
||||
exclude: store.state.ui.filter,
|
||||
excludeTags: store.state.ui.filter,
|
||||
includeTags,
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user