Skip to content

Commit

Permalink
[WIP] added descriptions for new tables fields. code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
anjeylink committed Aug 20, 2018
1 parent 529d16d commit 186acab
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Classes/Backend/FormDataProvider/OrderEditFormInitialize.php
Expand Up @@ -4,6 +4,7 @@
namespace Pixelant\PxaProductManager\Backend\FormDataProvider;

use Pixelant\PxaProductManager\Domain\Model\Order;
use Pixelant\PxaProductManager\Domain\Model\OrderFormField;
use Pixelant\PxaProductManager\Utility\MainUtility;
use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
use TYPO3\CMS\Core\Utility\StringUtility;
Expand Down Expand Up @@ -40,7 +41,7 @@ public function addData(array $result): array
foreach ($orderFields as $fieldName => $fieldConfiguration) {
// Add TCA
switch ($fieldConfiguration['type']) {
case Order::ORDERFIELD_TEXTAREA:
case OrderFormField::FIELD_TEXTAREA:
$result['processedTca']['columns'][$fieldName] = [
'label' => MainUtility::snakeCasePhraseToWords($fieldName),
'config' => [
Expand Down
4 changes: 1 addition & 3 deletions Classes/Controller/ProductController.php
Expand Up @@ -16,8 +16,6 @@
use Pixelant\PxaProductManager\Validation\ValidatorResolver;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\StringUtility;
use TYPO3\CMS\Extbase\Domain\Model\FrontendUser;
use TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository;
use TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
Expand Down Expand Up @@ -594,7 +592,7 @@ protected function createAndSaveOrder(OrderConfiguration $orderConfiguration, ar
/** @var OrderFormField $formField */
foreach ($orderConfiguration->getFormFields() as $formField) {
$orderFields[$formField->getUid()] = [
'value' => $formField->getValue(),
'value' => $formField->getValueAsText(),
'type' => $formField->getType()
];
}
Expand Down
4 changes: 0 additions & 4 deletions Classes/Domain/Model/Order.php
Expand Up @@ -36,10 +36,6 @@
*/
class Order extends AbstractDomainObject
{

const ORDERFIELD_INPUT = 'input';
const ORDERFIELD_TEXTAREA = 'textarea';

/**
* @var bool
*/
Expand Down
22 changes: 22 additions & 0 deletions Classes/Domain/Model/OrderFormField.php
Expand Up @@ -158,6 +158,28 @@ public function getValue(): string
return $this->value;
}

/**
* @return string
*/
public function getValueAsText(): string
{
switch ($this->value) {
case self::FIELD_SELECTBOX:
$optionUid = (int)$this->value;
/** @var Option $option */
foreach ($this->getOptions() as $option) {
if ($option->getUid() === $optionUid) {
return $option->getValue();
}
}
break;
default:
return $this->value;
}

return '';
}

/**
* @param string $value
*/
Expand Down
Expand Up @@ -22,7 +22,7 @@
],
'type' => 'type',
'sortby' => 'sorting',
'hideTable' => 1,
'hideTable' => true,
'searchFields' => 'name',
'iconfile' => 'EXT:pxa_product_manager/Resources/Public/Icons/Svg/form-field.svg'
],
Expand Down
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2018-08-20T15:29:57Z"
product-name="pxa_product_manager">
<header/>
<body>
<trans-unit id="name.description">
<source>Name of configuration.</source>
</trans-unit>
<trans-unit id="enabled_email_to_user.description">
<source>Send email to user. One of the inputs must be marked as user email.</source>
</trans-unit>
<trans-unit id="enabled_replace_with_fe_user_fields.description">
<source>Autofill form fields with Frontend user fields values. Name of form field must much FE user DB field name as camel case.</source>
</trans-unit>
<trans-unit id="admin_emails.description">
<source>List of admin emails</source>
</trans-unit>
</body>
</file>
</xliff>
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2018-08-20T15:29:57Z"
product-name="pxa_product_manager">
<header/>
<body>
<trans-unit id="name.description">
<source>Name of field. Should be same as FE user field in order to replace it automatically.</source>
</trans-unit>
<trans-unit id="user_email_field.description">
<source>Use this field as user email address.</source>
</trans-unit>
<trans-unit id="label.description">
<source>Field label.</source>
</trans-unit>
<trans-unit id="placeholder.description">
<source>Field placeholder.</source>
</trans-unit>
<trans-unit id="validation_rules.description">
<source>Select validations for field.</source>
</trans-unit>
<trans-unit id="type.description">
<source>Type of form field.</source>
</trans-unit>
</body>
</file>
</xliff>
4 changes: 3 additions & 1 deletion ext_tables.php
Expand Up @@ -18,7 +18,9 @@ function ($_EXTKEY) {
'tx_pxaproductmanager_domain_model_option',
'tx_pxaproductmanager_domain_model_link',
'tx_pxaproductmanager_domain_model_filter',
'tx_pxaproductmanager_domain_model_order'
'tx_pxaproductmanager_domain_model_order',
'tx_pxaproductmanager_domain_model_orderconfiguration',
'tx_pxaproductmanager_domain_model_orderformfield'
];

// @codingStandardsIgnoreStart
Expand Down

0 comments on commit 186acab

Please sign in to comment.