Skip to content

Commit 032cfc7

Browse files
authored
ENGCOM-5737: #23990: Reset not working properly in Add review from admin #24318
2 parents 5de3ccf + 8a4e952 commit 032cfc7

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

app/code/Magento/Review/Block/Adminhtml/Add.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

app/code/Magento/Review/view/adminhtml/web/js/rating.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ define([
6262

6363
checkedInputs.nextAll('label').addBack().css('color', this.options.colorFilled).data('checked', true);
6464
checkedInputs.prevAll('label').css('color', this.options.colorUnfilled).data('checked', false);
65+
},
66+
67+
/**
68+
* Remove rating when form reset
69+
*/
70+
removeRating: function () {
71+
var checkedInputs = this.element.find('input[type="radio"]');
72+
73+
checkedInputs.nextAll('label').css('color', this.options.colorUnfilled).data('checked', false);
6574
}
6675
});
6776

0 commit comments

Comments
 (0)