Skip to content

Commit

Permalink
WIP [TASK] Update CSS and HTML in BE view
Browse files Browse the repository at this point in the history
* Use TYPO3-native date input fields.
* Payment and shipping get background colors
  depending on their status.
* Use TYPO3-native layout functionality.
* Remove inline CSS
* Restyle list view (update filters, pagination)
* Restyle order view

Todo:
* Add changelog for new TypoScript option for
  search date format
* Update docs for TypoScript search date format
  • Loading branch information
rintisch committed Apr 1, 2024
1 parent 1ed3556 commit 8a85a27
Show file tree
Hide file tree
Showing 19 changed files with 507 additions and 410 deletions.
19 changes: 19 additions & 0 deletions Classes/Controller/Backend/Order/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Pagination\SimplePagination;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
Expand All @@ -37,6 +38,8 @@ class OrderController extends ActionController

protected array $searchArguments = [];

private PageRenderer $pageRenderer;

public function injectPersistenceManager(PersistenceManager $persistenceManager): void
{
$this->persistenceManager = $persistenceManager;
Expand All @@ -47,6 +50,11 @@ public function injectItemRepository(ItemRepository $itemRepository): void
$this->itemRepository = $itemRepository;
}

public function injectPageRenderer(PageRenderer $pageRenderer): void
{
$this->pageRenderer = $pageRenderer;
}

public function __construct(
protected readonly ModuleTemplateFactory $moduleTemplateFactory,
protected readonly IconFactory $iconFactory
Expand All @@ -65,6 +73,8 @@ public function listAction(int $currentPage = 1): ResponseInterface
{
$this->moduleTemplate = $this->moduleTemplateFactory->create($this->request);

$this->addBackendAssets();

$this->moduleTemplate->assign('settings', $this->settings);
$this->moduleTemplate->assign('searchArguments', $this->searchArguments);

Expand Down Expand Up @@ -125,6 +135,8 @@ public function showAction(Item $orderItem): ResponseInterface
{
$this->moduleTemplate = $this->moduleTemplateFactory->create($this->request);

$this->addBackendAssets();

$this->moduleTemplate->assign('settings', $this->settings);
$this->moduleTemplate->assign('orderItem', $orderItem);

Expand Down Expand Up @@ -234,4 +246,11 @@ public function getShippingStatus(): array
}
return $shippingStatusArray;
}

private function addBackendAssets(): void
{
$this->pageRenderer->addCssFile('EXT:cart/Resources/Public/Stylesheets/Backend/style.css');

$this->pageRenderer->loadJavaScriptModule('@extcode/cart/order-module.js');
}
}
8 changes: 8 additions & 0 deletions Configuration/JavaScriptModules.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
'dependencies' => ['backend'],
'imports' => [
'@extcode/cart/' => 'EXT:cart/Resources/Public/JavaScript/Backend/',
],
];
4 changes: 4 additions & 0 deletions Configuration/TypoScript/constants.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ plugin.tx_cart {
decimals = 2
}

search {
dateFormat = Y-m-d
}

