init
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\ContactPopup\Block;
|
||||
|
||||
use Magento\Directory\Model\ResourceModel\Country\CollectionFactory;
|
||||
use Magento\Framework\View\Element\Template;
|
||||
|
||||
class Modal extends Template
|
||||
{
|
||||
public function __construct(
|
||||
Template\Context $context,
|
||||
private readonly CollectionFactory $countryCollectionFactory,
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
public function getCountryOptions(): array
|
||||
{
|
||||
return $this->countryCollectionFactory->create()
|
||||
->loadByStore()
|
||||
->toOptionArray(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\ContactPopup\Controller\Adminhtml\Submission;
|
||||
|
||||
use Esun\ContactPopup\Model\SubmissionFactory;
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\Controller\Result\Redirect;
|
||||
|
||||
class Delete extends Action
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Esun_ContactPopup::delete';
|
||||
|
||||
public function __construct(Action\Context $context, private readonly SubmissionFactory $submissionFactory)
|
||||
{
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute(): Redirect
|
||||
{
|
||||
try {
|
||||
$submission = $this->submissionFactory->create()->load((int)$this->getRequest()->getParam('entity_id'));
|
||||
if (!$submission->getId()) {
|
||||
throw new \RuntimeException('Submission not found.');
|
||||
}
|
||||
$submission->delete();
|
||||
$this->messageManager->addSuccessMessage(__('The contact message has been deleted.'));
|
||||
} catch (\Throwable $exception) {
|
||||
$this->messageManager->addErrorMessage(__('The contact message could not be deleted.'));
|
||||
}
|
||||
return $this->resultRedirectFactory->create()->setPath('*/*/');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\ContactPopup\Controller\Adminhtml\Submission;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\View\Result\Page;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
class Index extends Action
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Esun_ContactPopup::submissions';
|
||||
|
||||
public function __construct(Context $context, private readonly PageFactory $pageFactory)
|
||||
{
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute(): Page
|
||||
{
|
||||
$page = $this->pageFactory->create();
|
||||
$page->setActiveMenu('Esun_ContactPopup::submissions');
|
||||
$page->getConfig()->getTitle()->prepend(__('Contact Messages'));
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\ContactPopup\Controller\Adminhtml\Submission;
|
||||
|
||||
use Esun\ContactPopup\Model\ResourceModel\Submission\CollectionFactory;
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\Controller\Result\Redirect;
|
||||
use Magento\Ui\Component\MassAction\Filter;
|
||||
|
||||
class MassDelete extends Action
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Esun_ContactPopup::delete';
|
||||
|
||||
public function __construct(
|
||||
Action\Context $context,
|
||||
private readonly Filter $filter,
|
||||
private readonly CollectionFactory $collectionFactory
|
||||
) {
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute(): Redirect
|
||||
{
|
||||
$collection = $this->filter->getCollection($this->collectionFactory->create());
|
||||
$deleted = 0;
|
||||
foreach ($collection as $submission) {
|
||||
$submission->delete();
|
||||
$deleted++;
|
||||
}
|
||||
$this->messageManager->addSuccessMessage(__('A total of %1 message(s) have been deleted.', $deleted));
|
||||
return $this->resultRedirectFactory->create()->setPath('*/*/');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\ContactPopup\Controller\Index;
|
||||
|
||||
use Esun\ContactPopup\Model\Submission;
|
||||
use Esun\ContactPopup\Model\SubmissionFactory;
|
||||
use Magento\Contact\Model\ConfigInterface;
|
||||
use Magento\Contact\Model\MailInterface;
|
||||
use Magento\Framework\App\Action\HttpPostActionInterface;
|
||||
use Magento\Framework\App\RequestInterface;
|
||||
use Magento\Framework\Controller\Result\Json;
|
||||
use Magento\Framework\Controller\Result\JsonFactory;
|
||||
use Magento\Framework\DataObject;
|
||||
use Magento\Framework\Escaper;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Post implements HttpPostActionInterface
|
||||
{
|
||||
private const ALLOWED_CATEGORIES = [
|
||||
'Product',
|
||||
'Technical support',
|
||||
'Cooperation',
|
||||
'Other',
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
private readonly RequestInterface $request,
|
||||
private readonly JsonFactory $jsonFactory,
|
||||
private readonly ConfigInterface $contactsConfig,
|
||||
private readonly MailInterface $mail,
|
||||
private readonly SubmissionFactory $submissionFactory,
|
||||
private readonly Escaper $escaper,
|
||||
private readonly LoggerInterface $logger
|
||||
) {
|
||||
}
|
||||
|
||||
public function execute(): Json
|
||||
{
|
||||
$result = $this->jsonFactory->create();
|
||||
|
||||
try {
|
||||
$data = $this->validateRequest();
|
||||
$submission = $this->saveSubmission($data);
|
||||
} catch (\Magento\Framework\Exception\LocalizedException $exception) {
|
||||
return $this->errorResult($result, $exception->getMessage(), 422);
|
||||
} catch (\Throwable $exception) {
|
||||
$this->logger->critical($exception);
|
||||
return $this->errorResult($result, __('Unable to save your message. Please try again later.'), 500);
|
||||
}
|
||||
|
||||
$this->sendMail($submission, $data);
|
||||
|
||||
return $result->setData([
|
||||
'success' => true,
|
||||
'message' => (string)__('Thanks for contacting us. We will respond to you as soon as possible.'),
|
||||
]);
|
||||
}
|
||||
|
||||
private function validateRequest(): array
|
||||
{
|
||||
$company = trim((string)$this->request->getParam('company', ''));
|
||||
$category = trim((string)$this->request->getParam('question_category', ''));
|
||||
$name = trim((string)$this->request->getParam('name', ''));
|
||||
$email = trim((string)$this->request->getParam('email', ''));
|
||||
$country = trim((string)$this->request->getParam('country', ''));
|
||||
$details = trim((string)$this->request->getParam('details', ''));
|
||||
|
||||
if (trim((string)$this->request->getParam('hideit', '')) !== '') {
|
||||
throw new \Magento\Framework\Exception\LocalizedException(__('Unable to submit the form.'));
|
||||
}
|
||||
if (!in_array($category, self::ALLOWED_CATEGORIES, true)) {
|
||||
throw new \Magento\Framework\Exception\LocalizedException(__('Select a question category.'));
|
||||
}
|
||||
if ($name === '') {
|
||||
throw new \Magento\Framework\Exception\LocalizedException(__('Enter your name.'));
|
||||
}
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
throw new \Magento\Framework\Exception\LocalizedException(__('Enter a valid email address.'));
|
||||
}
|
||||
if ($country === '') {
|
||||
throw new \Magento\Framework\Exception\LocalizedException(__('Enter your country.'));
|
||||
}
|
||||
if ($details === '') {
|
||||
throw new \Magento\Framework\Exception\LocalizedException(__('Enter the details.'));
|
||||
}
|
||||
if (
|
||||
mb_strlen($company) > 255 || mb_strlen($name) > 255 ||
|
||||
mb_strlen($email) > 255 || mb_strlen($country) > 255
|
||||
) {
|
||||
throw new \Magento\Framework\Exception\LocalizedException(__('One or more fields are too long.'));
|
||||
}
|
||||
if (mb_strlen($details) > 5000) {
|
||||
throw new \Magento\Framework\Exception\LocalizedException(__('The details must not exceed 5000 characters.'));
|
||||
}
|
||||
|
||||
return compact('company', 'category', 'name', 'email', 'country', 'details');
|
||||
}
|
||||
|
||||
private function saveSubmission(array $data): Submission
|
||||
{
|
||||
$submission = $this->submissionFactory->create();
|
||||
$submission->setData([
|
||||
'company' => $data['company'],
|
||||
'question_category' => $data['category'],
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'country' => $data['country'],
|
||||
'details' => $data['details'],
|
||||
'mail_status' => 'pending',
|
||||
]);
|
||||
$submission->save();
|
||||
return $submission;
|
||||
}
|
||||
|
||||
private function sendMail(Submission $submission, array $data): void
|
||||
{
|
||||
if (!$this->contactsConfig->isEnabled()) {
|
||||
$submission->setData('mail_status', 'disabled')->save();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->mail->send($data['email'], ['data' => new DataObject($this->buildMailData($data))]);
|
||||
$submission->setData('mail_status', 'sent')->setData('mail_error', null)->save();
|
||||
} catch (\Throwable $exception) {
|
||||
$this->logger->critical($exception);
|
||||
try {
|
||||
$submission->setData('mail_status', 'failed')
|
||||
->setData('mail_error', mb_substr($exception->getMessage(), 0, 2000))
|
||||
->save();
|
||||
} catch (\Throwable $saveException) {
|
||||
$this->logger->critical($saveException);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function buildMailData(array $data): array
|
||||
{
|
||||
$message = [
|
||||
$this->mailLine(__('Company Name'), $data['company'] !== '' ? $data['company'] : '-'),
|
||||
$this->mailLine(__('Question Category'), $data['category']),
|
||||
$this->mailLine(__('Country'), $data['country']),
|
||||
'',
|
||||
$this->escaper->escapeHtml((string)__('Details')) . ':<br>' .
|
||||
nl2br($this->escaper->escapeHtml($data['details']), false),
|
||||
];
|
||||
|
||||
return [
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'telephone' => '',
|
||||
'comment' => implode('<br>', $message),
|
||||
];
|
||||
}
|
||||
|
||||
private function mailLine(\Stringable|string $label, string $value): string
|
||||
{
|
||||
return $this->escaper->escapeHtml((string)$label) . ': ' . $this->escaper->escapeHtml($value);
|
||||
}
|
||||
|
||||
private function errorResult(Json $result, \Stringable|string $message, int $statusCode): Json
|
||||
{
|
||||
$result->setHttpResponseCode($statusCode);
|
||||
return $result->setData([
|
||||
'success' => false,
|
||||
'message' => (string)$message,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\ContactPopup\Model\ResourceModel;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
|
||||
|
||||
class Submission extends AbstractDb
|
||||
{
|
||||
protected function _construct(): void
|
||||
{
|
||||
$this->_init('esun_contact_popup_submission', 'entity_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\ContactPopup\Model\ResourceModel\Submission;
|
||||
|
||||
use Esun\ContactPopup\Model\ResourceModel\Submission as SubmissionResource;
|
||||
use Esun\ContactPopup\Model\Submission;
|
||||
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
||||
|
||||
class Collection extends AbstractCollection
|
||||
{
|
||||
protected function _construct(): void
|
||||
{
|
||||
$this->_init(Submission::class, SubmissionResource::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\ContactPopup\Model;
|
||||
|
||||
use Magento\Framework\Model\AbstractModel;
|
||||
|
||||
class Submission extends AbstractModel
|
||||
{
|
||||
protected function _construct(): void
|
||||
{
|
||||
$this->_init(\Esun\ContactPopup\Model\ResourceModel\Submission::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\ContactPopup\Ui\Component\Listing\Column;
|
||||
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Ui\Component\Listing\Columns\Column;
|
||||
|
||||
class SubmissionActions extends Column
|
||||
{
|
||||
public function __construct(
|
||||
\Magento\Framework\View\Element\UiComponent\ContextInterface $context,
|
||||
\Magento\Framework\View\Element\UiComponentFactory $uiComponentFactory,
|
||||
private readonly UrlInterface $urlBuilder,
|
||||
array $components = [],
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $uiComponentFactory, $components, $data);
|
||||
}
|
||||
|
||||
public function prepareDataSource(array $dataSource): array
|
||||
{
|
||||
if (!isset($dataSource['data']['items'])) {
|
||||
return $dataSource;
|
||||
}
|
||||
foreach ($dataSource['data']['items'] as &$item) {
|
||||
if (!isset($item['entity_id'])) {
|
||||
continue;
|
||||
}
|
||||
$item[$this->getData('name')]['delete'] = [
|
||||
'href' => $this->urlBuilder->getUrl('esun_contact_popup/submission/delete', ['entity_id' => $item['entity_id']]),
|
||||
'label' => __('Delete'),
|
||||
'confirm' => [
|
||||
'title' => __('Delete contact message'),
|
||||
'message' => __('Are you sure you want to delete this contact message?'),
|
||||
],
|
||||
'post' => true,
|
||||
];
|
||||
}
|
||||
unset($item);
|
||||
return $dataSource;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
|
||||
<acl>
|
||||
<resources>
|
||||
<resource id="Magento_Backend::admin">
|
||||
<resource id="Esun_ImageManager::esun" title="Esun" sortOrder="85">
|
||||
<resource id="Esun_ContactPopup::submissions" title="Contact Messages" sortOrder="80">
|
||||
<resource id="Esun_ContactPopup::delete" title="Delete Contact Messages" sortOrder="10"/>
|
||||
</resource>
|
||||
</resource>
|
||||
</resource>
|
||||
</resources>
|
||||
</acl>
|
||||
</config>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
|
||||
<menu>
|
||||
<add id="Esun_ContactPopup::submissions"
|
||||
title="Contact Messages"
|
||||
module="Esun_ContactPopup"
|
||||
sortOrder="80"
|
||||
parent="Esun_ImageManager::esun"
|
||||
action="esun_contact_popup/submission/index"
|
||||
resource="Esun_ContactPopup::submissions"/>
|
||||
</menu>
|
||||
</config>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework/App/etc/routes.xsd">
|
||||
<router id="admin">
|
||||
<route id="esun_contact_popup" frontName="esun_contact_popup">
|
||||
<module name="Esun_ContactPopup" before="Magento_Backend"/>
|
||||
</route>
|
||||
</router>
|
||||
</config>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0"?>
|
||||
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
|
||||
<table name="esun_contact_popup_submission" resource="default" engine="innodb" comment="eSUN Contact Popup Submissions">
|
||||
<column xsi:type="int" name="entity_id" unsigned="true" nullable="false" identity="true" comment="Entity ID"/>
|
||||
<column xsi:type="varchar" name="company" nullable="false" length="255" default="" comment="Company Name"/>
|
||||
<column xsi:type="varchar" name="question_category" nullable="false" length="64" comment="Question Category"/>
|
||||
<column xsi:type="varchar" name="name" nullable="false" length="255" comment="Name"/>
|
||||
<column xsi:type="varchar" name="email" nullable="false" length="255" comment="Email"/>
|
||||
<column xsi:type="varchar" name="country" nullable="false" length="255" comment="Country"/>
|
||||
<column xsi:type="text" name="details" nullable="false" comment="Details"/>
|
||||
<column xsi:type="varchar" name="mail_status" nullable="false" length="32" default="pending" comment="Mail Status"/>
|
||||
<column xsi:type="text" name="mail_error" nullable="true" comment="Mail Error"/>
|
||||
<column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/>
|
||||
<constraint xsi:type="primary" referenceId="PRIMARY"><column name="entity_id"/></constraint>
|
||||
<index referenceId="ESUN_CONTACT_POPUP_SUBMISSION_EMAIL" indexType="btree"><column name="email"/></index>
|
||||
<index referenceId="ESUN_CONTACT_POPUP_SUBMISSION_CREATED_AT" indexType="btree"><column name="created_at"/></index>
|
||||
</table>
|
||||
</schema>
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"esun_contact_popup_submission": {
|
||||
"column": {
|
||||
"entity_id": true,
|
||||
"company": true,
|
||||
"question_category": true,
|
||||
"name": true,
|
||||
"email": true,
|
||||
"country": true,
|
||||
"details": true,
|
||||
"mail_status": true,
|
||||
"mail_error": true,
|
||||
"created_at": true
|
||||
},
|
||||
"index": {
|
||||
"ESUN_CONTACT_POPUP_SUBMISSION_EMAIL": true,
|
||||
"ESUN_CONTACT_POPUP_SUBMISSION_CREATED_AT": true
|
||||
},
|
||||
"constraint": {"PRIMARY": true}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
|
||||
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
|
||||
<arguments>
|
||||
<argument name="collections" xsi:type="array">
|
||||
<item name="esun_contact_popup_submission_listing_data_source" xsi:type="string">EsunContactPopupSubmissionGridCollection</item>
|
||||
</argument>
|
||||
</arguments>
|
||||
</type>
|
||||
<virtualType name="EsunContactPopupSubmissionGridCollection"
|
||||
type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
|
||||
<arguments>
|
||||
<argument name="mainTable" xsi:type="string">esun_contact_popup_submission</argument>
|
||||
<argument name="resourceModel" xsi:type="string">Esun\ContactPopup\Model\ResourceModel\Submission</argument>
|
||||
</arguments>
|
||||
</virtualType>
|
||||
</config>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
|
||||
<router id="standard">
|
||||
<route id="contact_popup" frontName="contact-popup">
|
||||
<module name="Esun_ContactPopup"/>
|
||||
</route>
|
||||
</router>
|
||||
</config>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
|
||||
<module name="Esun_ContactPopup">
|
||||
<sequence>
|
||||
<module name="Magento_Contact"/>
|
||||
<module name="Magento_Directory"/>
|
||||
<module name="Magento_Ui"/>
|
||||
</sequence>
|
||||
</module>
|
||||
</config>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
ComponentRegistrar::register(
|
||||
ComponentRegistrar::MODULE,
|
||||
'Esun_ContactPopup',
|
||||
__DIR__
|
||||
);
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?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">
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<uiComponent name="esun_contact_popup_submission_listing"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
<?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">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="js_config" xsi:type="array">
|
||||
<item name="provider" xsi:type="string">esun_contact_popup_submission_listing.esun_contact_popup_submission_listing_data_source</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<spinner>esun_contact_popup_submission_columns</spinner>
|
||||
<deps><dep>esun_contact_popup_submission_listing.esun_contact_popup_submission_listing_data_source</dep></deps>
|
||||
</settings>
|
||||
<dataSource name="esun_contact_popup_submission_listing_data_source" component="Magento_Ui/js/grid/provider">
|
||||
<settings>
|
||||
<storageConfig><param name="indexField" xsi:type="string">entity_id</param></storageConfig>
|
||||
<updateUrl path="mui/index/render"/>
|
||||
</settings>
|
||||
<aclResource>Esun_ContactPopup::submissions</aclResource>
|
||||
<dataProvider class="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider"
|
||||
name="esun_contact_popup_submission_listing_data_source">
|
||||
<settings><requestFieldName>id</requestFieldName><primaryFieldName>entity_id</primaryFieldName></settings>
|
||||
</dataProvider>
|
||||
</dataSource>
|
||||
<listingToolbar name="listing_top">
|
||||
<settings><sticky>true</sticky></settings>
|
||||
<bookmark name="bookmarks"/>
|
||||
<columnsControls name="columns_controls"/>
|
||||
<filters name="listing_filters"/>
|
||||
<massaction name="listing_massaction">
|
||||
<action name="delete">
|
||||
<settings>
|
||||
<confirm>
|
||||
<message translate="true">Are you sure you want to delete the selected messages?</message>
|
||||
<title translate="true">Delete contact messages</title>
|
||||
</confirm>
|
||||
<url path="esun_contact_popup/submission/massDelete"/>
|
||||
<type>delete</type><label translate="true">Delete</label>
|
||||
</settings>
|
||||
</action>
|
||||
</massaction>
|
||||
<paging name="listing_paging"/>
|
||||
</listingToolbar>
|
||||
<columns name="esun_contact_popup_submission_columns">
|
||||
<selectionsColumn name="ids"><settings><indexField>entity_id</indexField></settings></selectionsColumn>
|
||||
<column name="entity_id"><settings><filter>textRange</filter><label translate="true">ID</label><sorting>desc</sorting></settings></column>
|
||||
<column name="company"><settings><filter>text</filter><label translate="true">Company Name</label></settings></column>
|
||||
<column name="question_category"><settings><filter>text</filter><label translate="true">Question Category</label></settings></column>
|
||||
<column name="name"><settings><filter>text</filter><label translate="true">Name</label></settings></column>
|
||||
<column name="email"><settings><filter>text</filter><label translate="true">Email</label></settings></column>
|
||||
<column name="country"><settings><filter>text</filter><label translate="true">Country</label></settings></column>
|
||||
<column name="details"><settings><filter>text</filter><label translate="true">Details</label></settings></column>
|
||||
<column name="mail_status"><settings><filter>text</filter><label translate="true">Mail Status</label></settings></column>
|
||||
<column name="mail_error"><settings><filter>text</filter><label translate="true">Mail Error</label><visible>false</visible></settings></column>
|
||||
<column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date">
|
||||
<settings><filter>dateRange</filter><dataType>date</dataType><label translate="true">Submitted At</label></settings>
|
||||
</column>
|
||||
<actionsColumn name="actions" class="Esun\ContactPopup\Ui\Component\Listing\Column\SubmissionActions">
|
||||
<settings><indexField>entity_id</indexField><resizeEnabled>false</resizeEnabled><resizeDefaultWidth>90</resizeDefaultWidth></settings>
|
||||
</actionsColumn>
|
||||
</columns>
|
||||
</listing>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?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_ContactPopup::css/contact-popup.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<referenceContainer name="before.body.end">
|
||||
<block class="Esun\ContactPopup\Block\Modal"
|
||||
name="esun.contact.popup"
|
||||
template="Esun_ContactPopup::modal.phtml"
|
||||
ifconfig="contact/contact/enabled"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/** @var \Esun\ContactPopup\Block\Modal $block */
|
||||
/** @var \Magento\Framework\Escaper $escaper */
|
||||
$formId = 'esun-contact-inline-' . substr(sha1($block->getNameInLayout()), 0, 10);
|
||||
?>
|
||||
<div class="esun-contact-popup esun-contact-inline">
|
||||
<form id="<?= $escaper->escapeHtmlAttr($formId) ?>"
|
||||
class="esun-contact-popup__form esun-contact-inline__form"
|
||||
action="<?= $escaper->escapeUrl($block->getUrl('contact-popup/index/post')) ?>"
|
||||
method="post"
|
||||
data-role="esun-contact-inline-form"
|
||||
novalidate>
|
||||
<?= /* @noEscape */ $block->getBlockHtml('formkey') ?>
|
||||
|
||||
<div class="esun-contact-popup__status" data-role="contact-status"
|
||||
role="status" aria-live="polite"></div>
|
||||
|
||||
<div class="esun-contact-popup__field esun-contact-popup__field--full">
|
||||
<label class="esun-contact-popup__label" for="<?= $escaper->escapeHtmlAttr($formId) ?>-company">
|
||||
<?= $escaper->escapeHtml(__('Company Name')) ?>
|
||||
</label>
|
||||
<input class="input-text" type="text"
|
||||
id="<?= $escaper->escapeHtmlAttr($formId) ?>-company"
|
||||
name="company" maxlength="255"
|
||||
placeholder="<?= $escaper->escapeHtmlAttr(__('Company Name')) ?>"/>
|
||||
</div>
|
||||
|
||||
<div class="esun-contact-popup__grid">
|
||||
<div class="esun-contact-popup__field required">
|
||||
<label class="esun-contact-popup__label" for="<?= $escaper->escapeHtmlAttr($formId) ?>-category">
|
||||
<?= $escaper->escapeHtml(__('Question category')) ?>
|
||||
</label>
|
||||
<select id="<?= $escaper->escapeHtmlAttr($formId) ?>-category"
|
||||
name="question_category" required data-validate="{required:true}">
|
||||
<option value=""><?= $escaper->escapeHtml(__('Question category')) ?></option>
|
||||
<option value="Product"><?= $escaper->escapeHtml(__('Product')) ?></option>
|
||||
<option value="Technical support"><?= $escaper->escapeHtml(__('Technical support')) ?></option>
|
||||
<option value="Cooperation"><?= $escaper->escapeHtml(__('Cooperation')) ?></option>
|
||||
<option value="Other"><?= $escaper->escapeHtml(__('Other')) ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="esun-contact-popup__field required">
|
||||
<label class="esun-contact-popup__label" for="<?= $escaper->escapeHtmlAttr($formId) ?>-name">
|
||||
<?= $escaper->escapeHtml(__('Name')) ?>
|
||||
</label>
|
||||
<input class="input-text" type="text"
|
||||
id="<?= $escaper->escapeHtmlAttr($formId) ?>-name"
|
||||
name="name" maxlength="255" autocomplete="name" required
|
||||
data-validate="{required:true}"
|
||||
placeholder="<?= $escaper->escapeHtmlAttr(__('* Name')) ?>"/>
|
||||
</div>
|
||||
|
||||
<div class="esun-contact-popup__field required">
|
||||
<label class="esun-contact-popup__label" for="<?= $escaper->escapeHtmlAttr($formId) ?>-email">
|
||||
<?= $escaper->escapeHtml(__('Email')) ?>
|
||||
</label>
|
||||
<input class="input-text" type="email"
|
||||
id="<?= $escaper->escapeHtmlAttr($formId) ?>-email"
|
||||
name="email" autocomplete="email" required
|
||||
data-validate="{required:true, 'validate-email':true}"
|
||||
placeholder="<?= $escaper->escapeHtmlAttr(__('* Email (We will reply to you via email)')) ?>"/>
|
||||
</div>
|
||||
|
||||
<div class="esun-contact-popup__field required">
|
||||
<label class="esun-contact-popup__label" for="<?= $escaper->escapeHtmlAttr($formId) ?>-country">
|
||||
<?= $escaper->escapeHtml(__('Country')) ?>
|
||||
</label>
|
||||
<select id="<?= $escaper->escapeHtmlAttr($formId) ?>-country"
|
||||
name="country" required data-validate="{required:true}">
|
||||
<option value=""><?= $escaper->escapeHtml(__('* Country')) ?></option>
|
||||
<?php foreach ($block->getCountryOptions() as $country): ?>
|
||||
<option value="<?= $escaper->escapeHtmlAttr((string)$country['label']) ?>">
|
||||
<?= $escaper->escapeHtml((string)$country['label']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="esun-contact-popup__field esun-contact-popup__field--full required">
|
||||
<label class="esun-contact-popup__label" for="<?= $escaper->escapeHtmlAttr($formId) ?>-details">
|
||||
<?= $escaper->escapeHtml(__('Details')) ?>
|
||||
</label>
|
||||
<textarea id="<?= $escaper->escapeHtmlAttr($formId) ?>-details"
|
||||
name="details" maxlength="5000" rows="5" required
|
||||
data-validate="{required:true}"
|
||||
placeholder="<?= $escaper->escapeHtmlAttr(__('* Details')) ?>"></textarea>
|
||||
</div>
|
||||
|
||||
<input type="text" name="hideit" class="esun-contact-popup__trap"
|
||||
tabindex="-1" autocomplete="off"/>
|
||||
|
||||
<button type="submit" class="action primary esun-contact-popup__submit">
|
||||
<span><?= $escaper->escapeHtml(__('Send')) ?></span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script type="text/x-magento-init">
|
||||
{
|
||||
"#<?= $escaper->escapeJs($formId) ?>": {
|
||||
"Esun_ContactPopup/js/contact-inline": {}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/** @var \Esun\ContactPopup\Block\Modal $block */
|
||||
/** @var \Magento\Framework\Escaper $escaper */
|
||||
?>
|
||||
<div id="esun-contact-popup" class="esun-contact-popup" style="display:none;">
|
||||
<form id="esun-contact-popup-form"
|
||||
class="esun-contact-popup__form"
|
||||
action="<?= $escaper->escapeUrl($block->getUrl('contact-popup/index/post')) ?>"
|
||||
method="post"
|
||||
novalidate>
|
||||
<?= /* @noEscape */ $block->getBlockHtml('formkey') ?>
|
||||
|
||||
<div class="esun-contact-popup__status" role="status" aria-live="polite"></div>
|
||||
|
||||
<div class="esun-contact-popup__field esun-contact-popup__field--full">
|
||||
<label class="esun-contact-popup__label" for="contact-popup-company">
|
||||
<?= $escaper->escapeHtml(__('Company Name')) ?>
|
||||
</label>
|
||||
<input class="input-text"
|
||||
type="text"
|
||||
id="contact-popup-company"
|
||||
name="company"
|
||||
maxlength="255"
|
||||
placeholder="<?= $escaper->escapeHtmlAttr(__('Company Name')) ?>"/>
|
||||
</div>
|
||||
|
||||
<div class="esun-contact-popup__grid">
|
||||
<div class="esun-contact-popup__field required">
|
||||
<label class="esun-contact-popup__label" for="contact-popup-category">
|
||||
<?= $escaper->escapeHtml(__('Question category')) ?>
|
||||
</label>
|
||||
<select id="contact-popup-category"
|
||||
name="question_category"
|
||||
required
|
||||
data-validate="{required:true}">
|
||||
<option value=""><?= $escaper->escapeHtml(__('Question category')) ?></option>
|
||||
<option value="Product"><?= $escaper->escapeHtml(__('Product')) ?></option>
|
||||
<option value="Technical support"><?= $escaper->escapeHtml(__('Technical support')) ?></option>
|
||||
<option value="Cooperation"><?= $escaper->escapeHtml(__('Cooperation')) ?></option>
|
||||
<option value="Other"><?= $escaper->escapeHtml(__('Other')) ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="esun-contact-popup__field required">
|
||||
<label class="esun-contact-popup__label" for="contact-popup-name">
|
||||
<?= $escaper->escapeHtml(__('Name')) ?>
|
||||
</label>
|
||||
<input class="input-text"
|
||||
type="text"
|
||||
id="contact-popup-name"
|
||||
name="name"
|
||||
maxlength="255"
|
||||
autocomplete="name"
|
||||
required
|
||||
data-validate="{required:true}"
|
||||
placeholder="<?= $escaper->escapeHtmlAttr(__('* Name')) ?>"/>
|
||||
</div>
|
||||
|
||||
<div class="esun-contact-popup__field required">
|
||||
<label class="esun-contact-popup__label" for="contact-popup-email">
|
||||
<?= $escaper->escapeHtml(__('Email')) ?>
|
||||
</label>
|
||||
<input class="input-text"
|
||||
type="email"
|
||||
id="contact-popup-email"
|
||||
name="email"
|
||||
autocomplete="email"
|
||||
required
|
||||
data-validate="{required:true, 'validate-email':true}"
|
||||
placeholder="<?= $escaper->escapeHtmlAttr(__('* Email (We will reply to you via email)')) ?>"/>
|
||||
</div>
|
||||
|
||||
<div class="esun-contact-popup__field required">
|
||||
<label class="esun-contact-popup__label" for="contact-popup-country">
|
||||
<?= $escaper->escapeHtml(__('Country')) ?>
|
||||
</label>
|
||||
<select id="contact-popup-country"
|
||||
name="country"
|
||||
required
|
||||
data-validate="{required:true}">
|
||||
<option value=""><?= $escaper->escapeHtml(__('* Country')) ?></option>
|
||||
<?php foreach ($block->getCountryOptions() as $country): ?>
|
||||
<option value="<?= $escaper->escapeHtmlAttr((string)$country['label']) ?>">
|
||||
<?= $escaper->escapeHtml((string)$country['label']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="esun-contact-popup__field esun-contact-popup__field--full required">
|
||||
<label class="esun-contact-popup__label" for="contact-popup-details">
|
||||
<?= $escaper->escapeHtml(__('Details')) ?>
|
||||
</label>
|
||||
<textarea id="contact-popup-details"
|
||||
name="details"
|
||||
maxlength="5000"
|
||||
rows="5"
|
||||
required
|
||||
data-validate="{required:true}"
|
||||
placeholder="<?= $escaper->escapeHtmlAttr(__('* Details')) ?>"></textarea>
|
||||
</div>
|
||||
|
||||
<input type="text" name="hideit" class="esun-contact-popup__trap" tabindex="-1" autocomplete="off"/>
|
||||
|
||||
<button type="submit" class="action primary esun-contact-popup__submit">
|
||||
<span><?= $escaper->escapeHtml(__('Send')) ?></span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script type="text/x-magento-init">
|
||||
{
|
||||
"#esun-contact-popup": {
|
||||
"Esun_ContactPopup/js/contact-popup": {
|
||||
"triggerSelector": ".footer-esun_contactus a[href='/contacts'], .js-esun-contact-popup"
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,286 @@
|
||||
.esun-contact-popup-modal .modal-inner-wrap {
|
||||
width: min(660px, calc(100% - 40px));
|
||||
max-width: 660px;
|
||||
overflow: hidden;
|
||||
border: 0;
|
||||
border-radius: 20px;
|
||||
background: #fff;
|
||||
box-shadow: 0 18px 60px rgba(19, 63, 42, 0.2);
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal .modal-header {
|
||||
padding: 24px 36px;
|
||||
background: #1e9e5a;
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal .modal-title {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
color: #fff;
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal .action-close {
|
||||
top: 18px;
|
||||
right: 24px;
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
padding: 0;
|
||||
border: 1px solid rgba(255, 255, 255, 0.65);
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
color: #fff;
|
||||
transition: background-color 0.2s ease;
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal .action-close:before {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal .action-close:hover,
|
||||
.esun-contact-popup-modal .action-close:focus {
|
||||
border-color: #fff;
|
||||
background: rgba(255, 255, 255, 0.25);
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal .modal-content {
|
||||
padding: 34px 36px 38px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.esun-contact-popup__grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 20px 18px;
|
||||
}
|
||||
|
||||
.esun-contact-popup__field {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.esun-contact-popup__grid .esun-contact-popup__field {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.esun-contact-popup__label {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.esun-contact-popup input.input-text,
|
||||
.esun-contact-popup select,
|
||||
.esun-contact-popup textarea {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #d9dde1;
|
||||
background: #fff;
|
||||
color: #1a1a1a;
|
||||
font-family: inherit;
|
||||
font-size: 15px;
|
||||
box-shadow: none;
|
||||
transition:
|
||||
border-color 0.2s ease,
|
||||
box-shadow 0.2s ease;
|
||||
}
|
||||
.esun-contact-popup select {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
padding-right: 54px;
|
||||
background-color: #fff;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='8' viewBox='0 0 14 8'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23a3a3a3' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 22px center;
|
||||
background-size: 10px 8px;
|
||||
}
|
||||
.esun-contact-popup input.input-text,
|
||||
.esun-contact-popup select {
|
||||
height: 48px;
|
||||
padding: 0 20px;
|
||||
border-radius: 24px;
|
||||
}
|
||||
|
||||
.esun-contact-popup textarea {
|
||||
min-height: 140px;
|
||||
padding: 16px 20px;
|
||||
border-radius: 18px;
|
||||
line-height: 1.5;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.esun-contact-popup input.input-text::placeholder,
|
||||
.esun-contact-popup textarea::placeholder,
|
||||
.esun-contact-popup select:invalid {
|
||||
color: #a3a3a3;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.esun-contact-popup input.input-text:focus,
|
||||
.esun-contact-popup select:focus,
|
||||
.esun-contact-popup textarea:focus {
|
||||
outline: none;
|
||||
border-color: #1e9e5a;
|
||||
box-shadow: 0 0 0 3px rgba(30, 158, 90, 0.12);
|
||||
}
|
||||
|
||||
.esun-contact-popup__field--full:first-of-type {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.esun-contact-popup__grid + .esun-contact-popup__field--full {
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.esun-contact-popup .mage-error {
|
||||
margin-top: 6px;
|
||||
color: #e02b27;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.esun-contact-popup__status {
|
||||
display: none;
|
||||
margin-bottom: 20px;
|
||||
padding: 12px 18px;
|
||||
border-radius: 12px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.esun-contact-popup__status.success,
|
||||
.esun-contact-popup__status.error {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.esun-contact-popup__status.success {
|
||||
background: #edf8f2;
|
||||
color: #167746;
|
||||
}
|
||||
|
||||
.esun-contact-popup__status.error {
|
||||
background: #fff1f0;
|
||||
color: #c62828;
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal
|
||||
.esun-contact-popup
|
||||
button.action.primary.esun-contact-popup__submit {
|
||||
width: 100%;
|
||||
min-height: 48px;
|
||||
border: 0;
|
||||
border-radius: 24px;
|
||||
background: #1e9e5a;
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.4px;
|
||||
box-shadow: none;
|
||||
transition:
|
||||
background-color 0.2s ease,
|
||||
transform 0.2s ease;
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal
|
||||
.esun-contact-popup
|
||||
button.action.primary.esun-contact-popup__submit:hover,
|
||||
.esun-contact-popup-modal
|
||||
.esun-contact-popup
|
||||
button.action.primary.esun-contact-popup__submit:focus {
|
||||
background: #178049;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal
|
||||
.esun-contact-popup
|
||||
button.action.primary.esun-contact-popup__submit:active {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal
|
||||
.esun-contact-popup
|
||||
button.action.primary.esun-contact-popup__submit.disabled {
|
||||
opacity: 0.65;
|
||||
}
|
||||
|
||||
.esun-contact-inline {
|
||||
box-sizing: border-box;
|
||||
margin: 30px auto;
|
||||
max-width: 660px;
|
||||
padding: 34px 36px 38px;
|
||||
border-radius: 20px;
|
||||
background: #fff;
|
||||
box-shadow: 0 10px 38px rgba(19, 63, 42, 0.12);
|
||||
}
|
||||
|
||||
.esun-contact-inline button.action.primary.esun-contact-popup__submit {
|
||||
width: 100%;
|
||||
min-height: 48px;
|
||||
border: 0;
|
||||
border-radius: 24px;
|
||||
background: #1e9e5a;
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.4px;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.esun-contact-inline button.action.primary.esun-contact-popup__submit:hover,
|
||||
.esun-contact-inline button.action.primary.esun-contact-popup__submit:focus {
|
||||
background: #178049;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.esun-contact-inline button.action.primary.esun-contact-popup__submit.disabled {
|
||||
opacity: 0.65;
|
||||
}
|
||||
|
||||
.esun-contact-popup__trap {
|
||||
position: absolute !important;
|
||||
left: -10000px !important;
|
||||
width: 1px !important;
|
||||
height: 1px !important;
|
||||
opacity: 0 !important;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.esun-contact-popup-modal .modal-inner-wrap {
|
||||
width: calc(100% - 24px);
|
||||
border-radius: 16px;
|
||||
min-height: auto !important;
|
||||
}
|
||||
.modal-popup.esun-contact-popup-modal.modal-slide {
|
||||
left: 5%;
|
||||
right: 5%;
|
||||
}
|
||||
.esun-contact-popup-modal .modal-header {
|
||||
padding: 20px 24px;
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal .modal-title {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal .modal-content {
|
||||
padding: 26px 20px 30px;
|
||||
}
|
||||
|
||||
.esun-contact-popup__grid {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 18px;
|
||||
}
|
||||
|
||||
.esun-contact-popup__field {
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.esun-contact-inline {
|
||||
margin: 20px auto;
|
||||
padding: 26px 20px 30px;
|
||||
border-radius: 16px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
define([
|
||||
'jquery',
|
||||
'mage/validation'
|
||||
], function ($) {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var $form = $(element);
|
||||
var $status = $form.find('[data-role="contact-status"]');
|
||||
var $submit = $form.find('[type="submit"]');
|
||||
|
||||
$form.validation();
|
||||
|
||||
$form.on('submit.esunContactInline', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
if (!$form.validation('isValid')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$submit.prop('disabled', true).addClass('disabled');
|
||||
$status.removeClass('success error').empty();
|
||||
|
||||
$.ajax({
|
||||
url: $form.attr('action'),
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: $form.serialize()
|
||||
}).done(function (response) {
|
||||
if (response.success) {
|
||||
$(document).trigger('esun:generateLead', {leadType: 'contact_popup'});
|
||||
$form[0].reset();
|
||||
$status.addClass('success').text(response.message);
|
||||
} else {
|
||||
$status.addClass('error').text(response.message);
|
||||
}
|
||||
}).fail(function (xhr) {
|
||||
var response = xhr.responseJSON || {};
|
||||
|
||||
$status.addClass('error').text(
|
||||
response.message || $.mage.__('Unable to send your message. Please try again.')
|
||||
);
|
||||
}).always(function () {
|
||||
$submit.prop('disabled', false).removeClass('disabled');
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,87 @@
|
||||
define([
|
||||
'jquery',
|
||||
'Magento_Ui/js/modal/modal',
|
||||
'mage/validation'
|
||||
], function ($, modal) {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var $popup = $(element);
|
||||
var $form = $popup.find('form');
|
||||
var $status = $popup.find('.esun-contact-popup__status');
|
||||
var $submit = $form.find('[type="submit"]');
|
||||
|
||||
modal({
|
||||
type: 'popup',
|
||||
responsive: true,
|
||||
innerScroll: true,
|
||||
modalClass: 'esun-contact-popup-modal',
|
||||
title: $.mage.__('Leave Message'),
|
||||
buttons: []
|
||||
}, $popup);
|
||||
|
||||
$(document).on('click.esunContactPopup', config.triggerSelector, function (event) {
|
||||
event.preventDefault();
|
||||
$status.removeClass('success error').empty();
|
||||
$popup.modal('openModal');
|
||||
});
|
||||
|
||||
// Keep product-page delegated button handlers from receiving this click.
|
||||
$submit.on('click.esunContactPopup', function (event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
$form.on('submit.esunContactPopup', function (event) {
|
||||
var scrollPosition = window.pageYOffset || document.documentElement.scrollTop;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
|
||||
if (!$form.validation('isValid')) {
|
||||
window.scrollTo(0, scrollPosition);
|
||||
window.requestAnimationFrame(function () {
|
||||
window.scrollTo(0, scrollPosition);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
$submit.prop('disabled', true).addClass('disabled');
|
||||
$status.removeClass('success error').empty();
|
||||
|
||||
$.ajax({
|
||||
url: $form.attr('action'),
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: $form.serialize()
|
||||
}).done(function (response) {
|
||||
if (response.success) {
|
||||
$(document).trigger('esun:generateLead', {leadType: 'contact_popup'});
|
||||
$form[0].reset();
|
||||
$status.addClass('success').text(response.message);
|
||||
} else {
|
||||
$status.addClass('error').text(response.message);
|
||||
}
|
||||
}).fail(function (xhr) {
|
||||
var response = xhr.responseJSON || {};
|
||||
|
||||
$status.addClass('error').text(
|
||||
response.message || $.mage.__('Unable to send your message. Please try again.')
|
||||
);
|
||||
}).always(function () {
|
||||
$submit.prop('disabled', false).removeClass('disabled');
|
||||
window.scrollTo(0, scrollPosition);
|
||||
window.requestAnimationFrame(function () {
|
||||
window.scrollTo(0, scrollPosition);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Register Magento validation after our isolated submit handler.
|
||||
$form.validation();
|
||||
$form.off('invalid-form.validate');
|
||||
|
||||
if ($form.data('validator')) {
|
||||
$form.data('validator').settings.focusInvalid = false;
|
||||
}
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user