init
This commit is contained in:
+2
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"><head><css src="Esun_CustomerMessage::css/admin-messages.css"/></head><body><referenceContainer name="content"><block class="Esun\CustomerMessage\Block\Adminhtml\Message\Index" name="esun.customer.message.admin" template="Esun_CustomerMessage::message/index.phtml" cacheable="false"/></referenceContainer></body></page>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<head>
|
||||
<css src="Esun_CustomerMessage::css/admin-order-unread.css"/>
|
||||
</head>
|
||||
</page>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/** @var \Esun\CustomerMessage\Block\Adminhtml\Message\Index $block */
|
||||
/** @var \Magento\Framework\Escaper $escaper */
|
||||
$threads = $block->getThreads();
|
||||
$thread = $block->getSelectedThread();
|
||||
$entries = $block->getMessages($thread);
|
||||
$order = $block->getOrder();
|
||||
$orderId = $order ? (int)$order->getEntityId() : (int)($thread['order_id'] ?? 0);
|
||||
$customerName = trim(implode(' ', array_filter([
|
||||
(string)($thread['customer_firstname'] ?? ($order ? $order->getCustomerFirstname() : '')),
|
||||
(string)($thread['customer_lastname'] ?? ($order ? $order->getCustomerLastname() : '')),
|
||||
])));
|
||||
$customerName = $customerName
|
||||
?: (string)($thread['customer_email'] ?? ($order ? $order->getCustomerEmail() : ''))
|
||||
?: (string)__('Customer');
|
||||
?>
|
||||
<div class="esun-admin-inbox">
|
||||
<aside class="esun-admin-inbox__threads">
|
||||
<div class="esun-admin-inbox__search"><input class="admin__control-text" type="search" placeholder="<?= $escaper->escapeHtmlAttr(__('Search conversations')) ?>" data-role="thread-search"></div>
|
||||
<?php foreach ($threads as $item): ?>
|
||||
<a class="esun-admin-thread <?= $thread && (int)$thread['thread_id'] === (int)$item['thread_id'] ? 'is-active' : '' ?>" data-search="<?= $escaper->escapeHtmlAttr(strtolower($item['customer_email'] . ' ' . $item['subject'] . ' ' . ($item['order_increment_id'] ?? ''))) ?>" href="<?= $escaper->escapeUrl($block->getUrl('esun_customer_message/message/index', ['thread_id' => (int)$item['thread_id']])) ?>">
|
||||
<strong><?= $escaper->escapeHtml($item['customer_email']) ?></strong>
|
||||
<span><?= $escaper->escapeHtml($item['subject']) ?></span>
|
||||
<small><?= $escaper->escapeHtml(mb_substr((string)$item['last_content'], 0, 70)) ?></small>
|
||||
<?php if ((int)$item['admin_unread_count']): ?><b><?= (int)$item['admin_unread_count'] ?></b><?php endif; ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</aside>
|
||||
<section class="esun-admin-inbox__conversation">
|
||||
<?php if ($thread || $order): ?>
|
||||
<header><div><h1><?= $escaper->escapeHtml($thread['subject'] ?? __('Order #%1', $order->getIncrementId())) ?></h1><span><?= $escaper->escapeHtml($thread['customer_email'] ?? $order->getCustomerEmail()) ?></span></div><?php if ($orderId): ?><a href="<?= $escaper->escapeUrl($block->getUrl('sales/order/view', ['order_id' => $orderId])) ?>"><?= $escaper->escapeHtml(__('View Order')) ?></a><?php endif; ?></header>
|
||||
<div class="esun-admin-inbox__entries">
|
||||
<?php if ($entries): foreach ($entries as $entry): ?>
|
||||
<article class="esun-admin-entry is-<?= $escaper->escapeHtmlAttr($entry['sender_type']) ?>">
|
||||
<small><?= $escaper->escapeHtml($entry['sender_type'] === 'admin' ? __('Manager') : $customerName) ?> · <?= $escaper->escapeHtml($block->formatDate($entry['created_at'], \IntlDateFormatter::MEDIUM, true)) ?></small>
|
||||
<div><?= nl2br($escaper->escapeHtml($entry['content'])) ?><?php if ($entry['attachments']): ?><div class="esun-admin-entry__images"><?php foreach ($entry['attachments'] as $attachment): ?><a href="<?= $escaper->escapeUrl($block->getUrl('esun_customer_message/attachment/view', ['id' => (int)$attachment['attachment_id']])) ?>" target="_blank" rel="noopener"><img src="<?= $escaper->escapeUrl($block->getUrl('esun_customer_message/attachment/view', ['id' => (int)$attachment['attachment_id']])) ?>" alt="<?= $escaper->escapeHtmlAttr($attachment['original_name']) ?>"></a><?php endforeach; ?></div><?php endif; ?></div>
|
||||
</article>
|
||||
<?php endforeach; else: ?><p class="esun-admin-inbox__empty"><?= $escaper->escapeHtml(__('Start an order conversation with this customer.')) ?></p><?php endif; ?>
|
||||
</div>
|
||||
<form class="esun-admin-reply" method="post" enctype="multipart/form-data" action="<?= $escaper->escapeUrl($block->getUrl('esun_customer_message/thread/reply')) ?>">
|
||||
<?= $block->getBlockHtml('formkey') ?>
|
||||
<?php if ($thread): ?><input type="hidden" name="thread_id" value="<?= (int)$thread['thread_id'] ?>"><?php endif; ?>
|
||||
<?php if ($orderId): ?><input type="hidden" name="order_id" value="<?= $orderId ?>"><?php endif; ?>
|
||||
<textarea class="admin__control-textarea" name="content" rows="4" placeholder="<?= $escaper->escapeHtmlAttr(__('Enter a reply...')) ?>"></textarea>
|
||||
<div><label class="action-secondary"><span><?= $escaper->escapeHtml(__('Add Images')) ?></span><input type="file" name="images[]" accept="image/jpeg,image/png,image/webp" multiple hidden></label><small><?= $escaper->escapeHtml(__('Up to 5 JPG, PNG or WebP images, 5 MB each.')) ?></small><button class="action-primary" type="submit"><?= $escaper->escapeHtml(__('Send')) ?></button></div>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<div class="esun-admin-inbox__placeholder"><h2><?= $escaper->escapeHtml(__('Customer Messages')) ?></h2><p><?= $escaper->escapeHtml(__('Select a conversation to view and reply.')) ?></p></div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
</div>
|
||||
<script>
|
||||
require(['jquery'], function ($) {
|
||||
'use strict';
|
||||
$('[data-role=thread-search]').on('input', function () {
|
||||
var query = this.value.toLowerCase();
|
||||
$('.esun-admin-thread').each(function () { $(this).toggle($(this).data('search').indexOf(query) !== -1); });
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0"?>
|
||||
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
|
||||
<columns name="sales_order_columns">
|
||||
<column name="esun_message_unread"
|
||||
class="Esun\CustomerMessage\Ui\Component\Listing\Column\AdminUnread"
|
||||
component="Esun_CustomerMessage/js/grid/columns/admin-unread"
|
||||
sortOrder="85">
|
||||
<settings>
|
||||
<bodyTmpl>ui/grid/cells/html</bodyTmpl>
|
||||
<disableAction>true</disableAction>
|
||||
<label translate="true">Unread Messages</label>
|
||||
<sortable>false</sortable>
|
||||
<filter>false</filter>
|
||||
<visible>true</visible>
|
||||
</settings>
|
||||
</column>
|
||||
</columns>
|
||||
</listing>
|
||||
@@ -0,0 +1 @@
|
||||
.esun-admin-inbox{background:#fff;border:1px solid #ddd;display:grid;grid-template-columns:360px minmax(0,1fr);height:calc(100vh - 180px);min-height:620px}.esun-admin-inbox__threads{border-right:1px solid #ddd;overflow-y:auto}.esun-admin-inbox__search{border-bottom:1px solid #ddd;padding:18px}.esun-admin-thread{border-bottom:1px solid #eee;color:#333;display:block;min-height:76px;padding:15px 45px 15px 18px;position:relative;text-decoration:none}.esun-admin-thread:hover,.esun-admin-thread.is-active{background:#f4faf7;color:#111;text-decoration:none}.esun-admin-thread strong,.esun-admin-thread span,.esun-admin-thread small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.esun-admin-thread span{margin-top:5px}.esun-admin-thread small{color:#999;margin-top:4px}.esun-admin-thread b{background:#18aa59;border-radius:99px;color:#fff;min-width:20px;padding:2px 6px;position:absolute;right:15px;text-align:center;top:18px}.esun-admin-inbox__conversation{display:flex;flex-direction:column;min-width:0}.esun-admin-inbox__conversation>header{align-items:center;border-bottom:1px solid #ddd;display:flex;justify-content:space-between;padding:18px 24px}.esun-admin-inbox__conversation h1{font-size:22px;margin:0 0 5px}.esun-admin-inbox__entries{flex:1;overflow-y:auto;padding:25px}.esun-admin-entry{margin:0 0 24px;max-width:70%}.esun-admin-entry.is-admin{margin-left:auto}.esun-admin-entry>small{color:#888;display:block;margin-bottom:7px}.esun-admin-entry.is-admin>small{text-align:right}.esun-admin-entry>div{background:#f5f5f5;border-radius:20px;padding:16px 20px}.esun-admin-entry.is-admin>div{background:#dff5ea}.esun-admin-entry__images{display:flex;flex-wrap:wrap;gap:10px;margin-top:12px}.esun-admin-entry__images img{background:#fff;height:100px;object-fit:cover;width:100px}.esun-admin-reply{border-top:1px solid #ddd;padding:18px 24px}.esun-admin-reply>.admin__control-textarea{box-sizing:border-box;display:block;min-height:120px;width:100%}.esun-admin-reply>div{align-items:center;display:flex;gap:14px;margin-top:12px}.esun-admin-reply button{margin-left:auto}.esun-admin-inbox__placeholder{color:#999;margin:auto;text-align:center}@media(max-width:900px){.esun-admin-inbox{grid-template-columns:280px minmax(0,1fr)}.esun-admin-entry{max-width:90%}}
|
||||
@@ -0,0 +1,26 @@
|
||||
.esun-admin-order-unread {
|
||||
align-items: center;
|
||||
display: inline-flex;
|
||||
gap: 7px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.esun-admin-order-unread__badge {
|
||||
align-items: center;
|
||||
background: #e22626;
|
||||
border-radius: 999px;
|
||||
box-sizing: border-box;
|
||||
color: #fff;
|
||||
display: inline-flex;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
height: 22px;
|
||||
justify-content: center;
|
||||
line-height: 22px;
|
||||
min-width: 22px;
|
||||
padding: 0 7px;
|
||||
}
|
||||
|
||||
.esun-admin-order-unread-empty {
|
||||
color: #adadad;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
define([
|
||||
'Magento_Ui/js/grid/columns/column'
|
||||
], function (Column) {
|
||||
'use strict';
|
||||
|
||||
return Column.extend({
|
||||
/**
|
||||
* Keep the order grid's default cell action away from message links.
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
getFieldHandler: function () {
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user