Improve the way the service description renders in the booking page
This commit is contained in:
parent
fa6f685e13
commit
acafb0da48
2 changed files with 33 additions and 25 deletions
|
@ -83,7 +83,9 @@
|
||||||
<select id="select-provider" class="form-control"></select>
|
<select id="select-provider" class="form-control"></select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="service-description"></div>
|
<div id="service-description" class="small">
|
||||||
|
<!-- JS -->
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -833,6 +833,8 @@ App.Pages.Booking = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Update the service description and information.
|
||||||
|
*
|
||||||
* This method updates the HTML content with a brief description of the
|
* This method updates the HTML content with a brief description of the
|
||||||
* user selected service (only if available in db). This is useful for the
|
* user selected service (only if available in db). This is useful for the
|
||||||
* customers upon selecting the correct service.
|
* customers upon selecting the correct service.
|
||||||
|
@ -849,41 +851,45 @@ App.Pages.Booking = (function () {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!service) {
|
if (!service) {
|
||||||
return;
|
return; // Service not found
|
||||||
}
|
}
|
||||||
|
|
||||||
$('<strong/>', {
|
// Render the additional service information
|
||||||
'text': App.Utils.String.escapeHtml(service.name),
|
|
||||||
}).appendTo($serviceDescription);
|
|
||||||
|
|
||||||
if (service.description) {
|
const additionalInfoParts = [];
|
||||||
$('<br/>').appendTo($serviceDescription);
|
|
||||||
|
|
||||||
$('<span/>', {
|
|
||||||
'html': App.Utils.String.escapeHtml(service.description).replaceAll('\n', '<br/>'),
|
|
||||||
}).appendTo($serviceDescription);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (service.duration || Number(service.price) > 0 || service.location) {
|
|
||||||
$('<br/>').appendTo($serviceDescription);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (service.duration) {
|
if (service.duration) {
|
||||||
$('<span/>', {
|
additionalInfoParts.push(`${lang('duration')}: ${service.duration} ${lang('minutes')}`);
|
||||||
'text': '[' + lang('duration') + ' ' + service.duration + ' ' + lang('minutes') + ']',
|
|
||||||
}).appendTo($serviceDescription);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Number(service.price) > 0) {
|
if (Number(service.price) > 0) {
|
||||||
$('<span/>', {
|
additionalInfoParts.push(`${lang('price')}: ${service.price} ${service.currency}`);
|
||||||
'text': '[' + lang('price') + ' ' + service.price + ' ' + service.currency + ']',
|
|
||||||
}).appendTo($serviceDescription);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (service.location) {
|
if (service.location) {
|
||||||
$('<span/>', {
|
additionalInfoParts.push(`${lang('location')}: ${service.location}`);
|
||||||
'text': '[' + lang('location') + ' ' + service.location + ']',
|
}
|
||||||
}).appendTo($serviceDescription);
|
|
||||||
|
if (additionalInfoParts.length) {
|
||||||
|
$(`
|
||||||
|
<div class="mb-2 fst-italic">
|
||||||
|
${additionalInfoParts.join(', ')}
|
||||||
|
</div>
|
||||||
|
`).appendTo($serviceDescription);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render the service description
|
||||||
|
|
||||||
|
if (service.description.length) {
|
||||||
|
const escapedDescription = App.Utils.String.escapeHtml(service.description);
|
||||||
|
|
||||||
|
const multiLineDescription = escapedDescription.replaceAll('\n', '<br/>');
|
||||||
|
|
||||||
|
$(`
|
||||||
|
<div class="text-muted">
|
||||||
|
${multiLineDescription}
|
||||||
|
</div>
|
||||||
|
`).appendTo($serviceDescription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue