Skip to content

Commit 141a84f

Browse files
committed
Merge branch 'next'
2 parents 133d0e9 + b3574a6 commit 141a84f

19 files changed

+1675
-32
lines changed

docs/api/config/booking-cardshape.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: You can learn about the cardShape config in the documentation of th
88

99
### Description
1010

11-
@short: Optional. An object with settings for managing information displayed on the left side of cards
11+
@short: Optional. An object with settings for managing information displayed on the left side of each card
1212

1313
### Usage
1414

@@ -26,7 +26,7 @@ cardShape?: {
2626

2727
### Parameters
2828

29-
To configure the card appearance, in the **cardShape** object you can specify the following parameters (fields):
29+
In the **cardShape** object you can specify the following parameters (fields):
3030

3131
- `category` - (optional) shows/hides a card's name
3232
- `details` - (optional) shows/hides details
@@ -65,6 +65,15 @@ new booking.Booking("#root", {
6565
});
6666
~~~
6767

68-
The snippet below demonstrates how to configure what to display on the left side of cards:
68+
The snippet below demonstrates how to configure what fields to display on the left side of cards:
6969

7070
<iframe src="https://snippet.dhtmlx.com/6mxd7918?mode=result" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe>
71+
72+
:::info
73+
You can also configure the appearance of a card using the [`cardTemplate`](/api/config/booking-cardtemplate) property. If both `cardTemplate` and `cardShape` are applied, `cardTemplate` will override the `cardShape` settings.
74+
:::
75+
76+
**Related articles:**
77+
78+
- [Defining the structure of cards](/guides/configuration/#defining-the-structure-of-cards)
79+
- [`cardTemplate`](/api/config/booking-cardtemplate)
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
sidebar_label: cardTemplate
3+
title: cardTemplate
4+
description: You can learn about the cardTemplate config in the documentation of the DHTMLX JavaScript Booking library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX Booking.
5+
---
6+
7+
# cardTemplate
8+
9+
### Description
10+
11+
@short: Optional. Allows applying a template to a card's left block
12+
13+
The property specifies the HTML structure and layout of each card's block (the left side of each card). It means you can manage which fields are displayed, how they are arranged, and how they look.
14+
15+
:::info
16+
You can also specify which fields to display using the [`cardShape`](/api/config/booking-cardshape) property
17+
:::
18+
19+
### Usage
20+
21+
~~~jsx {}
22+
cardTemplate?: ({item: obj}) => string;
23+
~~~
24+
25+
### Parameters
26+
27+
`cardTemplate` expects a function that takes a `card` object as input and returns a string of HTML that defines how the card should look.
28+
29+
### Example
30+
31+
In the example below we create a function that takes the `card` object and returns HTML for a card that includes a preview image (card.preview), category (card.category), title (card.title), and price (card.price). You need to create your own HTML template to be applied to a card and import the **template** helper. Then pass the function into the Booking configuration by assigning the function to the `cardTemplate` property.
32+
33+
~~~html {}
34+
<style>
35+
.custom-preview {
36+
display: flex;
37+
width: 100%;
38+
height: 100%;
39+
gap: 30px;
40+
}
41+
42+
.preview-left {
43+
width: auto;
44+
display: flex;
45+
flex-direction: column;
46+
gap: 4px;
47+
}
48+
/* other styles */
49+
</style>
50+
51+
<script>
52+
const { Booking, template } = booking; //import template helper
53+
54+
function cardPreviewTemplate({ card }) {
55+
return `
56+
<div class="custom-preview" data-action="preview-click">
57+
<div class="preview-left">
58+
<div
59+
style="background-image: url(${card.preview})"
60+
class="card-photo"
61+
></div>
62+
<!-- <div class="card-photo-empty" /> -->
63+
</div>
64+
65+
<div class="preview-right">
66+
<div class="category">${card.category}</div>
67+
<div class="title">${card.title}</div>
68+
<div class="price">${card.price}</div>
69+
</div>
70+
</div>
71+
`;
72+
}
73+
74+
const widget = new Booking("#root", {
75+
data,
76+
cardTemplate: template(card => cardPreviewTemplate(card)), // pass the function to Booking configuration
77+
});
78+
// other parameters
79+
</script>
80+
~~~
81+
82+
83+
The snippet below demonstrates how to apply a template to the left block of a card:
84+
85+
<iframe src="https://snippet.dhtmlx.com/k2v01vng" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe>
86+
87+
**Related articles:**
88+
89+
- [Defining the structure of cards](/guides/configuration/#defining-the-structure-of-cards)
90+
- [`cardShape`](/api/config/booking-cardshape)
91+

docs/api/config/booking-infoshape.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,12 @@ new booking.Booking("#root", {
6262
The snippet below shows how to configure what to display on the left side of the Booking dialog:
6363

6464
<iframe src="https://snippet.dhtmlx.com/pd6wp1xc?mode=result" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe>
65+
66+
:::info
67+
You can also control which fields to display in the information block of the Booking dialog using the [`infoTemplate`](/api/config/booking-infotemplate) property. But if both properties are applied, `infoTemplate` will override the `infoShape` settings.
68+
:::
69+
70+
**Related articles:**
71+
72+
- [Configuring the Booking dialog](/guides/configuration/#configuring-the-booking-dialog)
73+
- [`infoTemplate`](/api/config/booking-infotemplate)
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
sidebar_label: infoTemplate
3+
title: infoTemplate
4+
description: You can learn about the infoTemplate config in the documentation of the DHTMLX JavaScript Booking library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX Booking.
5+
---
6+
7+
# infoTemplate
8+
9+
### Description
10+
11+
@short: Optional. Allows applying a template to the information block in the Booking dialog
12+
13+
### Usage
14+
15+
~~~jsx {}
16+
infoTemplate?: ({item: obj, slot: number}) => string;
17+
~~~
18+
19+
### Parameters
20+
21+
`infoTemplate` takes the `card` item object and selected `slot` timestamp as input and returns a string of HTML.
22+
23+
24+
### Example
25+
26+
In the example below, we define the `cardInfoTemplate` function that will generate the custom HTML for the information block. This function will receive the `item` (card object) and `slot` (slot timestamp) as input parameters. The function returns div containers representing the information block for a selected booking item, including an image, category, title, and formatted date. You should also import the **template** helper and assign your custom function to `infoTemplate`.
27+
28+
~~~html
29+
<style>
30+
.custom-info {
31+
display: flex;
32+
flex-direction: column;
33+
align-items: center;
34+
width: 100%;
35+
height: 100%;
36+
}
37+
38+
.info-wrapper {
39+
display: flex;
40+
flex-direction: column;
41+
align-items: center;
42+
gap: 20px;
43+
padding: 34px;
44+
background: rgba(128, 128, 155, 0.12);
45+
border-radius: 8px;
46+
}
47+
/* other styles */
48+
</style>
49+
50+
<script>
51+
const { Booking, template } = booking; // import template helper
52+
53+
function cardInfoTemplate({
54+
item,
55+
slot,
56+
}) {
57+
return `
58+
<div class="custom-info">
59+
<div class="info-wrapper">
60+
<div class="photo-wrapper">
61+
${getPhotoElement(item.preview, "info")}
62+
</div>
63+
<span class="info-title">${item.title}</span>
64+
<span class="info-category">${item.category}</span>
65+
<div class="date" data-action="reset-slot">
66+
<i class="icon wxi-calendar"></i>
67+
<span>${formatDate(slot, { dateFormat, timeFormat })}</span>
68+
</div>
69+
</div>
70+
</div>
71+
`;
72+
}
73+
74+
const widget = new Booking("#root", {
75+
data,
76+
infoTemplate: template(item => cardInfoTemplate(item)), // pass the function to the widget configuration
77+
});
78+
</script>
79+
~~~
80+
81+
The snippet below shows how to apply a template to the information block of the Booking dialog that appears when a user clicks the time slot button:
82+
83+
<iframe src="https://snippet.dhtmlx.com/byb94ipu?mode=result" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe>
84+
85+
:::info
86+
You can also control which fields to display in the information block of the Booking dialog using the [`infoShape`](/api/config/booking-infoshape) property. But if both properties are applied, `infoTemplate` will override the `infoShape` settings.
87+
:::
88+
89+
**Related articles:**
90+
91+
- [Configuring the Booking dialog](/guides/configuration/#configuring-the-booking-dialog)
92+
- [`infoShape`](/api/config/booking-infoshape)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
sidebar_label: renderType
3+
title: renderType
4+
description: You can learn about renderType in the documentation of the DHTMLX JavaScript Booking library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX Booking.
5+
---
6+
7+
# renderType
8+
9+
### Description
10+
11+
@short: Optional. Defines how cards are rendered
12+
13+
The property helps optimize performance when working with a large number of cards.
14+
15+
### Usage
16+
17+
~~~jsx {}
18+
renderType?: "default" | "lazy";
19+
~~~
20+
21+
### Parameters
22+
23+
- `default` - renders all cards loaded to the widget (set by default)
24+
- `lazy` - renders only visible cards
25+
26+
### Example
27+
28+
~~~jsx {}
29+
new booking.Booking("#root", {
30+
data,
31+
renderType: "lazy",
32+
// other parameters
33+
});
34+
~~~
35+
36+
The snippet below shows how to handle rendering large data sets:
37+
38+
<iframe src="https://snippet.dhtmlx.com/fb9a5a3b?mode=result" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe>

docs/api/overview/booking-api-overview.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,13 @@ new booking.Booking("#root", {
6464
| [](../config/booking-data.md) | @getshort(../config/booking-data.md) |
6565
| [](../config/booking-end.md) | @getshort(../config/booking-end.md) |
6666
| [](../config/booking-cardshape.md) | @getshort(../config/booking-cardshape.md) |
67+
| [](../config/booking-cardtemplate.md) | @getshort(../config/booking-cardtemplate.md) |
6768
| [](../config/booking-filtershape.md) | @getshort(../config/booking-filtershape.md) |
6869
| [](../config/booking-formshape.md) | @getshort(../config/booking-formshape.md) |
6970
| [](../config/booking-infoshape.md) | @getshort(../config/booking-infoshape.md) |
71+
| [](../config/booking-infotemplate.md) | @getshort(../config/booking-infotemplate.md) |
7072
| [](../config/booking-locale.md) | @getshort(../config/booking-locale.md) |
73+
| [](../config/booking-rendertype.md) | @getshort(../config/booking-rendertype.md) |
7174
| [](../config/booking-slotgap.md) | @getshort(../config/booking-slotgap.md) |
7275
| [](../config/booking-slotsize.md) | @getshort(../config/booking-slotsize.md) |
7376
| [](../config/booking-start.md) | @getshort(../config/booking-start.md) |

docs/api/overview/booking-properties-overview.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ description: You can have properties overview of JavaScript Booking in the docum
1111
| [](../config/booking-data.md) | @getshort(../config/booking-data.md) |
1212
| [](../config/booking-end.md) | @getshort(../config/booking-end.md) |
1313
| [](../config/booking-cardshape.md) | @getshort(../config/booking-cardshape.md) |
14+
| [](../config/booking-cardtemplate.md) | @getshort(../config/booking-cardtemplate.md) |
1415
| [](../config/booking-filtershape.md) | @getshort(../config/booking-filtershape.md) |
1516
| [](../config/booking-formshape.md) | @getshort(../config/booking-formshape.md) |
1617
| [](../config/booking-infoshape.md) | @getshort(../config/booking-infoshape.md) |
18+
| [](../config/booking-infotemplate.md) | @getshort(../config/booking-infotemplate.md) |
1719
| [](../config/booking-locale.md) | @getshort(../config/booking-locale.md) |
20+
| [](../config/booking-rendertype.md) | @getshort(../config/booking-rendertype.md) |
1821
| [](../config/booking-slotgap.md) | @getshort(../config/booking-slotgap.md) |
1922
| [](../config/booking-slotsize.md) | @getshort(../config/booking-slotsize.md) |
2023
| [](../config/booking-start.md) | @getshort(../config/booking-start.md) |

docs/assets/trial-booking.png

781 KB
Loading

0 commit comments

Comments
 (0)