Fixed: default functional and UI flow of Back-office implemented, instead of custom styling and flow
Co-authored-by: Name <sumit201@webkul.in>
This commit is contained in:
@@ -635,22 +635,3 @@ body.adminhotelroomsbooking .ui-tooltip {
|
||||
.error-border {
|
||||
outline: rgb(210, 124, 130) solid 1px;
|
||||
border-radius: 2px;}
|
||||
#hotel-images-files-list {
|
||||
margin-top: 10px;}
|
||||
#hotel-images-files-list .hotel-images-file-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 8px 10px;
|
||||
border-bottom: 1px solid #eee;}
|
||||
#hotel-images-files-list .hotel-images-file-row:last-child {
|
||||
border-bottom: none;}
|
||||
#hotel-images-files-list .hotel-images-file-row > span {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
padding-right: 10px;}
|
||||
#hotel-images-files-list .hotel-images-file-row > button {
|
||||
flex-shrink: 0;}
|
||||
#hotel-images-heading #open-add-hotel-images-modal {
|
||||
margin-top: 1.5px;}
|
||||
|
||||
@@ -43,12 +43,6 @@ $(document).ready(function () {
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function updateBadge(delta)
|
||||
{
|
||||
var $badge = $('#hotel-images-heading .badge');
|
||||
$badge.text(Math.max(0, parseInt($badge.text(), 10) + delta));
|
||||
}
|
||||
|
||||
function getCheckedImageIds()
|
||||
{
|
||||
return $('.hotel-image-checkbox:checked').map(function () {
|
||||
@@ -68,7 +62,7 @@ $(document).ready(function () {
|
||||
if (fileInput) {
|
||||
fileInput.value = '';
|
||||
}
|
||||
renderHotelImagesFileList(null);
|
||||
$('#hotel-images-file-name').val('');
|
||||
openModalWithLoader('#addHotelImagesModal');
|
||||
});
|
||||
|
||||
@@ -76,56 +70,17 @@ $(document).ready(function () {
|
||||
$('#hotel-images-file-input').trigger('click');
|
||||
});
|
||||
|
||||
$(document).on('change', '#hotel-images-file-input', function () {
|
||||
renderHotelImagesFileList(this.files);
|
||||
$('#hotel-images-file-name').on('click', function () {
|
||||
$('#hotel-images-file-input').trigger('click');
|
||||
});
|
||||
|
||||
$(document).on('click', '.hotel-images-remove-file', function () {
|
||||
var removeIdx = parseInt($(this).data('index'), 10);
|
||||
var fileInput = document.getElementById('hotel-images-file-input');
|
||||
if (!fileInput || !fileInput.files) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
var dt = new DataTransfer();
|
||||
for (var i = 0; i < fileInput.files.length; i++) {
|
||||
if (i !== removeIdx) {
|
||||
dt.items.add(fileInput.files[i]);
|
||||
}
|
||||
}
|
||||
fileInput.files = dt.files;
|
||||
} catch (e) {
|
||||
// ponytail: DataTransfer unsupported in this browser, list just won't reflect the removal
|
||||
}
|
||||
renderHotelImagesFileList(fileInput.files);
|
||||
$('#hotel-images-file-input').on('change', function () {
|
||||
var fileNames = Array.prototype.map.call(this.files, function (file) {
|
||||
return file.name;
|
||||
});
|
||||
$('#hotel-images-file-name').val(fileNames.join(', '));
|
||||
});
|
||||
|
||||
function renderHotelImagesFileList(files)
|
||||
{
|
||||
var $list = $('#hotel-images-files-list').empty();
|
||||
if (!files || !files.length) {
|
||||
$list.hide();
|
||||
return;
|
||||
}
|
||||
$list.show();
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
(function (idx, file) {
|
||||
var size = file.size < 1048576
|
||||
? (file.size / 1024).toFixed(1) + ' KB'
|
||||
: (file.size / 1048576).toFixed(1) + ' MB';
|
||||
$list.append(
|
||||
$('<li class="hotel-images-file-row"/>')
|
||||
.append($('<span/>').text(file.name + ' (' + size + ')'))
|
||||
.append(
|
||||
$('<button type="button" class="btn btn-default btn-xs hotel-images-remove-file"/>')
|
||||
.attr('data-index', idx)
|
||||
.html('<i class="icon-trash"></i>')
|
||||
)
|
||||
);
|
||||
})(i, files[i]);
|
||||
}
|
||||
}
|
||||
|
||||
$('#hotel-images-upload-btn').on('click', function () {
|
||||
var fileInput = document.getElementById('hotel-images-file-input');
|
||||
var files = fileInput ? Array.prototype.slice.call(fileInput.files) : [];
|
||||
@@ -172,7 +127,6 @@ $(document).ready(function () {
|
||||
if (resp && resp.success) {
|
||||
$('.list-empty-tr').hide();
|
||||
$('#hotel-image-table tbody').append(resp.image_row);
|
||||
updateBadge(1);
|
||||
initHotelImagePreview();
|
||||
showSuccessMessage(imgUploadSuccessMsg);
|
||||
} else {
|
||||
@@ -196,6 +150,7 @@ $(document).ready(function () {
|
||||
var isCover = $(this).attr('data-is-cover');
|
||||
var triggerElement = $(this);
|
||||
if (isCover == 0) {
|
||||
$('#page-loader').show();
|
||||
$.ajax({
|
||||
type:'POST',
|
||||
url: adminHotelCtrlUrl,
|
||||
@@ -208,13 +163,11 @@ $(document).ready(function () {
|
||||
},
|
||||
success: function(result) {
|
||||
if (result.status) {
|
||||
// remover cover image identifier from old cover image
|
||||
var oldCoverImageTr = $("#hotel-image-table tbody tr.cover-image-tr");
|
||||
oldCoverImageTr.removeClass("cover-image-tr").find("td.cover-image-td").removeClass("cover-image-td").find("a.changer-cover-image").removeClass("text-success").addClass("text-danger").attr("data-is-cover", "0").find("i.icon-check").removeClass("icon-check").addClass("icon-times");
|
||||
oldCoverImageTr.find("td button.delete-hotel-image").attr("data-is-cover", "0");
|
||||
oldCoverImageTr.find("td button.edit-hotel-image").attr("data-is-cover", "0");
|
||||
|
||||
// Add classes in new covre image elements
|
||||
triggerElement.removeClass("text-danger").addClass("text-success").attr("data-is-cover", "1").find("i.icon-times").removeClass("icon-times").addClass("icon-check");
|
||||
triggerElement.parent().addClass("cover-image-td").parent().addClass("cover-image-tr").find("td button.delete-hotel-image").attr("data-is-cover", "1");
|
||||
triggerElement.parent().parent().find("td button.edit-hotel-image").attr("data-is-cover", "1");
|
||||
@@ -227,6 +180,8 @@ $(document).ready(function () {
|
||||
error: function(data){
|
||||
showErrorMessage(coverImgErrorMsg);
|
||||
}
|
||||
}).always(function () {
|
||||
$('#page-loader').hide();
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -401,7 +356,6 @@ $(document).ready(function () {
|
||||
initHotelImagePreview();
|
||||
}
|
||||
showEmptyRowIfNoImagesLeft();
|
||||
updateBadge(-result.deleted_ids.length);
|
||||
$('.hotel-image-checkbox').prop('checked', false);
|
||||
showSuccessMessage(deleteImgSuccessMsg);
|
||||
} else {
|
||||
@@ -426,6 +380,7 @@ $(document).ready(function () {
|
||||
var idImage = triggerElement.attr('data-id-image');
|
||||
|
||||
if (parseInt(idHotel) && parseInt(idImage)) {
|
||||
$('#page-loader').show();
|
||||
$.ajax({
|
||||
type:'POST',
|
||||
url: adminHotelCtrlUrl,
|
||||
@@ -446,7 +401,6 @@ $(document).ready(function () {
|
||||
}
|
||||
|
||||
showEmptyRowIfNoImagesLeft();
|
||||
updateBadge(-1);
|
||||
|
||||
showSuccessMessage(deleteImgSuccessMsg);
|
||||
} else {
|
||||
@@ -456,6 +410,8 @@ $(document).ready(function () {
|
||||
error: function(data){
|
||||
showErrorMessage(deleteImgErrorMsg);
|
||||
}
|
||||
}).always(function () {
|
||||
$('#page-loader').hide();
|
||||
});
|
||||
} else {
|
||||
showErrorMessage(deleteImgErrorMsg);
|
||||
|
||||
@@ -438,15 +438,14 @@
|
||||
{hook h='displayAdminAddHotelFormImagesTabBefore' id_hotel=$hook_arg_id_hotel}
|
||||
|
||||
{if isset($hotel_info.id) && $hotel_info.id}
|
||||
<div class="panel-heading" id="hotel-images-heading">
|
||||
<i class="icon-image"></i> {l s='Hotel Images' mod='hotelreservationsystem'}
|
||||
<span class="badge">{if isset($hotelImages) && $hotelImages}{$hotelImages|@count}{else}0{/if}</span>
|
||||
<button type="button" class="btn btn-primary pull-right" id="open-add-hotel-images-modal">
|
||||
<i class="icon-plus"></i> {l s='Add Images' mod='hotelreservationsystem'}
|
||||
</button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<button type="button" class="btn btn-primary pull-right" id="open-add-hotel-images-modal">
|
||||
<i class="icon-plus-sign"></i> {l s='Add file' mod='hotelreservationsystem'}
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<hr>
|
||||
{include file="../../_partials/htl-images-list.tpl"}
|
||||
</div>
|
||||
</div>
|
||||
@@ -460,18 +459,25 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-lg-3">{l s='Select images' mod='hotelreservationsystem'}</label>
|
||||
<label class="control-label col-lg-3">{l s='Images' mod='hotelreservationsystem'}</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="file" id="hotel-images-file-input" class="hide" accept="image/gif, image/jpg, image/jpeg, image/png" multiple>
|
||||
<button type="button" class="btn btn-default" id="hotel-images-file-add-btn"><i class="icon-folder-open"></i> {l s='Add files...' mod='hotelreservationsystem'}</button>
|
||||
<ul class="list-unstyled" id="hotel-images-files-list" style="display:none;"></ul>
|
||||
<div class="dummyfile input-group">
|
||||
<span class="input-group-addon"><i class="icon-file"></i></span>
|
||||
<input id="hotel-images-file-name" type="text" readonly>
|
||||
<span class="input-group-btn">
|
||||
<button type="button" id="hotel-images-file-add-btn" class="btn btn-default">
|
||||
<i class="icon-folder-open"></i> {l s='Add file' mod='hotelreservationsystem'}
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-lg-3" for="id_htl_image_category">{l s='Image category' mod='hotelreservationsystem'}</label>
|
||||
<label class="control-label col-lg-3" for="id_htl_image_category">{l s='Category' mod='hotelreservationsystem'}</label>
|
||||
<div class="col-lg-9">
|
||||
<select class="form-control" id="id_htl_image_category" name="id_htl_image_category">
|
||||
<option value="0">{l s='Select category (optional)' mod='hotelreservationsystem'}</option>
|
||||
<option value="0">{l s='Select category' mod='hotelreservationsystem'}</option>
|
||||
{if isset($hotelImageCategories) && $hotelImageCategories}
|
||||
{foreach from=$hotelImageCategories item=hotelImageCategory}
|
||||
<option value="{$hotelImageCategory.id_htl_image_category|intval}">{$hotelImageCategory.name|escape:'html':'UTF-8'}</option>
|
||||
@@ -517,10 +523,10 @@
|
||||
<div class="modal-body">
|
||||
<input type="hidden" id="edit_hotel_image_id">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-lg-3" for="edit_id_htl_image_category">{l s='Image category' mod='hotelreservationsystem'}</label>
|
||||
<label class="control-label col-lg-3" for="edit_id_htl_image_category">{l s='Category' mod='hotelreservationsystem'}</label>
|
||||
<div class="col-lg-9">
|
||||
<select class="form-control" id="edit_id_htl_image_category">
|
||||
<option value="0">{l s='Select category (optional)' mod='hotelreservationsystem'}</option>
|
||||
<option value="0">{l s='Select category' mod='hotelreservationsystem'}</option>
|
||||
{if isset($hotelImageCategories) && $hotelImageCategories}
|
||||
{foreach from=$hotelImageCategories item=hotelImageCategory}
|
||||
<option value="{$hotelImageCategory.id_htl_image_category|intval}">{$hotelImageCategory.name|escape:'html':'UTF-8'}</option>
|
||||
@@ -557,14 +563,14 @@
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><i class="icon-remove-sign"></i></button>
|
||||
<h4 class="modal-title"><i class="icon-tags"></i> {l s='Update selection' mod='hotelreservationsystem'}</h4>
|
||||
<h4 class="modal-title"><i class="icon-edit"></i> {l s='Bulk Update selection' mod='hotelreservationsystem'}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-lg-3" for="bulk_id_htl_image_category">{l s='Image category' mod='hotelreservationsystem'}</label>
|
||||
<label class="control-label col-lg-3" for="bulk_id_htl_image_category">{l s='Category' mod='hotelreservationsystem'}</label>
|
||||
<div class="col-lg-9">
|
||||
<select class="form-control" id="bulk_id_htl_image_category">
|
||||
<option value="0">{l s='Select category (optional)' mod='hotelreservationsystem'}</option>
|
||||
<option value="0">{l s='Select category' mod='hotelreservationsystem'}</option>
|
||||
{if isset($hotelImageCategories) && $hotelImageCategories}
|
||||
{foreach from=$hotelImageCategories item=hotelImageCategory}
|
||||
<option value="{$hotelImageCategory.id_htl_image_category|intval}">{$hotelImageCategory.name|escape:'html':'UTF-8'}</option>
|
||||
|
||||
Reference in New Issue
Block a user