Skip to content

Commit

Permalink
Merge pull request #40 from Paazl/1.2.0
Browse files Browse the repository at this point in the history
1.2.0
  • Loading branch information
Marvin-Magmodules authored Feb 27, 2020
2 parents 3f686ef + d1f55d0 commit 947f595
Show file tree
Hide file tree
Showing 83 changed files with 2,576 additions and 582 deletions.
19 changes: 19 additions & 0 deletions Api/Data/Order/OrderReferenceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,23 @@ public function getExtSentAt();
* @return bool
*/
public function isSent();

/**
* Can resend order again after successful send.
*
* @return bool
*/
public function canResend();

/**
* Can resend order again after failed send.
*
* @return bool
*/
public function canRetry();

/**
* @return bool
*/
public function canEdit();
}
7 changes: 7 additions & 0 deletions Api/Data/Quote/QuoteReferenceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,11 @@ public function setTokenExpiresAt($value);
* @return string
*/
public function getTokenExpiresAt();

/**
* @param \DateTime|null $now
*
* @return bool
*/
public function isTokenExpired(\DateTime $now = null);
}
2 changes: 1 addition & 1 deletion Api/QuoteReferenceRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface QuoteReferenceRepositoryInterface
{

/**
* @param $quoteId
* @param int $quoteId
*
* @return QuoteReferenceInterface
* @throws NoSuchEntityException
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php
/**
* Copyright © 2019 Paazl. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Paazl\CheckoutWidget\Block\Adminhtml\Order\Create\Shipping\Method\Paazl\Widget;

use Magento\Backend\Block\Template;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Serialize\SerializerInterface;
use Paazl\CheckoutWidget\Model\CompositeConfigProvider;

/**
* PaazlShipping method block
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Config extends Template
{
/**
* Path to template file in theme.
*
* @var string
*/
protected $_template = 'Paazl_CheckoutWidget::order/create/shipping/method/paazl/widget/config.phtml';

/**
* @var CompositeConfigProvider
*/
protected $configProvider;

/**
* @var SerializerInterface
*/
private $serializer;

/**
* @param CompositeConfigProvider $configProvider
* @param SerializerInterface $serializer
* @param Context $context
* @param array $data
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __construct(
CompositeConfigProvider $configProvider,
SerializerInterface $serializer,
Context $context,
array $data = []
) {
$this->configProvider = $configProvider;
$this->serializer = $serializer;
parent::__construct($context, $data);
}

/**
* Retrieves order configuration
*
* @return array
*/
public function getWidgetConfig()
{
return $this->configProvider->getConfig();
}

/**
* Retrieves serialized order config.
*
* @return bool|string
*/
public function getSerializedWidgetConfig()
{
return $this->serializer->serialize($this->getWidgetConfig());
}
}
124 changes: 124 additions & 0 deletions Block/Adminhtml/Order/Create/Shipping/Method/Paazl/Widget/Modal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?php
/**
* Copyright © 2019 Paazl. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Paazl\CheckoutWidget\Block\Adminhtml\Order\Create\Shipping\Method\Paazl\Widget;

use Magento\Backend\Block\Template\Context;
use Magento\Backend\Block\Widget;
use Magento\Backend\Model\Session\Quote as SessionQuote;
use Magento\Framework\Serialize\SerializerInterface;
use Magento\Quote\Model\Quote;
use Magento\Store\Model\Store;

/**
* Adminhtml sales order create abstract block
*
* @SuppressWarnings(PHPMD.NumberOfChildren)
*/
class Modal extends Widget
{
/**
* Path to template file in theme.
*
* @var string
*/
protected $_template = 'Paazl_CheckoutWidget::order/create/shipping/method/paazl/widget/modal.phtml';

/**
* @var SerializerInterface
*/
private $serializer;

/**
* Session quote
*
* @var SessionQuote
*/
private $sessionQuote;

/**
* @param Context $context
* @param SerializerInterface $serializer
* @param SessionQuote $sessionQuote
* @param array $data
*/
public function __construct(
Context $context,
SerializerInterface $serializer,
SessionQuote $sessionQuote,
array $data = []
) {
$this->sessionQuote = $sessionQuote;
$this->serializer = $serializer;
parent::__construct($context, $data);
}

/**
* Retrieve quote session object
*
* @return SessionQuote
*/
protected function getSession()
{
return $this->sessionQuote;
}

/**
* Retrieve quote model object
*
* @return Quote
*/
public function getQuote()
{
return $this->getSession()->getQuote();
}

/**
* Retrieve customer identifier
*
* @return int
*/
public function getCustomerId()
{
return $this->getSession()->getCustomerId();
}

/**
* Retrieve store model object
*
* @return Store
*/
public function getStore()
{
return $this->getSession()->getStore();
}

/**
* Retrieve store identifier
*
* @return int
*/
public function getStoreId()
{
return $this->getSession()->getStoreId();
}

/**
* Initialize paazl modal widget
*
* @return string
*/
public function getPaazlWidgetModalJson()
{
return $this->serializer->serialize(
[
'paazlWidgetModal' => [
'modalClass' => 'ui-dialog-active ui-popup paazl-widget-modal'
],
]
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ public function getSaveUrl()
]
);
}
}
}
38 changes: 23 additions & 15 deletions Block/Adminhtml/Order/View/ShippingAndHandling/PaazlStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ protected function _prepareLayout()
return parent::_prepareLayout();
}