validation {
orderItem {
fields {
Expand Down
6 changes: 0 additions & 6 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,6 @@ plugin.tx_cart {
}
}

module.tx_cart {
invoiceNumber < plugin.tx_cart.invoiceNumber
deliveryNumber < plugin.tx_cart.deliveryNumber
}


# use this lib to add custom information or content elements to your email template

temp.cartMailContentElement = RECORDS
Expand Down
20 changes: 19 additions & 1 deletion Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -536,17 +536,35 @@
<trans-unit id="tx_cart_domain_model_order_item.order_product">
<source>Order Product</source>
</trans-unit>
<trans-unit id="tx_cart_domain_model_order_item.order_order">
<source>Order</source>
</trans-unit>
<trans-unit id="tx_cart_domain_model_order_item.order_invoice">
<source>Invoice</source>
</trans-unit>
<trans-unit id="tx_cart_domain_model_order_item.order_shipping">
<source>Shipping</source>
</trans-unit>
<trans-unit id="tx_cart_domain_model_order_item.order_shipping.method">
<source>Method</source>
</trans-unit>
<trans-unit id="tx_cart_domain_model_order_item.order_delivery">
<source>Delivery</source>
</trans-unit>
<trans-unit id="tx_cart_domain_model_order_item.order_payment">
<source>Payment</source>
</trans-unit>
<trans-unit id="tx_cart_domain_model_order_item.order_payment.method">
<source>Method</source>
</trans-unit>
<trans-unit id="tx_cart_domain_model_order_item.items">
<source>Ordered items</source>
</trans-unit>
<trans-unit id="tx_cart_domain_model_order_item.crdate">
<source>Order Date</source>
</trans-unit>
<trans-unit id="tx_cart_domain_model_order_item.comment">
<source>Comment</source>
<source>Customer comment</source>
</trans-unit>
<trans-unit id="tx_cart_domain_model_order_item.accept_terms_and_conditions">
<source>I have read the general terms and conditions agree to them.</source>
Expand Down
207 changes: 116 additions & 91 deletions Resources/Private/Partials/Backend/Order/Filter/List.html
Original file line number Diff line number Diff line change
@@ -1,100 +1,125 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true">

<div class="tx_cart_module_products_filter">
<div class="tx_cart_module_products_filter_inner">

<f:form action="{action}" name="search" id="module_cartorders_search_form">
<div>
<label for="searchCustomer">
<f:translate key="filterCustomer"/>
</label>
<f:form.textfield property="customer" id="searchCustomer"
class="cart_module_search_field_string" value="{searchArguments.customer}"/>
</div><br />

<div class="col-50">
<div>
<label for="searchOrderNumber">
<f:translate key="filterOrderNumber"/>
</label>
<f:form.textfield property="orderNumber" id="searchOrderNumber"
class="cart_module_search_field_string" value="{searchArguments.orderNumber}"/>
</div>
<div>
<label for="searchOrderDateStart">
<f:translate key="filterStartDate"/>
</label>
<f:form.textfield property="orderDateStart" id="searchOrderDateStart"
class="cart_module_search_field_start cart_date"
value="{searchArguments.orderDateStart}"
type="date" />
</div>
<div>
<label for="searchOrderDateEnd">
<f:translate key="filterEndDate"/>
</label>
<f:form.textfield property="orderDateEnd" id="searchOrderDateEnd"
class="cart_module_search_field_end cart_date"
value="{searchArguments.orderDateEnd}"
type="date" />
</div>
</div>
<div class="col-50">
<div>
<label for="searchInvoiceNumber">
<f:translate key="filterInvoiceNumber"/>
</label>
<f:form.textfield property="invoiceNumber" id="searchInvoiceNumber"
class="cart_module_search_field_string"
value="{searchArguments.inoviceNumber}"/>
</div>
<div>
<label for="searchInvoiceDateStart">
<f:translate key="filterStartDate"/>
</label>
<f:form.textfield property="invoiceDateStart" id="searchInvoiceDateStart"
class="cart_module_search_field_start cart_date"
value="{searchArguments.invoiceDateStart}"
type="date" />
</div>
<div>
<label for="searchInvoiceDateEnd">
<f:translate key="filterEndDate"/>
</label>
<f:form.textfield property="invoiceDateEnd" id="searchInvoiceDateEnd"
class="cart_module_search_field_end cart_date"
value="{searchArguments.invoiceDateEnd}"
type="date" />
</div>
</div>
<div class="clear">&nbsp;</div><br />
<f:form action="{action}" name="search" class="mb-2">
<div class="row">
<div class="form-group col col-sm-4">
<label for="searchCustomer" class="form-label">
<f:translate key="filterCustomer"/>
</label>
<f:form.textfield property="customer" id="searchCustomer"
class="form-control"
value="{searchArguments.customer}"/>
</div>
</div>

<div class="col-50">
<label for="searchPaymentStatus">
<f:translate key="tx_cart_domain_model_order_payment"/>
<f:translate key="tx_cart_domain_model_order_payment.status"/>
</label>
<f:form.select property="paymentStatus" options="{paymentStatus}" optionValueField="key"
optionLabelField="value" value="{searchArguments.paymentStatus}"/>
</div>
<div class="col-50">
<label for="searchShippingStatus">
<f:translate key="tx_cart_domain_model_order_shipping"/>
<f:translate key="tx_cart_domain_model_order_shipping.status"/>
</label>
<f:form.select property="shippingStatus" options="{shippingStatus}" optionValueField="key"
optionLabelField="value" value="{searchArguments.paymentStatus}"/>
</div>
<div class="clear">&nbsp;</div><br />
<div class="row">
<div class="form-group col col-sm-3">
<label for="searchOrderNumber" class="form-label">
<f:translate key="filterOrderNumber"/>
</label>
<f:form.textfield property="orderNumber" id="searchOrderNumber"
class="form-control"
value="{searchArguments.orderNumber}"/>
</div>
<div class="form-group col col-sm-3">
<label for="searchOrderDateStart" class="form-label">
<f:translate key="filterStartDate"/>
</label>
<f:form.textfield
name="orderDateStart"
id="searchOrderDateStart"
value="{f:if(condition: searchArguments.orderDateStart, then: \" {f:format.date(format:'{settings.search.dateFormat}', date: '{searchArguments.orderDateStart}')}\")}"
additionalAttributes="{'autocomplete': 'off'}"
class="form-control t3js-datetimepicker t3js-clearable"
data="{date-type: 'date', date-format: '{settings.search.dateFormat}'}"/>
<f:form.hidden
property="orderDateStart"
value="{f:if(condition: searchArguments.orderDateStart, then: \"{f:format.date(format:'c', date: '{searchArguments.orderDateStart}')}\")}"
/>
</div>
<div class="form-group col col-sm-3">
<label for="searchOrderDateEnd" class="form-label">
<f:translate key="filterEndDate"/>
</label>
<f:form.textfield
name="orderDateEnd"
id="searchOrderDateEnd"
value="{f:if(condition: searchArguments.orderDateEnd, then: \" {f:format.date(format:'{settings.search.dateFormat}', date: '{searchArguments.orderDateEnd}')}\")}"
additionalAttributes="{'autocomplete': 'off'}"
class="form-control t3js-datetimepicker t3js-clearable"
data="{date-type: 'date'}"/>
<f:form.hidden
property="orderDateEnd"
value="{f:if(condition: searchArguments.orderDateEnd, then: \"{f:format.date(format:'c', date: '{searchArguments.orderDateEnd}')}\")}"
/>

<div class="col-25" style="float:right;">
<f:form.submit value="{f:translate(key: 'filter')}" class="searchall_submit"/>
</div>
</div>
</div>

<div class="clear">&nbsp;</div>
</f:form>
<div class="row">
<div class="form-group col col-sm-3">
<label for="searchInvoiceNumber" class="form-label">
<f:translate key="filterInvoiceNumber"/>
</label>
<f:form.textfield property="invoiceNumber" id="searchInvoiceNumber"
class="form-control"
value="{searchArguments.inoviceNumber}"/>
</div>
<div class="form-group col col-sm-3">
<label for="searchInvoiceDateStart" class="form-label">
<f:translate key="filterStartDate"/>
</label>
<f:form.textfield
name="searchInvoiceDateStart"
id="invoiceDateStart"
value="{f:if(condition: searchArguments.invoiceDateStart, then: \" {f:format.date(format:'{settings.search.dateFormat}', date: '{searchArguments.invoiceDateStart}')}\")}"
additionalAttributes="{'autocomplete': 'off'}"
class="form-control t3js-datetimepicker t3js-clearable"
data="{date-type: 'date'}"/>
<f:form.hidden
property="invoiceDateStart"
value="{f:if(condition: searchArguments.invoiceDateStart, then: \"{f:format.date(format:'c', date: '{searchArguments.invoiceDateStart}')}\")}"
/>
</div>
<div class="form-group col col-sm-3">
<label for="searchInvoiceDateEnd" class="form-label">
<f:translate key="filterEndDate"/>
</label>
<f:form.textfield
name="invoiceDateEnd"
id="searchInvoiceDateEnd"
value="{f:if(condition: searchArguments.invoiceDateEnd, then: \" {f:format.date(format:'{settings.search.dateFormat}', date: '{searchArguments.invoiceDateEnd}')}\")}"
additionalAttributes="{'autocomplete': 'off'}"
class="form-control t3js-datetimepicker t3js-clearable"
data="{date-type: 'date'}"/>
<f:form.hidden
property="invoiceDateEnd"
value="{f:if(condition: searchArguments.invoiceDateEnd, then: \"{f:format.date(format:'c', date: '{searchArguments.invoiceDateEnd}')}\")}"
/>
</div>
</div>

<div class="row">
<div class="col col-sm-3">
<label for="searchPaymentStatus" class="form-label">
<f:translate key="tx_cart_domain_model_order_payment"/>
<f:translate key="tx_cart_domain_model_order_payment.status"/>
</label>
<f:form.select id="searchPaymentStatus" class="form-select" property="paymentStatus"
options="{paymentStatus}" optionValueField="key" optionLabelField="value"
value="{searchArguments.paymentStatus}"/>
</div>
<div class="col col-sm-3">
<label for="searchShippingStatus" class="form-label">
<f:translate key="tx_cart_domain_model_order_shipping"/>
<f:translate key="tx_cart_domain_model_order_shipping.status"/>
</label>
<f:form.select id="searchShippingStatus" class="form-select" property="shippingStatus"
options="{shippingStatus}" optionValueField="key" optionLabelField="value"
value="{searchArguments.paymentStatus}"/>
</div>
</div>
</div>
<f:form.submit value="{f:translate(key: 'filter')}" class="my-3 btn btn-default"/>
</f:form>
</html>
14 changes: 5 additions & 9 deletions Resources/Private/Partials/Backend/Order/List/Item.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xmlns:cart="http://typo3.org/ns/Extcode/Cart/ViewHelpers"
data-namespace-typo3-fluid="true">

<tr class="db_list_normal">
<tr>
<td>
{orderItem.billingAddress.firstName}
</td>
Expand Down Expand Up @@ -32,23 +32,19 @@
<f:format.date format="d.m.Y" date="{orderItem.invoiceDate}"/>
</f:if>
</td>
<td style="width: 75px; text-align: right;">
<td class="cart-figure">
<cart:format.currency currencySign="{orderItem.currency}">{orderItem.totalGross}</cart:format.currency>
</td>
<td style="width: 75px; text-align: right;">
<td class="cart-figure">
<cart:format.currency currencySign="{orderItem.currency}">{orderItem.totalNet}</cart:format.currency>
</td>
<td class="order-payment-status-{orderItem.payment.status}">
{orderItem.payment.name} <br/>
(
<f:translate key="tx_cart_domain_model_order_payment.status.{orderItem.payment.status}"/>
)
(&nbsp;<f:translate key="tx_cart_domain_model_order_payment.status.{orderItem.payment.status}"/>&nbsp;)
</td>
<td class="order-shipping-status-{orderItem.shipping.status}">
{orderItem.shipping.name} <br/>
(
<f:translate key="tx_cart_domain_model_order_shipping.status.{orderItem.shipping.status}"/>
)
(&nbsp;<f:translate key="tx_cart_domain_model_order_shipping.status.{orderItem.shipping.status}"/>&nbsp;)
</td>
<td>
<f:render partial="Backend/Order/List/Actions"
Expand Down
Loading

0 comments on commit 8a85a27

Please sign in to comment.