Fix minor module issues

This commit is contained in:
Abhishek Kumar
2022-07-19 10:45:00 +05:30
committed by Shreesh Arora
parent 67a1446ed6
commit c85a4009cb
8 changed files with 42 additions and 22 deletions

View File

@@ -43,7 +43,7 @@ class QloHotelReviewDefaultModuleFrontController extends ModuleFrontController
$maxImages = (int) Configuration::get('QHR_MAX_IMAGES_PER_REVIEW');
$approvalEnabled = (int) Configuration::get('QHR_ADMIN_APPROVAL_ENABLED');
$status = 'ko';
$status = false;
$errors = array('by_key' => array(), 'general' => array());
$objModule = new QloHotelReview();
$objHotel = new HotelBranchInformation($idHotel);
@@ -104,14 +104,14 @@ class QloHotelReviewDefaultModuleFrontController extends ModuleFrontController
if ($maxImages) {
$objHotelReview->saveReviewImages();
}
$status = 'ok';
$status = true;
}
} else {
$status = 'ko';
$status = false;
$errors['general'][] = $objModule->l('Something went wrong.', 'default');
}
} else {
$status = 'ko';
$status = false;
}
if (is_array($errors['general']) && count($errors['general'])) {
@@ -127,7 +127,7 @@ class QloHotelReviewDefaultModuleFrontController extends ModuleFrontController
public function displayAjaxMarkReviewHelpful()
{
$response = array('status' => 'ko');
$response = array('status' => false);
$idHotelReview = (int) Tools::getValue('id_hotel_review');
if (!$idHotelReview) {
die(json_encode($response));
@@ -138,14 +138,14 @@ class QloHotelReviewDefaultModuleFrontController extends ModuleFrontController
}
if (QhrHotelReview::markHelpful($idHotelReview, $this->context->cookie->id_customer)) {
$response['status'] = 'ok';
$response['status'] = true;
die(json_encode($response));
}
}
public function displayAjaxReportAbuse()
{
$response = array('status' => 'ko');
$response = array('status' => false);
$idHotelReview = (int) Tools::getValue('id_hotel_review');
if (!$idHotelReview) {
die(json_encode($response));
@@ -156,14 +156,14 @@ class QloHotelReviewDefaultModuleFrontController extends ModuleFrontController
}
if (QhrHotelReview::reportAbuse($idHotelReview, $this->context->cookie->id_customer)) {
$response['status'] = 'ok';
$response['status'] = true;
die(json_encode($response));
}
}
public function displayAjaxGetReviews()
{
$response = array('status' => 'ko');
$response = array('status' => false);
$idHotel = (int) Tools::getValue('id_hotel');
$sortBy = (int) Tools::getValue('sort_by');
$page = (int)Tools::getValue('page');
@@ -181,7 +181,7 @@ class QloHotelReviewDefaultModuleFrontController extends ModuleFrontController
if (is_array($reviews) && count($reviews)) {
$response['html'] = $this->renderReviews($reviews);
$response['status'] = 'ok';
$response['status'] = true;
$response['message'] = 'HTML_OK';
$response['has_next_page'] = (bool) $hasNextPage;
}
@@ -191,7 +191,7 @@ class QloHotelReviewDefaultModuleFrontController extends ModuleFrontController
public function displayAjaxSortBy()
{
$response = array('status' => 'ko');
$response = array('status' => false);
$idHotel = (int) Tools::getValue('id_hotel');
$sortBy = (int) Tools::getValue('sort_by');
$reviewsPerPage = (int) Configuration::get('QHR_REVIEWS_PER_PAGE');
@@ -208,7 +208,7 @@ class QloHotelReviewDefaultModuleFrontController extends ModuleFrontController
if (is_array($reviews) && count($reviews)) {
$response['html'] = $this->renderReviews($reviews);
$response['status'] = 'ok';
$response['status'] = true;
$response['message'] = 'HTML_OK';
$response['has_next_page'] = (bool) $hasNextPage;
}

View File

@@ -17,6 +17,10 @@
* @license LICENSE.txt
*/
.rich-text {
white-space: break-spaces;
}
.image-row {
padding-top: 10px;
}

View File

@@ -175,6 +175,7 @@
font-size: 14px;
line-height: 24px;
color: #333;
white-space: break-spaces;
}
#hotel-reviews .btn-helpful span {

View File

@@ -83,6 +83,11 @@
margin-left: 10px;
}
#add-review-popup .review-actions-wrap .btn-review.disabled {
background-color: #1292FF;
border: 1px solid #1292FF;
}
#add-review-popup .image-input-btn {
width: 100px;
height: 100px;

