Skip to content

Commit

Permalink
Merge pull request #5 from leanormandon/feature/improve-ui
Browse files Browse the repository at this point in the history
Feature/improve UI
  • Loading branch information
lopes-vincent committed Feb 12, 2024
2 parents 1043a35 + c02fbce commit ef2d368
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
19 changes: 9 additions & 10 deletions Config/module.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="http://thelia.net/schema/dic/module"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<module xmlns="http://thelia.net/schema/dic/module" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/module http://thelia.net/schema/dic/module/module-2_2.xsd">
<fullnamespace>TheliaCollection\TheliaCollection</fullnamespace>
<descriptive locale="en_US">
<title>Create a collection of any item and associate it to any other item</title>
<!--
<subtitle></subtitle>
<description></description>
<postscriptum></postscriptum>
-->
<title>Create a collection of any item and associate it to any other item</title>
<!--
<subtitle></subtitle>
<description></description>
<postscriptum></postscriptum>
-->
</descriptive>
<descriptive locale="fr_FR">
<title>Créer une collection de n'importe quel objet et associé la a n'importe quel autre objet</title>
<title>Créer une collection de n'importe quel objet et associé la a n'importe quel autre objet</title>
</descriptive>
<!-- <logo></logo> -->
<!--<images-folder>images</images-folder>-->
<languages>
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>1.0.0</version>
<version>1.1.1</version>
<authors>
<author>
<name></name>
Expand Down
24 changes: 16 additions & 8 deletions Hook/TheliaCollectionBackHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,32 @@

class TheliaCollectionBackHook extends BaseHook
{
public function onModuleConfig(HookRenderEvent $event)
{
$event->add($this->render('thelia-collection-configuration.html'));
}

public function onProductTab(HookRenderBlockEvent $event): void
{
$this->renderHookTab($event, 'product');
}

public function onCategoryTab(HookRenderBlockEvent $event): void
{
$this->renderHookTab($event, 'category');
}

public function onModuleConfig(HookRenderEvent $event)
public function onContentTab(HookRenderBlockEvent $event): void
{
$event->add($this->render('thelia-collection-configuration.html'));
$this->renderHookTab($event, 'content');
}

public function onContentTab(HookRenderBlockEvent $event): void
public function onFolderTab(HookRenderBlockEvent $event): void
{
$this->renderHookTab($event, 'folder');
}

private function renderHookTab(HookRenderBlockEvent $event, string $itemType): void
{
$itemId = $event->getArgument('id');
$event->add(
Expand All @@ -33,14 +45,10 @@ public function onContentTab(HookRenderBlockEvent $event): void
'manage-collection.html',
[
'itemId' => $itemId,
'itemType' => 'content',
'itemType' => $itemType,
]
),
]
);
}

public function onFolderTab(HookRenderBlockEvent $event): void
{
}
}
14 changes: 11 additions & 3 deletions Loop/TheliaCollectionItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @method string getItemType()
* @method int getItemId()
* @method int getTheliaCollectionId()
* @method string getCode()
*/
class TheliaCollectionItem extends BaseLoop implements PropelSearchLoopInterface
{
Expand All @@ -27,7 +28,8 @@ protected function getArgDefinitions()
Argument::createIntTypeArgument('id'),
Argument::createIntTypeArgument('item_id'),
Argument::createAlphaNumStringTypeArgument('item_type'),
Argument::createIntTypeArgument('thelia_collection_id')
Argument::createIntTypeArgument('thelia_collection_id'),
Argument::createAlphaNumStringTypeArgument('code')
);
}

Expand All @@ -43,6 +45,13 @@ public function buildModelCriteria()
$query->filterByTheliaCollectionId($theliaCollectionId);
}

if (null !== $code = $this->getCode()) {
$query
->useTheliaCollectionQuery()
->filterByCode($code)
->endUse();
}

if (null !== $itemId = $this->getItemId()) {
$query->filterByItemId($itemId);
}
Expand All @@ -66,8 +75,7 @@ public function parseResults(LoopResult $loopResult)
->set('THELIA_COLLECTION_ID', $entry->getTheliaCollectionId())
->set('POSITION', $entry->getPosition())
->set('ITEM_TYPE', $entry->getItemType())
->set('ITEM_ID', $entry->getItemId())
;
->set('ITEM_ID', $entry->getItemId());

$this->addOutputFields($row, $entry);

Expand Down

0 comments on commit ef2d368

Please sign in to comment.