Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions resources/js/app/components/filter-box.vue
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export default {
this.availableFilters = this.filterList;
} else if (this.rightTypes.length == 1 && this.filtersByType) {
this.availableFilters = this.filtersByType[this.rightTypes[0]];
this.queryFilter.filter.type = this.rightTypes[0];
} else {
this.availableFilters = this.filtersByType?.[this.queryFilter.filter.type] || [];
}
Expand Down Expand Up @@ -383,6 +384,10 @@ export default {
this.folder = null;
this.selectedSearchType = 'q';
this.queryFilter = this.getCleanQuery();
if (this.rightTypes.length == 1 && this.filtersByType) {
this.availableFilters = this.filtersByType[this.rightTypes[0]];
this.queryFilter.filter.type = this.rightTypes[0];
}
this.$emit('filter-reset');
},

Expand Down
4 changes: 2 additions & 2 deletions src/Controller/ModulesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ public function resources($id, string $type): void
}

/**
* Relation data load callig api `GET /:object_type/:id/relationships/:relation`
* Relation data load calling api `GET /:object_type/:id/relationships/:relation`
* Json response
*
* @param string|int $id The object ID.
Expand Down Expand Up @@ -532,7 +532,7 @@ protected function availableRelationshipsUrl(string $relation): string
$relationsSchema = $this->Schema->getRelationsSchema();
$types = $this->Modules->relatedTypes($relationsSchema, $relation);

return '/objects?filter[type][]=' . implode('&filter[type][]=', $types);
return count($types) === 1 ? sprintf('/%s', $types[0]) : '/objects?filter[type][]=' . implode('&filter[type][]=', $types);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/View/Helper/SchemaHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ public function filterListByType(array $filtersByType, ?array $schemasByType): a
foreach ($filtersByType as $type => $filters) {
$noSchema = empty($schemasByType) || !array_key_exists($type, $schemasByType);
$schemaProperties = $noSchema ? null : Hash::get($schemasByType, $type);
$schemaProperties = array_key_exists('properties', (array)$schemaProperties) ? $schemaProperties['properties'] : $schemaProperties;
$schemaProperties = $schemaProperties !== false ? $schemaProperties : null;
$list[$type] = self::filterList($filters, $schemaProperties);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Controller/ModulesControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ public function testAvailableRelationshipsUrl(): void
->willReturn(['documents']);

$url = $this->controller->availableRelationshipsUrl('test_relation');
static::assertEquals('/objects?filter[type][]=documents', $url);
static::assertEquals('/documents', $url);

$this->controller->Modules = $this->createMock(ModulesComponent::class);
$this->controller->Modules->method('relatedTypes')
Expand Down
Loading