if ($this->getPaazlOrder()->isSent()) {
$onclick = "submitAndReloadArea($('paazl-order-status').parentNode.parentNode, '" . $this->getResendUrl() . "')";
if ($this->getPaazlOrder()->canResend()) {
$onclick = "submitAndReloadArea($('paazl-order-status').parentNode.parentNode, '" .
$this->getResendUrl() . "')";
$resendButton = $this->getLayout()
->createBlock(Button::class)
->setData([
Expand All @@ -80,18 +81,24 @@ protected function _prepareLayout()

return parent::_prepareLayout();
}
$onclick = "submitAndReloadArea($('paazl-order-status').parentNode.parentNode, '" . $this->getRetryUrl() . "')";
$retryButton = $this->getLayout()
->createBlock(Button::class)
->setData([
'label' => __('Retry'),
'class' => 'action-retry action-secondary',
'onclick' => $onclick
]);
$editBlock = $this->getLayout()
->createBlock(PaazlEdit::class);
$this->setChild('retry_button', $retryButton);
$this->setChild('edit_block', $editBlock);
if ($this->getPaazlOrder()->canEdit()) {
$editBlock = $this->getLayout()->createBlock(PaazlEdit::class);
$this->setChild('edit_block', $editBlock);
}

if ($this->getPaazlOrder()->canRetry()) {
$onclick = "submitAndReloadArea($('paazl-order-status').parentNode.parentNode, '" .
$this->getRetryUrl() . "')";
$retryButton = $this->getLayout()
->createBlock(Button::class)
->setData([
'label' => __('Retry'),
'class' => 'action-retry action-secondary',
'onclick' => $onclick
]);

$this->setChild('retry_button', $retryButton);
}

return parent::_prepareLayout();
}
Expand Down Expand Up @@ -158,7 +165,8 @@ public function getPaazlOrder()
{
if (null === $this->paazlOrder) {
try {
$this->paazlOrder = $this->getOrderReferenceRepository()->getByOrderId($this->getOrder()->getEntityId());
$this->paazlOrder =
$this->getOrderReferenceRepository()->getByOrderId($this->getOrder()->getEntityId());
} catch (NoSuchEntityException $exception) {
$this->paazlOrder = false;
}
Expand Down
15 changes: 4 additions & 11 deletions Block/Checkout/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use Magento\Framework\View\Element\Template;
use Paazl\CheckoutWidget\Model\Api\UrlProvider;
use Paazl\CheckoutWidget\Model\Api\UrlProviderFactory;
use Paazl\CheckoutWidget\Model\Checkout\WidgetConfigProvider;
use Paazl\CheckoutWidget\Model\Config;
use Magento\Framework\View\Element\Template\Context;
Expand Down Expand Up @@ -40,31 +41,23 @@ class Widget extends Template
*
* @param Context $context
* @param Config $scopeConfig
* @param UrlProvider $urlProvider
* @param UrlProviderFactory $urlProviderFactory
* @param WidgetConfigProvider $widgetConfigProvider
* @param array $data
*/
public function __construct(
Context $context,
Config $scopeConfig,
UrlProvider $urlProvider,
UrlProviderFactory $urlProviderFactory,
WidgetConfigProvider $widgetConfigProvider,
array $data = []
) {
$this->scopeConfig = $scopeConfig;
$this->widgetConfigProvider = $widgetConfigProvider;
$this->urlProvider = $urlProvider;
$this->urlProvider = $urlProviderFactory->create();
parent::__construct($context, $data);
}

/**
* @return string
*/
public function getWidgetConfigJson()
{
return json_encode($this->widgetConfigProvider->getConfig());
}

// ---

/**
Expand Down
10 changes: 7 additions & 3 deletions Controller/Adminhtml/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

abstract class Order extends Action
{
/** @var JsonFactory */
/**
* @var JsonFactory
*/
protected $resultJsonFactory;

/**
Expand All @@ -30,7 +32,9 @@ abstract class Order extends Action
*/
protected $orderRepository;

/** @var SendToService */
/**
* @var SendToService
*/
protected $sendToService;

/**
Expand Down Expand Up @@ -75,4 +79,4 @@ protected function _initOrder()
}
return $order;
}
}
}
Loading

0 comments on commit 947f595

Please sign in to comment.