@@ -17,33 +17,32 @@ class Add extends \Magento\Backend\Block\Widget\Form\Container
17
17
* Initialize add review
18
18
*
19
19
* @return void
20
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
20
21
*/
21
22
protected function _construct ()
22
23
{
23
24
parent ::_construct ();
24
-
25
25
$ this ->_blockGroup = 'Magento_Review ' ;
26
26
$ this ->_controller = 'adminhtml ' ;
27
27
$ this ->_mode = 'add ' ;
28
-
29
28
$ this ->buttonList ->update ('save ' , 'label ' , __ ('Save Review ' ));
30
29
$ this ->buttonList ->update ('save ' , 'id ' , 'save_button ' );
31
-
32
30
$ this ->buttonList ->update ('reset ' , 'id ' , 'reset_button ' );
33
-
31
+ $ this -> buttonList -> update ( ' reset ' , ' onclick ' , ' window.review.formReset() ' );
34
32
$ this ->_formScripts [] = '
35
33
require(["prototype"], function(){
36
34
toggleParentVis("add_review_form");
37
35
toggleVis("save_button");
38
36
toggleVis("reset_button");
39
37
});
40
38
' ;
41
-
42
39
// @codingStandardsIgnoreStart
43
40
$ this ->_formInitScripts [] = '
44
- require(["jquery","prototype"], function(jQuery){
41
+ require(["jquery","Magento_Review/js/rating"," prototype"], function(jQuery, rating ){
45
42
window.review = function() {
46
43
return {
44
+ reviewFormEditSelector: "#edit_form",
45
+ ratingSelector: "[data-widget=ratingControl]",
47
46
productInfoUrl : null,
48
47
formHidden : true,
49
48
gridRowClick : function(data, click) {
@@ -72,6 +71,10 @@ protected function _construct()
72
71
toggleVis("save_button");
73
72
toggleVis("reset_button");
74
73
},
74
+ formReset: function() {
75
+ jQuery(review.reviewFormEditSelector).trigger( \'reset \');
76
+ jQuery(review.ratingSelector).ratingControl( \'removeRating \');
77
+ },
75
78
updateRating: function() {
76
79
elements = [$("select_stores"), $("rating_detail").getElementsBySelector("input[type= \'radio \']")].flatten();
77
80
$( \'save_button \').disabled = true;
0 commit comments