Skip to content

Commit b3e0968

Browse files
author
abhishek
committed
module 2.0.0 added
0 parents  commit b3e0968

34 files changed

+2272
-0
lines changed

Api/Data/GridInterface.php

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<?php
2+
/**
3+
* Grid GridInterface.
4+
* @category Webkul
5+
* @package Webkul_Grid
6+
* @author Webkul
7+
* @copyright Copyright (c) 2010-2017 Webkul Software Private Limited (https://webkul.com)
8+
* @license https://store.webkul.com/license.html
9+
*/
10+
11+
namespace Webkul\Grid\Api\Data;
12+
13+
interface GridInterface
14+
{
15+
/**
16+
* Constants for keys of data array. Identical to the name of the getter in snake case.
17+
*/
18+
const ENTITY_ID = 'entity_id';
19+
const TITLE = 'title';
20+
const CONTENT = 'content';
21+
const PUBLISH_DATE = 'publish_date';
22+
const IS_ACTIVE = 'is_active';
23+
const UPDATE_TIME = 'update_time';
24+
const CREATED_AT = 'created_at';
25+
26+
/**
27+
* Get EntityId.
28+
*
29+
* @return int
30+
*/
31+
public function getEntityId();
32+
33+
/**
34+
* Set EntityId.
35+
*/
36+
public function setEntityId($entityId);
37+
38+
/**
39+
* Get Title.
40+
*
41+
* @return varchar
42+
*/
43+
public function getTitle();
44+
45+
/**
46+
* Set Title.
47+
*/
48+
public function setTitle($title);
49+
50+
/**
51+
* Get Content.
52+
*
53+
* @return varchar
54+
*/
55+
public function getContent();
56+
57+
/**
58+
* Set Content.
59+
*/
60+
public function setContent($content);
61+
62+
/**
63+
* Get Publish Date.
64+
*
65+
* @return varchar
66+
*/
67+
public function getPublishDate();
68+
69+
/**
70+
* Set PublishDate.
71+
*/
72+
public function setPublishDate($publishDate);
73+
74+
/**
75+
* Get IsActive.
76+
*
77+
* @return varchar
78+
*/
79+
public function getIsActive();
80+
81+
/**
82+
* Set StartingPrice.
83+
*/
84+
public function setIsActive($isActive);
85+
86+
/**
87+
* Get UpdateTime.
88+
*
89+
* @return varchar
90+
*/
91+
public function getUpdateTime();
92+
93+
/**
94+
* Set UpdateTime.
95+
*/
96+
public function setUpdateTime($updateTime);
97+
98+
/**
99+
* Get CreatedAt.
100+
*
101+
* @return varchar
102+
*/
103+
public function getCreatedAt();
104+
105+
/**
106+
* Set CreatedAt.
107+
*/
108+
public function setCreatedAt($createdAt);
109+
}

Block/Adminhtml/Grid/AddRow.php

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
/**
3+
* Webkul_Grid Add Row Form Block.
4+
*
5+
* @category Webkul
6+
*
7+
* @author Webkul Software Private Limited
8+
*/
9+
namespace Webkul\Grid\Block\Adminhtml\Grid;
10+
11+
class AddRow extends \Magento\Backend\Block\Widget\Form\Container
12+
{
13+
/**
14+
* Core registry.
15+
*
16+
* @var \Magento\Framework\Registry
17+
*/
18+
protected $_coreRegistry = null;
19+
20+
/**
21+
* @param \Magento\Backend\Block\Widget\Context $context
22+
* @param \Magento\Framework\Registry $registry
23+
* @param array $data
24+
*/
25+
public function __construct(
26+
\Magento\Backend\Block\Widget\Context $context,
27+
\Magento\Framework\Registry $registry,
28+
array $data = []
29+
) {
30+
$this->_coreRegistry = $registry;
31+
parent::__construct($context, $data);
32+
}
33+
34+
/**
35+
* Initialize Imagegallery Images Edit Block.
36+
*/
37+
protected function _construct()
38+
{
39+
$this->_objectId = 'row_id';
40+
$this->_blockGroup = 'Webkul_Grid';
41+
$this->_controller = 'adminhtml_grid';
42+
parent::_construct();
43+
if ($this->_isAllowedAction('Webkul_Grid::add_row')) {
44+
$this->buttonList->update('save', 'label', __('Save'));
45+
} else {
46+
$this->buttonList->remove('save');
47+
}
48+
$this->buttonList->remove('reset');
49+
}
50+
51+
/**
52+
* Retrieve text for header element depending on loaded image.
53+
*
54+
* @return \Magento\Framework\Phrase
55+
*/
56+
public function getHeaderText()
57+
{
58+
return __('Add RoW Data');
59+
}
60+
61+
/**
62+
* Check permission for passed action.
63+
*
64+
* @param string $resourceId
65+
*
66+
* @return bool
67+
*/
68+
protected function _isAllowedAction($resourceId)
69+
{
70+
return $this->_authorization->isAllowed($resourceId);
71+
}
72+
73+
/**
74+
* Get form action URL.
75+
*
76+
* @return string
77+
*/
78+
public function getFormActionUrl()
79+
{
80+
if ($this->hasFormActionUrl()) {
81+
return $this->getData('form_action_url');
82+
}
83+
84+
return $this->getUrl('*/*/save');
85+
}
86+
}

