Skip to content

Commit

Permalink
[TASK] Add sort order configuration to plugin
Browse files Browse the repository at this point in the history
Related: #79
  • Loading branch information
extcode committed Apr 22, 2020
1 parent 80c9622 commit b0ea3ad
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Classes/Controller/ActionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ public function injectCategoryRepository(CategoryRepository $categoryRepository)
*/
protected function createDemandObjectFromSettings(array $settings) : Demand
{
$demand = $this->objectManager->get(
Demand::class
);
$demand = new Demand();
$this->addCategoriesToDemandObjectFromSettings($demand);
if ($this->settings['orderBy']) {
$demand->setOrderBy($this->settings['orderBy']);
}

$arguments = $this->request->getArguments();

Expand Down
21 changes: 21 additions & 0 deletions Classes/Domain/Model/Dto/Demand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ class Demand extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/
protected $class = '';

/**
* @var string
*/
protected $orderBy = '';

/**
* @return string
*/
Expand Down Expand Up @@ -126,4 +131,20 @@ public function setActionAndClass($action, $class)
$this->action = $action;
$this->class = $class;
}

/**
* @return string
*/
public function getOrderBy(): string
{
return $this->orderBy;
}

/**
* @param string $orderBy
*/
public function setOrderBy(string $orderBy): void
{
$this->orderBy = $orderBy;
}
}
8 changes: 8 additions & 0 deletions Classes/Domain/Repository/CompanyRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ public function findDemanded(Demand $demand)
);
}

if (!empty($demand->getOrderBy())) {
$query->setOrderings(
[
$demand->getOrderBy() => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING
]
);
}

return $query->execute();
}

Expand Down
8 changes: 8 additions & 0 deletions Classes/Domain/Repository/ContactRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ public function findDemanded(Demand $demand)
);
}

if (!empty($demand->getOrderBy())) {
$query->setOrderings(
[
$demand->getOrderBy() => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING
]
);
}

return $query->execute();
}

Expand Down
19 changes: 19 additions & 0 deletions Configuration/FlexForms/CompaniesPlugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,25 @@
</TCEforms>
</switchableControllerActions>

<settings.orderBy>
<TCEforms>
<label>LLL:EXT:contacts/Resources/Private/Language/locallang_be.xlf:tx_contacts.plugin.companies.action.company.list.orderBy</label>
<config>
<type>select</type>
<items>
<numIndex index="0" type="array">
<numIndex index="0"></numIndex>
<numIndex index="1"></numIndex>
</numIndex>
<numIndex index="2">
<numIndex index="0">LLL:EXT:contacts/Resources/Private/Language/locallang_be.xlf:tx_contacts.plugin.companies.action.company.list.orderBy.name</numIndex>
<numIndex index="1">name</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</settings.orderBy>

<settings.companyUids>
<TCEforms>
<label>LLL:EXT:contacts/Resources/Private/Language/locallang_db.xlf:tx_contacts_domain_model_company</label>
Expand Down
19 changes: 19 additions & 0 deletions Configuration/FlexForms/ContactsPlugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@
</TCEforms>
</switchableControllerActions>

<settings.orderBy>
<TCEforms>
<label>LLL:EXT:contacts/Resources/Private/Language/locallang_be.xlf:tx_contacts.plugin.contacts.action.contact.list.orderBy</label>
<config>
<type>select</type>
<items>
<numIndex index="0" type="array">
<numIndex index="0"></numIndex>
<numIndex index="1"></numIndex>
</numIndex>
<numIndex index="2">
<numIndex index="0">LLL:EXT:contacts/Resources/Private/Language/locallang_be.xlf:tx_contacts.plugin.contacts.action.contact.list.orderBy.last_name</numIndex>
<numIndex index="1">last_name</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</settings.orderBy>

<settings.contactUids>
<TCEforms>
<label>LLL:EXT:contacts/Resources/Private/Language/locallang_db.xlf:tx_contacts_domain_model_contact</label>
Expand Down
16 changes: 16 additions & 0 deletions Resources/Private/Language/de.locallang_be.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@
<target>Standard</target>
</trans-unit>

<trans-unit id="tx_contacts.plugin.contacts.action.contact.list.orderBy">
<source>Sort Order</source>
<target>Sortierreihenfolge</target>
</trans-unit>
<trans-unit id="tx_contacts.plugin.contacts.action.contact.list.orderBy.last_name">
<source>Last Name</source>
<target>Nachname</target>
</trans-unit>
<trans-unit id="tx_contacts.plugin.contacts.action.contact.list.categories">
<source>Categories</source>
<target>Kategorie</target>
Expand All @@ -64,6 +72,14 @@
<target>mit Unterkategorien</target>
</trans-unit>

<trans-unit id="tx_contacts.plugin.companies.action.company.list.orderBy">
<source>Sort Order</source>
<target>Sortierreihenfolge</target>
</trans-unit>
<trans-unit id="tx_contacts.plugin.companies.action.company.list.orderBy.name">
<source>Name</source>
<target>Name</target>
</trans-unit>
<trans-unit id="tx_contacts.plugin.companies.action.company.list.categories">
<source>Categories</source>
<target>Kategorie</target>
Expand Down
12 changes: 12 additions & 0 deletions Resources/Private/Language/locallang_be.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,25 @@
<source>Default</source>
</trans-unit>

<trans-unit id="tx_contacts.plugin.contacts.action.contact.list.orderBy">
<source>Sort Order</source>
</trans-unit>
<trans-unit id="tx_contacts.plugin.contacts.action.contact.list.orderBy.last_name">
<source>Last Name</source>
</trans-unit>
<trans-unit id="tx_contacts.plugin.contacts.action.contact.list.categories">
<source>Categories</source>
</trans-unit>
<trans-unit id="tx_contacts.plugin.contacts.action.contact.list.subcategories">
<source>with Subcategories</source>
</trans-unit>

<trans-unit id="tx_contacts.plugin.companies.action.company.list.orderBy">
<source>Sort Order</source>
</trans-unit>
<trans-unit id="tx_contacts.plugin.companies.action.company.list.orderBy.name">
<source>Name</source>
</trans-unit>
<trans-unit id="tx_contacts.plugin.companies.action.company.list.categories">
<source>Categories</source>
</trans-unit>
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
'modify_tables' => '',
'clearCacheOnLoad' => 0,
'lockType' => '',
'version' => '2.6.1',
'version' => '2.7.0',
'constraints' => [
'depends' => [
'typo3' => '8.7.0-8.7.99',
Expand Down

0 comments on commit b0ea3ad

Please sign in to comment.