Skip to content

Commit 8438cd0

Browse files
committed
Init commit
0 parents  commit 8438cd0

31 files changed

+1583
-0
lines changed

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# General
2+
.DS_Store
3+
.AppleDouble
4+
.LSOverride
5+
6+
# Icon must end with two \r
7+
Icon
8+
9+
# Thumbnails
10+
._*
11+
12+
# Files that might appear in the root of a volume
13+
.DocumentRevisions-V100
14+
.fseventsd
15+
.Spotlight-V100
16+
.TemporaryItems
17+
.Trashes
18+
.VolumeIcon.icns
19+
.com.apple.timemachine.donotpresent
20+
21+
# Directories potentially created on remote AFP share
22+
.AppleDB
23+
.AppleDesktop
24+
Network Trash Folder
25+
Temporary Items
26+
.apdisk

Block/Adminhtml/Theme.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/**
4+
* @Author: nguyen
5+
* @Date: 2020-06-09 18:32:37
6+
* @Last Modified by: nguyen
7+
* @Last Modified time: 2020-06-09 20:08:03
8+
*/
9+
10+
namespace Magepow\Theme\Block\Adminhtml;
11+
12+
class Theme extends \Magento\Backend\Block\Widget\Grid\Container
13+
{
14+
/**
15+
* Constructor.
16+
*/
17+
protected function _construct()
18+
{
19+
$this->_controller = 'adminhtml_theme';
20+
$this->_blockGroup = 'Magepow_Theme';
21+
$this->_headerText = __('Theme');
22+
$this->_addButtonLabel = __('Add New Theme');
23+
parent::_construct();
24+
}
25+
}

Block/Adminhtml/Theme/Edit.php

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<?php
2+
3+
/**
4+
* @Author: nguyen
5+
* @Date: 2020-06-09 19:40:03
6+
* @Last Modified by: nguyen
7+
* @Last Modified time: 2020-06-09 19:41:14
8+
*/
9+
10+
namespace Magepow\Theme\Block\Adminhtml\Theme;
11+
12+
class Edit extends \Magento\Backend\Block\Widget\Form\Container
13+
{
14+
/**
15+
* _construct
16+
* @return void
17+
*/
18+
protected function _construct()
19+
{
20+
$this->_objectId = 'theme_id';
21+
$this->_blockGroup = 'Magepow_Theme';
22+
$this->_controller = 'adminhtml_theme';
23+
24+
parent::_construct();
25+
26+
$this->buttonList->update('save', 'label', __('Save Theme'));
27+
$this->buttonList->update('delete', 'label', __('Delete'));
28+
29+
if ($this->getRequest()->getParam('current_theme_id')) {
30+
$this->buttonList->remove('save');
31+
$this->buttonList->remove('delete');
32+
33+
$this->buttonList->remove('back');
34+
$this->buttonList->add(
35+
'close_window',
36+
[
37+
'label' => __('Close Window'),
38+
'onclick' => 'window.close();',
39+
],
40+
10
41+
);
42+
43+
$this->buttonList->add(
44+
'save_and_continue',
45+
[
46+
'label' => __('Save and Continue Edit'),
47+
'class' => 'save',
48+
'onclick' => 'customsaveAndContinueEdit()',
49+
],
50+
10
51+
);
52+
53+
$this->buttonList->add(
54+
'save_and_close',
55+
[
56+
'label' => __('Save and Close'),
57+
'class' => 'save_and_close',
58+
'onclick' => 'saveAndCloseWindow()',
59+
],
60+
10
61+
);
62+
63+
$this->_formScripts[] = "
64+
require(['jquery'], function($){
65+
$(document).ready(function(){
66+
var input = $('<input class=\"custom-button-submit\" type=\"submit\" hidden=\"true\" />');
67+
$(edit_form).append(input);
68+
69+
window.customsaveAndContinueEdit = function (){
70+
edit_form.action = '".$this->getSaveAndContinueUrl()."';
71+
$('.custom-button-submit').trigger('click');
72+
73+
}
74+
75+
window.saveAndCloseWindow = function (){
76+
edit_form.action = '".$this->getSaveAndCloseWindowUrl()."';
77+
$('.custom-button-submit').trigger('click');
78+
}
79+
});
80+
});
81+
";
82+
83+
if ($themeId = $this->getRequest()->getParam('theme_id')) {
84+
$this->_formScripts[] = '
85+
window.theme_id = '.$themeId.';
86+
';
87+
}
88+
} else {
89+
$this->buttonList->add(
90+
'save_and_continue',
91+
[
92+
'label' => __('Save and Continue Edit'),
93+
'class' => 'save',
94+
'data_attribute' => [
95+
'mage-init' => [
96+
'button' => ['event' => 'saveAndContinueEdit', 'target' => '#edit_form'],
97+
],
98+
],
99+
],
100+
10
101+
);
102+
}
103+
104+
if ($this->getRequest()->getParam('saveandclose')) {
105+
$this->_formScripts[] = 'window.close();';
106+
}
107+
}
108+
109+
/**
110+
* Retrieve the save and continue edit Url.
111+
*
112+
* @return string
113+
*/
114+
protected function getSaveAndContinueUrl()
115+
{
116+
return $this->getUrl(
117+
'*/*/save',
118+
[
119+
'_current' => true,
120+
'back' => 'edit',
121+
'tab' => '{{tab_id}}',
122+
'store' => $this->getRequest()->getParam('store'),
123+
'theme_id' => $this->getRequest()->getParam('theme_id'),
124+
'current_theme_id' => $this->getRequest()->getParam('current_theme_id'),
125+
]
126+
);
127+
}
128+
129+
/**
130+
* Retrieve the save and continue edit Url.
131+
*
132+
* @return string
133+
*/
134+
protected function getSaveAndCloseWindowUrl()
135+
{
136+
return $this->getUrl(
137+
'*/*/save',
138+
[
139+
'_current' => true,
140+
'back' => 'edit',
141+
'tab' => '{{tab_id}}',
142+
'store' => $this->getRequest()->getParam('store'),
143+
'theme_id' => $this->getRequest()->getParam('theme_id'),
144+
'current_theme_id' => $this->getRequest()->getParam('current_theme_id'),
145+
'saveandclose' => 1,
146+
]
147+
);
148+
}
149+
}

0 commit comments

Comments
 (0)