Skip to content

Commit

Permalink
Merge pull request #10 from fgtclb/add-option-completed-projects
Browse files Browse the repository at this point in the history
Add option to show/hide completed projects
  • Loading branch information
Riiiad authored Aug 26, 2024
2 parents f2e9cf0 + 0d0c7f1 commit 148613a
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 6 deletions.
9 changes: 8 additions & 1 deletion Classes/Controller/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public function __construct(

public function listAction(?ProjectFilter $filter = null): ResponseInterface
{
$hideCompletedProjects = true;

if (!$filter) {
$filter = new ProjectFilter();

Expand All @@ -29,7 +31,12 @@ public function listAction(?ProjectFilter $filter = null): ResponseInterface
}
}

if (isset($this->settings['hide_completed_projects'])) {
$hideCompletedProjects = (bool)$this->settings['hide_completed_projects'];
}

$projects = $this->projectRepository->findByFilter(
$hideCompletedProjects,
$filter,
GeneralUtility::intExplode(
',',
Expand All @@ -39,7 +46,7 @@ public function listAction(?ProjectFilter $filter = null): ResponseInterface
)
);

$categories =$this->categoryRepository->findAllApplicable($projects);
$categories = $this->categoryRepository->findAllApplicable($projects);

$assignedValues = [
'projects' => $projects,
Expand Down
18 changes: 15 additions & 3 deletions Classes/Domain/Repository/ProjectRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ProjectRepository extends Repository
* @throws InvalidEnumerationValueException
*/
public function findByFilter(
bool $hideCompletedProjects,
?ProjectFilter $filter = null,
array $pages = []
): QueryResult {
Expand All @@ -36,9 +37,20 @@ public function findByFilter(
}
}

$query->matching(
$query->logicalAnd($constraints)
);
if ($hideCompletedProjects) {
$constraints[] = $query->logicalOr(
$query->greaterThanOrEqual('tx_academicprojects_end_date', new \DateTime()),
$query->equals('tx_academicprojects_end_date', 0)
);
} else {
$query->getQuerySettings()->setIgnoreEnableFields(true);
}

if (!empty($constraints)) {
$query->matching(
$query->logicalAnd($constraints)
);
}

[$sortingField, $sortingDirection] = explode(' ', SortingOptions::__default);
if ($filter && $filter->getSorting()) {
Expand Down
10 changes: 10 additions & 0 deletions Configuration/FlexForms/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
</config>
</TCEforms>
</settings.filter.options>
<settings.hide_completed_projects>
<TCEforms>
<label>LLL:EXT:academic_projects/Resources/Private/Language/locallang_be.xlf:flexform.filter.options.hide_completed_projects</label>
<description>LLL:EXT:academic_projects/Resources/Private/Language/locallang_be.xlf:flexform.filter.options.hide_completed_projects.description</description>
<config>
<type>check</type>
<default>1</default>
</config>
</TCEforms>
</settings.hide_completed_projects>
<settings.sorting>
<TCEforms>
<label>LLL:EXT:academic_projects/Resources/Private/Language/locallang_be.xlf:flexform.sorting</label>
Expand Down
80 changes: 80 additions & 0 deletions Resources/Private/Language/de.locallang_be.xlf
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en, de" target-language="de" datatype="plaintext"
original="messages" date="2023-04-24T15:52:42Z">
<header>
<generator>PhpStorm</generator>
</header>
<body>
<trans-unit id="flexform.filter.options.title">
<source>Deactivate filtering</source>
<target>Filterung deaktivieren</target>
</trans-unit>
<trans-unit id="flexform.filter.options.description">
<source>If the option is enabled, options with filters will not be visible in the frontend</source>
<target>Wenn die Option aktiviert ist, sind Optionen mit Filtern im Frontend nicht sichtbar</target>
</trans-unit>
<trans-unit id="flexform.filter.options.hide_completed_projects">
<source>Hide completed projects</source>
<target>Abgeschlossene Projekte ausblenden</target>
</trans-unit>
<trans-unit id="flexform.filter.options.hide_completed_projects.description">
<source>Hide projects that have passed their end date from the overview.</source>
<target>Projekte, deren Enddatum überschritten ist, in der Übersicht ausblenden.</target>
</trans-unit>
<trans-unit id="flexform.sorting">
<source>Sorting</source>
<target>Sortierung</target>
</trans-unit>
<trans-unit id="flexform.sorting.description">
<source>Define sorting in frontend. Sort by page sorting doesn't respect multiple mounts as sort</source>
<target>Definieren Sie die Sortierung im Frontend. Die Seitensortierung berücksichtigt mehrere Mounts nicht als Sortierung</target>
</trans-unit>

<trans-unit id="flexform.sorting.lastUpdated.asc">
<source>Last updated (latest first)</source>
<target>Zuletzt aktualisiert (neueste zuerst)</target>
</trans-unit>
<trans-unit id="flexform.sorting.lastUpdated.desc">
<source>Last updated (latest last)</source>
<target>Zuletzt aktualisiert (neueste zuletzt)</target>
</trans-unit>
<trans-unit id="flexform.sorting.sorting.asc">
<source>Page sorting (Result may be unexpected)</source>
<target>Seitensortierung (Ergebnis kann unerwartet sein)</target>
</trans-unit>
<trans-unit id="flexform.sorting.sorting.desc">
<source>Page sorting (Result may be unexpected)</source>
<target>Seitensortierung (Ergebnis kann unerwartet sein)</target>
</trans-unit>
<trans-unit id="flexform.sorting.title.asc">
<source>Title A-Z</source>
<target>Titel A-Z</target>
</trans-unit>
<trans-unit id="flexform.sorting.title.desc">
<source>Title Z-A</source>
<target>Titel Z-A</target>
</trans-unit>
<trans-unit id="flexform.sorting.tx_academicprojects_budget.asc">
<source>Budget (low to high)</source>
<target>Budget (niedrig bis hoch)</target>
</trans-unit>
<trans-unit id="flexform.sorting.tx_academicprojects_budget.desc">
<source>Budget (high to low)</source>
<target>Budget (hoch bis niedrig)</target>
</trans-unit>
<trans-unit id="flexform.sorting.tx_academicprojects_start_date.asc">
<source>Start date (oldest first)</source>
<target>Startdatum (älteste zuerst)</target>
</trans-unit>
<trans-unit id="flexform.sorting.tx_academicprojects_start_date.desc">
<source>Start date (newest first)</source>
<target>Startdatum (neueste zuerst)</target>
</trans-unit>
<trans-unit id="flexform.category.description">
<source>Select categories. Main categories will select all subcategories by OR, multiple categories selects by AND</source>
<target>Wählen Sie Kategorien aus. Hauptkategorien wählen alle Unterkategorien durch ODER aus, mehrere Kategorien wählen durch UND aus</target>
</trans-unit>
</body>
</file>
</xliff>
8 changes: 6 additions & 2 deletions Resources/Private/Language/locallang_be.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
<trans-unit id="flexform.filter.options.description">
<source>If the option is enabled, options with filters will not be visible in the frontend</source>
</trans-unit>

<trans-unit id="flexform.filter.options.hide_completed_projects">
<source>Hide completed projects</source>
</trans-unit>
<trans-unit id="flexform.filter.options.hide_completed_projects.description">
<source>Hide projects that have passed their end date from the overview.</source>
</trans-unit>
<trans-unit id="flexform.sorting">
<source>Sorting</source>
</trans-unit>
Expand Down Expand Up @@ -50,7 +55,6 @@
<trans-unit id="flexform.sorting.tx_academicprojects_start_date.desc">
<source>Start date (newest first)</source>
</trans-unit>

<trans-unit id="flexform.category.description">
<source>Select categories. Main categories will select all subcategories by OR, multiple categories selects by AND</source>
</trans-unit>
Expand Down

0 comments on commit 148613a

Please sign in to comment.