View File

@@ -33,7 +33,7 @@ var QhrReview = {
dataType: 'JSON',
headers: { 'cache-control': 'no-cache' },
success: function(response) {
if (response.status == 'ok') {
if (response.status == true) {
$(btnHelpful).fadeOut('slow', function() {
$(btnHelpful).remove();
})
@@ -54,7 +54,7 @@ var QhrReview = {
dataType: 'JSON',
headers: { 'cache-control': 'no-cache' },
success: function(response) {
if (response.status == 'ok') {
if (response.status == true) {
$(btnReportAbuse).fadeOut('slow', function() {
$(btnReportAbuse).remove();
})
@@ -76,7 +76,7 @@ var QhrReview = {
type: 'POST',
headers: { 'cache-control': 'no-cache' },
success: function(response) {
if (response.status == 'ok' && response.message == 'HTML_OK') {
if (response.status == true && response.message == 'HTML_OK') {
$('.review-list').animate({opacity: 0}, 250, 'linear', function() {
$('.review-list').html(response.html);
initRaty(qlo_hotel_review_js_vars.raty_img_path, '.review-list .raty');
@@ -108,7 +108,7 @@ var QhrReview = {
type: 'POST',
headers: { 'cache-control': 'no-cache' },
success: function(response) {
if (response.message == 'HTML_OK') {
if (response.status == true && response.message == 'HTML_OK') {
$('.review-list').append(response.html);
initRaty(qlo_hotel_review_js_vars.raty_img_path, '.review-list .raty');

View File

@@ -17,7 +17,7 @@
* @license LICENSE.txt
*/
function initRaty(path) {
function initRatyRoomTypeDetail(path) {
$('.room_hotel_name_block .raty').html(''); // reset first to avoid star duplications
$.extend($.raty, { path: path });
$('.room_hotel_name_block .raty').raty({readOnly: true, hints: null, noRatedMsg: '0'});
@@ -25,6 +25,6 @@ function initRaty(path) {
$(document).ready(function () {
if (typeof qlo_hotel_review_rtd_js_vars === 'object' && qlo_hotel_review_rtd_js_vars.raty_img_path) {
initRaty(qlo_hotel_review_rtd_js_vars.raty_img_path);
initRatyRoomTypeDetail(qlo_hotel_review_rtd_js_vars.raty_img_path);
}
});

View File

@@ -36,6 +36,7 @@ var QhrReviewForm = {
},
beforeSubmit: function() {
QhrReviewForm.hideGeneralErrors();
QhrReviewForm.disableSubmitButton();
},
submit: function() {
QhrReviewForm.beforeSubmit();
@@ -51,7 +52,7 @@ var QhrReviewForm = {
type: 'POST',
success: function(response) {
var jsonResponse = JSON.parse(response);
if (jsonResponse.status == 'ok') {
if (jsonResponse.status == true) {
QhrReviewForm.close();
QhrReviewForm.showSuccessMessage();
QhrReviewForm.removeBtn();
@@ -63,7 +64,10 @@ var QhrReviewForm = {
} else {
QhrReviewForm.showGeneralErrors(jsonResponse.errors.general);
}
}
},
complete: function() {
QhrReviewForm.enableSubmitButton();
},
});
},
showGeneralErrors: function(errors) {
@@ -75,6 +79,12 @@ var QhrReviewForm = {
$('#review-general-errors').html('');
});
},
enableSubmitButton: function() {
$('#btn-submit-review').removeClass('disabled');
},
disableSubmitButton: function() {
$('#btn-submit-review').addClass('disabled');
},
showSuccessMessage: function() {
var href = '';
if (qlo_hotel_review_js_vars.admin_approval_enabled) {

View File

@@ -42,14 +42,14 @@
<div class="row">
<label class="control-label col-lg-3">{l s='Subject' mod='qlohotelreview'}</label>
<div class="col-lg-9">
<p class="form-control-static">{$currentObject->subject}</p>
<p class="form-control-static rich-text">{$currentObject->subject}</p>
</div>
</div>
<div class="row">
<label class="control-label col-lg-3">{l s='Description' mod='qlohotelreview'}</label>
<div class="col-lg-9">
<p class="form-control-static">{$currentObject->description}</p>
<p class="form-control-static rich-text">{$currentObject->description}</p>
</div>
</div>