-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Checklist-Overview with Activities #6026
Open
pmattmann
wants to merge
10
commits into
ecamp:devel
Choose a base branch
from
pmattmann:feature/checklist-overview-draft
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+535
−23
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
336f61f
draft
pmattmann 43c203f
lint
pmattmann a2ee35f
add navigation
pmattmann 7ad4b27
checklist-overview function-complete
pmattmann 29d8c86
on mounted, reload data
pmattmann ef01370
improve gui
pmattmann 2698965
checklist overview: reduce number of api-requests
pmattmann c9f5b9e
reload data on navigation
pmattmann 81d4075
fix copyAndPaste
pmattmann 8c7838f
checklist overview, sort activities
pmattmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
namespace App\Doctrine\Filter; | ||
|
||
use ApiPlatform\Doctrine\Orm\Filter\AbstractFilter; | ||
use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface; | ||
use ApiPlatform\Metadata\IriConverterInterface; | ||
use ApiPlatform\Metadata\Operation; | ||
use App\Entity\Activity; | ||
use App\Entity\ContentNode; | ||
use App\Repository\FiltersByCampCollaboration; | ||
use Doctrine\ORM\QueryBuilder; | ||
use Doctrine\Persistence\ManagerRegistry; | ||
use Psr\Log\LoggerInterface; | ||
use Symfony\Component\PropertyInfo\Type; | ||
use Symfony\Component\Serializer\NameConverter\NameConverterInterface; | ||
|
||
final class ContentNodeCampFilter extends AbstractFilter { | ||
use FiltersByCampCollaboration; | ||
|
||
public const CAMP_QUERY_NAME = 'camp'; | ||
|
||
public function __construct( | ||
private IriConverterInterface $iriConverter, | ||
ManagerRegistry $managerRegistry, | ||
?LoggerInterface $logger = null, | ||
?array $properties = null, | ||
?NameConverterInterface $nameConverter = null | ||
) { | ||
parent::__construct($managerRegistry, $logger, $properties, $nameConverter); | ||
} | ||
|
||
// This function is only used to hook in documentation generators (supported by Swagger and Hydra) | ||
public function getDescription(string $resourceClass): array { | ||
$description = []; | ||
$description['camp'] = [ | ||
'property' => self::CAMP_QUERY_NAME, | ||
'type' => Type::BUILTIN_TYPE_STRING, | ||
'required' => false, | ||
]; | ||
|
||
return $description; | ||
} | ||
|
||
protected function filterProperty( | ||
string $property, | ||
$value, | ||
QueryBuilder $queryBuilder, | ||
QueryNameGeneratorInterface $queryNameGenerator, | ||
string $resourceClass, | ||
?Operation $operation = null, | ||
array $context = [] | ||
): void { | ||
if (ContentNode::class !== $resourceClass && !is_subclass_of($resourceClass, ContentNode::class)) { | ||
throw new \Exception("ContentNodeCampFilter can only be applied to entities of type ContentNode (received: {$resourceClass})."); | ||
} | ||
|
||
if (self::CAMP_QUERY_NAME !== $property) { | ||
return; | ||
} | ||
|
||
// load camp from query parameter value | ||
$camp = $this->iriConverter->getResourceFromIri($value); | ||
|
||
// generate alias to avoid interference with other filters | ||
$campParameterName = $queryNameGenerator->generateParameterName($property); | ||
$periodJoinAlias = $queryNameGenerator->generateJoinAlias('period'); | ||
$activityJoinAlias = $queryNameGenerator->generateJoinAlias('activity'); | ||
$scheduleEntryJoinAlias = $queryNameGenerator->generateJoinAlias('scheduleEntry'); | ||
|
||
$rootAlias = $queryBuilder->getRootAliases()[0]; | ||
|
||
$rootQry = $queryBuilder->getEntityManager()->createQueryBuilder(); | ||
$rootQry | ||
->select("identity({$activityJoinAlias}.rootContentNode)") | ||
->from(Activity::class, $activityJoinAlias) | ||
->join("{$activityJoinAlias}.scheduleEntries", $scheduleEntryJoinAlias) | ||
->join("{$scheduleEntryJoinAlias}.period", $periodJoinAlias) | ||
->where($queryBuilder->expr()->eq("{$periodJoinAlias}.camp", ":{$campParameterName}")) | ||
; | ||
|
||
$queryBuilder->andWhere($queryBuilder->expr()->in("{$rootAlias}.root", $rootQry->getDQL())); | ||
$queryBuilder->setParameter($campParameterName, $camp); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hier könnte man dann mal noch optimieren, dass wir die listen url herausgeben. (mit filter oder subresource)