Skip to content

Commit

Permalink
fixed - marketplace-eqp
Browse files Browse the repository at this point in the history
  • Loading branch information
duongdiep212 committed Dec 20, 2018
1 parent 85cfdc8 commit 4b7470e
Show file tree
Hide file tree
Showing 56 changed files with 346 additions and 256 deletions.
1 change: 0 additions & 1 deletion Api/Data/Staff/RoleInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,4 @@ public function getMaximumDiscountPercent();
* @return $this
*/
public function setMaximumDiscountPercent($discount);

}
5 changes: 3 additions & 2 deletions Api/Event/DispatchServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Magestore\Appadmin\Api\Event;

interface DispatchServiceInterface {
interface DispatchServiceInterface
{
const EVENT_NAME_FORCE_SIGN_OUT = 'magestore_webpos_force_sign_out';
const EVENT_NAME_FORCE_CHANGE_POS = 'magestore_webpos_force_change_pos';

Expand All @@ -28,4 +29,4 @@ public function dispatchEventForceSignOut($staffId, $posId = null);
* @return bool
*/
public function dispatchEventForceChangePos($staffId, $posId);
}
}
2 changes: 1 addition & 1 deletion Api/Staff/RuleRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ interface RuleRepositoryInterface
* @return bool
*/
public function isAllowPermission($aclResource, $staffId);
}
}
1 change: 0 additions & 1 deletion Api/Staff/StaffRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,4 @@ public function deleteById($staffId);
* @return \Magestore\Appadmin\Api\Data\Staff\StaffInterface[]
*/
public function getAllStaff();

}
12 changes: 6 additions & 6 deletions Block/Adminhtml/Staff/Role/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

namespace Magestore\Appadmin\Block\Adminhtml\Staff\Role;

