-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
CompactCode
authored
Apr 5, 2019
1 parent
ee97983
commit c13182c
Showing
68 changed files
with
13,616 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "compactcode/base", | ||
"description": "", | ||
"require": { | ||
"php": "~5.5.0|~5.6.0|~7.0.0|~7.1.0|~7.2.0" | ||
}, | ||
"suggest": { | ||
|
||
}, | ||
"type": "magento2-module", | ||
"version": "1.1.2", | ||
"license": [ | ||
"OSL-3.0", | ||
"AFL-3.0" | ||
], | ||
"autoload": { | ||
"files": [ | ||
"src/registration.php" | ||
], | ||
"psr-4": { | ||
"CompactCode\\Base\\": "src" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2019 | ||
* Copyright Holder : CompactCode - CompactCode BvBa - Belgium | ||
* Copyright : Unless granted permission from CompactCode BvBa. | ||
* You can not distribute, reuse, edit, resell or sell this. | ||
*/ | ||
|
||
namespace CompactCode\Base\Block\Adminhtml\Form\Field; | ||
|
||
use CompactCode\Base\Block\Color; | ||
|
||
class ColorPicker extends Color | ||
{ | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/Block/Adminhtml/UiComponent/Buttons/AjaxSaveButton.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2019 | ||
* Copyright Holder : CompactCode - CompactCode BvBa - Belgium | ||
* Copyright : Unless granted permission from CompactCode BvBa. | ||
* You can not distribute, reuse, edit, resell or sell this. | ||
*/ | ||
|
||
namespace CompactCode\Base\Block\Adminhtml\UiComponent\Buttons; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
class AjaxSaveButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
public function getButtonData() | ||
{ | ||
return [ | ||
'label' => 'Save', | ||
'class' => 'primary', | ||
'sort_order' => 80, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2019 | ||
* Copyright Holder : CompactCode - CompactCode BvBa - Belgium | ||
* Copyright : Unless granted permission from CompactCode BvBa. | ||
* You can not distribute, reuse, edit, resell or sell this. | ||
*/ | ||
|
||
namespace CompactCode\Base\Block\Adminhtml\UiComponent\Buttons; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
/** | ||
* Class BackButton | ||
*/ | ||
class BackButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
/** | ||
* @return array | ||
*/ | ||
public function getButtonData() | ||
{ | ||
return [ | ||
'label' => __('Back'), | ||
'on_click' => sprintf("location.href = '%s';", $this->getBackUrl()), | ||
'class' => 'back', | ||
'sort_order' => 10 | ||
]; | ||
} | ||
|
||
/** | ||
* Get URL for back (reset) button | ||
* | ||
* @return string | ||
*/ | ||
public function getBackUrl() | ||
{ | ||
return $this->getUrl('*/*/'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2019 | ||
* Copyright Holder : CompactCode - CompactCode BvBa - Belgium | ||
* Copyright : Unless granted permission from CompactCode BvBa. | ||
* You can not distribute, reuse, edit, resell or sell this. | ||
*/ | ||
|
||
namespace CompactCode\Base\Block\Adminhtml\UiComponent\Buttons; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
/** | ||
* Class DeleteButton | ||
*/ | ||
class DeleteButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
/** | ||
* @return array | ||
*/ | ||
public function getButtonData() | ||
{ | ||
$data = []; | ||
if ($this->getId()) { | ||
$data = [ | ||
'label' => __('Delete'), | ||
'class' => 'delete', | ||
'on_click' => 'deleteConfirm(\'' . __( | ||
'Are you sure you want to do this?' | ||
) . '\', \'' . $this->getDeleteUrl() . '\')', | ||
'sort_order' => 20, | ||
]; | ||
} | ||
return $data; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getDeleteUrl() | ||
{ | ||
return $this->getUrl('*/*/delete', ['id' => $this->getId()]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2019 | ||
* Copyright Holder : CompactCode - CompactCode BvBa - Belgium | ||
* Copyright : Unless granted permission from CompactCode BvBa. | ||
* You can not distribute, reuse, edit, resell or sell this. | ||
*/ | ||
|
||
namespace CompactCode\Base\Block\Adminhtml\UiComponent\Buttons; | ||
|
||
use Magento\Backend\Block\Widget\Context; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
|
||
/** | ||
* Class GenericButton | ||
*/ | ||
class GenericButton | ||
{ | ||
/** | ||
* @var Context | ||
*/ | ||
private $context; | ||
|
||
/** | ||
* @param Context $context | ||
* @param BlockRepositoryInterface $blockRepository | ||
*/ | ||
public function __construct( | ||
Context $context | ||
) | ||
{ | ||
$this->context = $context; | ||
} | ||
|
||
/** | ||
* Return CMS block ID | ||
* | ||
* @return int|null | ||
*/ | ||
public function getId() | ||
{ | ||
try { | ||
return $this->context->getRequest()->getParam('id'); | ||
} catch (NoSuchEntityException $e) { | ||
} | ||
return null; | ||
} | ||
|
||
/** | ||
* Generate url by route and parameters | ||
* | ||
* @param string $route | ||
* @param array $params | ||
* @return string | ||
*/ | ||
public function getUrl($route = '', $params = []) | ||
{ | ||
return $this->context->getUrlBuilder()->getUrl($route, $params); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Block/Adminhtml/UiComponent/Buttons/SaveAndContinueButton.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2019 | ||
* Copyright Holder : CompactCode - CompactCode BvBa - Belgium | ||
* Copyright : Unless granted permission from CompactCode BvBa. | ||
* You can not distribute, reuse, edit, resell or sell this. | ||
*/ | ||
|
||
namespace CompactCode\Base\Block\Adminhtml\UiComponent\Buttons; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
class SaveAndContinueButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
public function getButtonData() | ||
{ | ||
return [ | ||
'label' => 'Save and Continue', | ||
'class' => 'save', | ||
'data_attribute' => [ | ||
'mage-init' => [ | ||
'button' => ['event' => 'saveAndContinueEdit'], | ||
], | ||
], | ||
'sort_order' => 80, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2019 | ||
* Copyright Holder : CompactCode - CompactCode BvBa - Belgium | ||
* Copyright : Unless granted permission from CompactCode BvBa. | ||
* You can not distribute, reuse, edit, resell or sell this. | ||
*/ | ||
|
||
namespace CompactCode\Base\Block\Adminhtml\UiComponent\Buttons; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
class SaveButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
public function getButtonData() | ||
{ | ||
return [ | ||
'label' => 'Save', | ||
'class' => 'save primary', | ||
'data_attribute' => [ | ||
'mage-init' => [ | ||
'button' => ['event' => 'save'], | ||
], | ||
], | ||
'sort_order' => 80, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2019 | ||
* Copyright Holder : CompactCode - CompactCode BvBa - Belgium | ||
* Copyright : Unless granted permission from CompactCode BvBa. | ||
* You can not distribute, reuse, edit, resell or sell this. | ||
*/ | ||
|
||
namespace CompactCode\Base\Block\Adminhtml\Widget; | ||
|
||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
use Magento\Framework\Data\Form\Element\CollectionFactory; | ||
use Magento\Framework\Data\Form\Element\Factory; | ||
use Magento\Framework\Escaper; | ||
|
||
class ColorPicker extends AbstractElement | ||
{ | ||
|
||
/** | ||
* TemplateButtons constructor. | ||
* @param Factory $factoryElement | ||
* @param CollectionFactory $factoryCollection | ||
* @param Escaper $escaper | ||
* @param array $data | ||
*/ | ||
public function __construct | ||
( | ||
Factory $factoryElement, | ||
CollectionFactory $factoryCollection, | ||
Escaper $escaper, | ||
array $data = [] | ||
) | ||
{ | ||
parent::__construct($factoryElement, $factoryCollection, $escaper, $data); | ||
$this->setType('text'); | ||
} | ||
|
||
public function getElementHtml() | ||
{ | ||
$html = '<input name="' . $this->getName() . | ||
'" id="' . $this->getHtmlId() . | ||
'" value="' . $this->getValue() . | ||
'" />'; | ||
|
||
return $html; | ||
} | ||
|
||
public function getDefaultHtml() | ||
{ | ||
$value = $this->getData('value'); | ||
$result = $this->getElementHtml(); | ||
$result .= '<script type="text/javascript"> | ||
require(["jquery","jquery/colorpicker/js/colorpicker"], function ($) { | ||
$(document).ready(function () { | ||
var $el = $("#' . $this->getHtmlId() . '"); | ||
$el.css("backgroundColor", "' . $value . '"); | ||
// Attach the color picker | ||
$el.ColorPicker({ | ||
color: "' . $value . '", | ||
onChange: function (hsb, hex, rgb) { | ||
$el.css("backgroundColor", "#" + hex).val("#" + hex).trigger( "change" ); | ||
} | ||
}); | ||
}); | ||
}); | ||
</script>'; | ||
return $result; | ||
} | ||
} |
Oops, something went wrong.