@@ -17,33 +17,32 @@ class Add extends \Magento\Backend\Block\Widget\Form\Container
1717 * Initialize add review
1818 *
1919 * @return void
20+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
2021 */
2122 protected function _construct ()
2223 {
2324 parent ::_construct ();
24-
2525 $ this ->_blockGroup = 'Magento_Review ' ;
2626 $ this ->_controller = 'adminhtml ' ;
2727 $ this ->_mode = 'add ' ;
28-
2928 $ this ->buttonList ->update ('save ' , 'label ' , __ ('Save Review ' ));
3029 $ this ->buttonList ->update ('save ' , 'id ' , 'save_button ' );
31-
3230 $ this ->buttonList ->update ('reset ' , 'id ' , 'reset_button ' );
33-
31+ $ this -> buttonList -> update ( ' reset ' , ' onclick ' , ' window.review.formReset() ' );
3432 $ this ->_formScripts [] = '
3533 require(["prototype"], function(){
3634 toggleParentVis("add_review_form");
3735 toggleVis("save_button");
3836 toggleVis("reset_button");
3937 });
4038 ' ;
41-
4239 // @codingStandardsIgnoreStart
4340 $ this ->_formInitScripts [] = '
44- require(["jquery","prototype"], function(jQuery){
41+ require(["jquery","Magento_Review/js/rating"," prototype"], function(jQuery, rating ){
4542 window.review = function() {
4643 return {
44+ reviewFormEditSelector: "#edit_form",
45+ ratingSelector: "[data-widget=ratingControl]",
4746 productInfoUrl : null,
4847 formHidden : true,
4948 gridRowClick : function(data, click) {
@@ -72,6 +71,10 @@ protected function _construct()
7271 toggleVis("save_button");
7372 toggleVis("reset_button");
7473 },
74+ formReset: function() {
75+ jQuery(review.reviewFormEditSelector).trigger( \'reset \');
76+ jQuery(review.ratingSelector).ratingControl( \'removeRating \');
77+ },
7578 updateRating: function() {
7679 elements = [$("select_stores"), $("rating_detail").getElementsBySelector("input[type= \'radio \']")].flatten();
7780 $( \'save_button \').disabled = true;
0 commit comments