/**
* Class Edit
* @package Magestore\Appadmin\Block\Adminhtml\Staff\Role
Expand Down Expand Up @@ -46,16 +47,15 @@ protected function _construct()
$this->buttonList->update('delete', 'label', __('Delete'));
$this->buttonList->add(
'saveandcontinue',
array(
[
'label' => __('Save and Continue Edit'),
'class' => 'save',
'data_attribute' => array(
'mage-init' => array('button' => array('event' => 'saveAndContinueEdit', 'target' => '#edit_form'))
)
),
'data_attribute' => [
'mage-init' => ['button' => ['event' => 'saveAndContinueEdit', 'target' => '#edit_form']]
]
],
-100
);

}

/**
Expand Down
8 changes: 4 additions & 4 deletions Block/Adminhtml/Staff/Role/Edit/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
protected function _prepareForm()
{
$form = $this->_formFactory->create(
array(
'data' => array(
[
'data' => [
'id' => 'edit_form',
'action' => $this->getUrl('*/*/save', ['store' => $this->getRequest()->getParam('store')]),
'method' => 'post',
'enctype' => 'multipart/form-data'
)
)
]
]
);
$form->setUseContainer(true);
$this->setForm($form);
Expand Down
37 changes: 19 additions & 18 deletions Block/Adminhtml/Staff/Role/Edit/Tab/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
* Class Form
* @package Magestore\Giftwrap\Block\Adminhtml\Staff\Role\Edit\Tab
*/
class Form extends \Magento\Backend\Block\Widget\Form\Generic
implements \Magento\Backend\Block\Widget\Tab\TabInterface
class Form extends \Magento\Backend\Block\Widget\Form\Generic implements \Magento\Backend\Block\Widget\Tab\TabInterface
{

protected $_objectManager;
Expand All @@ -21,17 +20,17 @@ public function __construct(
\Magento\Framework\Registry $registry,
\Magento\Framework\Data\FormFactory $formFactory,
\Magento\Framework\ObjectManagerInterface $objectManager,
array $data = array()
)
{
array $data = []
) {
$this->_objectManager = $objectManager;
parent::__construct($context, $registry, $formFactory, $data);
}

/**
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _prepareLayout() {
protected function _prepareLayout()
{
$this->getLayout()->getBlock('page.title')->setPageTitle($this->getPageTitle());
}

Expand All @@ -47,28 +46,28 @@ protected function _prepareForm()

$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('page_');
$fieldset = $form->addFieldset('base_fieldset', array('legend' => __('Role Information')));
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Role Information')]);

if ($model->getRoleId()) {
$fieldset->addField('role_id', 'hidden', array('name' => 'role_id','value' => $model->getRoleId()));
$fieldset->addField('role_id', 'hidden', ['name' => 'role_id','value' => $model->getRoleId()]);
}

$fieldset->addField('name', 'text', array(
$fieldset->addField('name', 'text', [
'label' => __('Role Name'),
'class' => 'required-entry',
'required' => true,
'maxlength' => 127,
'name' => 'name',
'disabled' => false,
));
]);


$fieldset->addField('description', 'textarea', array(
$fieldset->addField('description', 'textarea', [
'label' => __('Description'),
'name' => 'description',
'maxlength' => 255,
'disabled' => false,
));
]);

$form->setValues($model->getData());
$this->setForm($form);
Expand All @@ -78,16 +77,20 @@ protected function _prepareForm()
/**
* @return mixed
*/
public function getRole() {
public function getRole()
{
return $this->_coreRegistry->registry('current_role');
}

/**
* @return \Magento\Framework\Phrase
*/
public function getPageTitle() {
return $this->getRole()->getId() ? __("Edit Role %1",
$this->escapeHtml($this->getRole()->getDisplayName())) : __('New Role');
public function getPageTitle()
{
return $this->getRole()->getId() ? __(
"Edit Role %1",
$this->escapeHtml($this->getRole()->getDisplayName())
) : __('New Role');
}

/**
Expand Down Expand Up @@ -122,6 +125,4 @@ public function isHidden()
{
return false;
}


}
1 change: 0 additions & 1 deletion Block/Adminhtml/Staff/Role/Edit/Tab/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,3 @@ function ($node) {
return isset($configResource['children']) ? $configResource['children'] : [];
}
}

3 changes: 2 additions & 1 deletion Block/Adminhtml/Staff/Role/Edit/Tab/Permission/Discount.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public function _construct()
* Get discount value
* @return float
*/
public function getMaxDiscountPercent(){
public function getMaxDiscountPercent()
{
$rid = $this->_request->getParam('id', false);
return $this->_webposAclRetriever->getMaxDiscountPercentByRole($rid);
}
Expand Down
54 changes: 30 additions & 24 deletions Block/Adminhtml/Staff/Role/Edit/Tab/Staff.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
*/

namespace Magestore\Appadmin\Block\Adminhtml\Staff\Role\Edit\Tab;

/**
* Class Staff
* @package Magestore\Appadmin\Block\Adminhtml\Staff\Role\Edit\Tab
*/
class Staff extends \Magento\Backend\Block\Widget\Grid\Extended {
class Staff extends \Magento\Backend\Block\Widget\Grid\Extended
{

/**
* @var \Magestore\Appadmin\Model\ResourceModel\Staff\Staff\CollectionFactory
Expand All @@ -27,32 +29,33 @@ public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Backend\Helper\Data $backendHelper,
\Magestore\Appadmin\Model\ResourceModel\Staff\Staff\CollectionFactory $staffCollectionFactory,
array $data = array()
)
{
array $data = []
) {
$this->_staffCollectionFactory = $staffCollectionFactory;
parent::__construct($context, $backendHelper, $data);
}

/**
*
*/
public function _construct() {
public function _construct()
{
parent::_construct();
$this->setId('staff_grid');
$this->setDefaultSort('staff_id');
$this->setDefaultDir('asc');
$this->setSaveParametersInSession(false);
$this->setUseAjax(true);
if ($this->getRequest()->getParam('id')) {
$this->setDefaultFilter(array('in_staff' => 1));
$this->setDefaultFilter(['in_staff' => 1]);
}
}

/**
* @return $this
*/
protected function _prepareCollection() {
protected function _prepareCollection()
{
$collection = $this->_staffCollectionFactory->create();
$roleId = (int)$this->getRequest()->getParam('id');
$collection->addFieldToFilter('role_id', $roleId);
Expand All @@ -65,56 +68,59 @@ protected function _prepareCollection() {
* @return $this
* @throws \Exception
*/
protected function _prepareColumns() {
$this->addColumn('staff_id', array(
protected function _prepareColumns()
{
$this->addColumn('staff_id', [
'header' => __('ID'),
'width' => '50px',
'index' => 'staff_id',
'type' => 'number',
));
]);

$this->addColumn('username', array(
$this->addColumn('username', [
'header' => __('User Name'),
'index' => 'username'
));
]);

$this->addColumn('staff_name', array(
$this->addColumn('staff_name', [
'header' => __('Display Name'),
'index' => 'name'
));
]);

$this->addColumn('email', array(
$this->addColumn('email', [
'header' => __('Email'),
'index' => 'email'
));
]);

$this->addColumn('status', array(
$this->addColumn('status', [
'header' => __('Status'),
'index' => 'status',
'type' => 'options',
'options' => array(
'options' => [
1 => 'Enable',
2 => 'Disable',
),
],

));
]);

return parent::_prepareColumns();
}

/**
* @return mixed|string
*/
public function getGridUrl() {
public function getGridUrl()
{
return $this->getData('grid_url') ? $this->getData('grid_url') :
$this->getUrl('*/*/staffgrid', array('_current' => true, 'id' => $this->getRequest()->getParam('id')));
$this->getUrl('*/*/staffgrid', ['_current' => true, 'id' => $this->getRequest()->getParam('id')]);
}

/**
* @param \Magento\Framework\DataObject $row
* @return string
*/
public function getRowUrl($row) {
public function getRowUrl($row)
{
return '';
}
}
}
6 changes: 3 additions & 3 deletions Block/Adminhtml/Staff/Role/Edit/Tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

namespace Magestore\Appadmin\Block\Adminhtml\Staff\Role\Edit;

/**
* Class Tabs
* @package Magestore\Appadmin\Block\Adminhtml\Staff\Role\Edit
Expand Down Expand Up @@ -41,7 +42,7 @@ protected function _beforeToHtml()
]
);
$permissionBlock = $this->getLayout()->createBlock('Magestore\Appadmin\Block\Adminhtml\Staff\Role\Edit\Tab\Permission');
$permissionBlock->addChild('block_discount_percent','Magestore\Appadmin\Block\Adminhtml\Staff\Role\Edit\Tab\Permission\Discount');
$permissionBlock->addChild('block_discount_percent', 'Magestore\Appadmin\Block\Adminhtml\Staff\Role\Edit\Tab\Permission\Discount');
$this->addTab(
'webpos_permission',
[
Expand All @@ -58,11 +59,10 @@ protected function _beforeToHtml()
'label' => __('Staff List'),
'title' => __('Staff List'),
'class' => 'ajax',
'url' => $this->getUrl('*/*/staff', array('_current' => true, 'id' => $this->getRequest()->getParam('id')))
'url' => $this->getUrl('*/*/staff', ['_current' => true, 'id' => $this->getRequest()->getParam('id')])
]
);

return parent::_beforeToHtml();
}

}
5 changes: 3 additions & 2 deletions Block/Adminhtml/Staff/Staff/Edit/Buttons/Back.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

namespace Magestore\Appadmin\Block\Adminhtml\Staff\Staff\Edit\Buttons;

class Back extends Generic {
class Back extends Generic
{
/**
* @return array
*/
Expand All @@ -19,4 +20,4 @@ public function getButtonData()
'sort_order' => 10
];
}
}
}
Loading

0 comments on commit 4b7470e

Please sign in to comment.