Block/Adminhtml/Grid/Edit/Form.php

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
<?php
2+
/**
3+
* Webkul_Grid Add New Row Form Admin Block.
4+
* @category Webkul
5+
* @package Webkul_Grid
6+
* @author Webkul Software Private Limited
7+
*
8+
*/
9+
namespace Webkul\Grid\Block\Adminhtml\Grid\Edit;
10+
11+
/**
12+
* Adminhtml Add New Row Form.
13+
*/
14+
class Form extends \Magento\Backend\Block\Widget\Form\Generic
15+
{
16+
/**
17+
* @var \Magento\Store\Model\System\Store
18+
*/
19+
protected $_systemStore;
20+
21+
/**
22+
* @param \Magento\Backend\Block\Template\Context $context,
23+
* @param \Magento\Framework\Registry $registry,
24+
* @param \Magento\Framework\Data\FormFactory $formFactory,
25+
* @param \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig,
26+
* @param \Webkul\Grid\Model\Status $options,
27+
*/
28+
public function __construct(
29+
\Magento\Backend\Block\Template\Context $context,
30+
\Magento\Framework\Registry $registry,
31+
\Magento\Framework\Data\FormFactory $formFactory,
32+
\Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig,
33+
\Webkul\Grid\Model\Status $options,
34+
array $data = []
35+
) {
36+
$this->_options = $options;
37+
$this->_wysiwygConfig = $wysiwygConfig;
38+
parent::__construct($context, $registry, $formFactory, $data);
39+
}
40+
41+
/**
42+
* Prepare form.
43+
*
44+
* @return $this
45+
*/
46+
protected function _prepareForm()
47+
{
48+
$dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
49+
$model = $this->_coreRegistry->registry('row_data');
50+
$form = $this->_formFactory->create(
51+
['data' => [
52+
'id' => 'edit_form',
53+
'enctype' => 'multipart/form-data',
54+
'action' => $this->getData('action'),
55+
'method' => 'post'
56+
]
57+
]
58+
);
59+
60+
$form->setHtmlIdPrefix('wkgrid_');
61+
if ($model->getEntityId()) {
62+
$fieldset = $form->addFieldset(
63+
'base_fieldset',
64+
['legend' => __('Edit Row Data'), 'class' => 'fieldset-wide']
65+
);
66+
$fieldset->addField('entity_id', 'hidden', ['name' => 'entity_id']);
67+
} else {
68+
$fieldset = $form->addFieldset(
69+
'base_fieldset',
70+
['legend' => __('Add Row Data'), 'class' => 'fieldset-wide']
71+
);
72+
}
73+
74+
$fieldset->addField(
75+
'title',
76+
'text',
77+
[
78+
'name' => 'title',
79+
'label' => __('Title'),
80+
'id' => 'title',
81+
'title' => __('Title'),
82+
'class' => 'required-entry',
83+
'required' => true,
84+
]
85+
);
86+
87+
$wysiwygConfig = $this->_wysiwygConfig->getConfig(['tab_id' => $this->getTabId()]);
88+
89+
$fieldset->addField(
90+
'content',
91+
'editor',
92+
[
93+
'name' => 'content',
94+
'label' => __('Content'),
95+
'style' => 'height:36em;',
96+
'required' => true,
97+
'config' => $wysiwygConfig
98+
]
99+
);
100+
101+
$fieldset->addField(
102+
'publish_date',
103+
'date',
104+
[
105+
'name' => 'publish_date',
106+
'label' => __('Publish Date'),
107+
'date_format' => $dateFormat,
108+
'time_format' => 'H:mm:ss',
109+
'class' => 'validate-date validate-date-range date-range-custom_theme-from',
110+
'class' => 'required-entry',
111+
'style' => 'width:200px',
112+
]
113+
);
114+
$fieldset->addField(
115+
'is_active',
116+
'select',
117+
[
118+
'name' => 'is_active',
119+
'label' => __('Status'),
120+
'id' => 'is_active',
121+
'title' => __('Status'),
122+
'values' => $this->_options->getOptionArray(),
123+
'class' => 'status',
124+
'required' => true,
125+
]
126+
);
127+
$form->setValues($model->getData());
128+
$form->setUseContainer(true);
129+
$this->setForm($form);
130+
131+
return parent::_prepareForm();
132+
}
133+
}

0 commit comments

Comments
 (0)