Skip to content

Commit

Permalink
Merge pull request #113 from JaroslawZielinski/feature/105-frontend-v…
Browse files Browse the repository at this point in the history
…alidation-for-input

task-105: Frontend Validation for Input
  • Loading branch information
JaroslawZielinski authored Aug 30, 2024
2 parents fdd2320 + 058025b commit 1de8da5
Show file tree
Hide file tree
Showing 22 changed files with 529 additions and 41 deletions.
42 changes: 42 additions & 0 deletions Block/BibleTools/VerseConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

namespace JaroslawZielinski\TorahVerse\Block\BibleTools;

use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;

class VerseConfig extends Template
{
/**
* @var array
*/
private $tabs;

/**
* @inheritDoc
*/
public function __construct(
Context $context,
array $data = []
) {
$this->tabs = $data['tabs'] ?? [];
parent::__construct($context, $data);
}

/**
*/
public function getTabs(): array
{
return $this->tabs;
}

/**
*/
public function getActiveTab()
{
$keys = array_keys($this->tabs);
return reset($keys);
}
}
12 changes: 12 additions & 0 deletions Block/BibleTools/VerseSearch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace JaroslawZielinski\TorahVerse\Block\BibleTools;

use Magento\Framework\View\Element\Template;

class VerseSearch extends Template
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

declare(strict_types=1);

namespace JaroslawZielinski\TorahVerse\Controller\Siglum;
namespace JaroslawZielinski\TorahVerse\Controller\BibleTools;

use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;

class Pick extends Action
class VerseConfig extends Action
{
/**
* @var PageFactory
Expand Down
36 changes: 36 additions & 0 deletions Controller/BibleTools/VerseSearch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace JaroslawZielinski\TorahVerse\Controller\BibleTools;

use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;

class VerseSearch extends Action
{
/**
* @var PageFactory
*/
private $resultPageFactory;

/**
* @inheritDoc
*/
public function __construct(
PageFactory $resultPageFactory,
Context $context
) {
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}

/**
* @inheritDoc
*/
public function execute()
{
return $this->resultPageFactory->create();
}
}
6 changes: 3 additions & 3 deletions Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class Config

public const CONFIG_PATH_TORAHINPUT_DIVISION = 'jaroslawzielinski_torah/torah_input/division';

public const CONFIG_PATH_TORAHINPUT_FRONTENDENABLED = 'jaroslawzielinski_torah/torah_input/frontend_enabled';
public const CONFIG_PATH_TORAHINPUT_BIBLETOOLSENABLED = 'jaroslawzielinski_torah/torah_input/bibletools_enabled';

/**
* @var ScopeConfigInterface
Expand Down Expand Up @@ -500,9 +500,9 @@ public function getTorahInputDivision(): string
->getValue(self::CONFIG_PATH_TORAHINPUT_DIVISION, ScopeInterface::SCOPE_STORE);
}

public function isTorahInputFrontendEnabled(): bool
public function isTorahInputBibleToolsEnabled(): bool
{
return $this->scopeConfig
->isSetFlag(self::CONFIG_PATH_TORAHINPUT_FRONTENDENABLED, ScopeInterface::SCOPE_STORE);
->isSetFlag(self::CONFIG_PATH_TORAHINPUT_BIBLETOOLSENABLED, ScopeInterface::SCOPE_STORE);
}
}
4 changes: 2 additions & 2 deletions Plugin/Backend/Model/Menu/BuilderPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public function afterGetResult(Builder $subject, Menu $result): Menu
if (!$this->config->isModuleMenuEnabled()) {
$result->remove('JaroslawZielinski_TorahVerse::menu');
} else {
if (!$this->config->isTorahInputFrontendEnabled()) {
$result->remove('JaroslawZielinski_TorahVerse::versepick');
if (!$this->config->isTorahInputBibleToolsEnabled()) {
$result->remove('JaroslawZielinski_TorahVerse::tools');
}
}
return $result;
Expand Down
5 changes: 4 additions & 1 deletion Plugin/Backend/Model/Menu/ItemPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ public function __construct(UrlInterface $frontUrlModel)
public function afterGetUrl(Item $subject, $result)
{
$info = $subject->toArray();
if ('JaroslawZielinski_TorahVerse::versepick' === $info['resource']) {
if (in_array($info['resource'], [
'JaroslawZielinski_TorahVerse::versesearch',
'JaroslawZielinski_TorahVerse::verseconfig'
])) {
return $this->frontUrlModel->getUrl($info['action']);
}
return $result;
Expand Down
3 changes: 2 additions & 1 deletion etc/acl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

<resource id="JaroslawZielinski_TorahVerse::tools" title="TorahVerse Tools"
translate="title">
<resource id="JaroslawZielinski_TorahVerse::versepick" title="TorahVerse Pick Verse" />
<resource id="JaroslawZielinski_TorahVerse::versesearch" title="TorahVerse Search Verse" />
<resource id="JaroslawZielinski_TorahVerse::verseconfig" title="TorahVerse Verse Config" />
</resource>
</resource>

Expand Down
4 changes: 2 additions & 2 deletions etc/adminhtml/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
title="Bible Tools" translate="title" module="JaroslawZielinski_TorahVerse"
parent="JaroslawZielinski_TorahVerse::menu" sortOrder="30"/>

<add id="JaroslawZielinski_TorahVerse::versepick" resource="JaroslawZielinski_TorahVerse::versepick"
title="Verse Pick" action="torahverse/siglum/pick"
<add id="JaroslawZielinski_TorahVerse::verseconfig" resource="JaroslawZielinski_TorahVerse::verseconfig"
title="Verse Config" action="torahverse/bibletools/verseconfig"
module="JaroslawZielinski_TorahVerse" sortOrder="10" parent="JaroslawZielinski_TorahVerse::tools"
target="_blank" dependsOnModule="JaroslawZielinski_TorahVerse"/>
</menu>
Expand Down
Loading

0 comments on commit 1de8da5

Please sign in to comment.