Skip to content

Commit c0e2049

Browse files
Merge pull request #38 from DHTMLX/next
Next
2 parents 28489ae + abaa153 commit c0e2049

281 files changed

Lines changed: 26800 additions & 951 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/api/config/booking-cardshape.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ cardShape?: {
2626

2727
### Parameters
2828

29-
In the **cardShape** object you can specify the following parameters (fields):
29+
In the `cardShape` object you can specify the following parameters (fields):
3030

31-
- `category` - (optional) shows/hides a card's name
31+
- `category` - (optional) shows/hides a category name
3232
- `details` - (optional) shows/hides details
3333
- `preview` - (optional) shows/hides a preview image
3434
- `price` - (optional) shows/hides price
@@ -45,7 +45,7 @@ const defaultCardShape = {
4545
preview: true,
4646
price: true,
4747
review: true,
48-
subtitle: false,
48+
subtitle: true,
4949
title: true
5050
};
5151
~~~
@@ -70,10 +70,10 @@ The snippet below demonstrates how to configure what fields to display on the le
7070
<iframe src="https://snippet.dhtmlx.com/6mxd7918?mode=result" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe>
7171

7272
:::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.
73+
You can also configure the appearance of a card using the [`cardTemplate`](api/config/booking-cardtemplate.md) property. If both `cardTemplate` and `cardShape` are applied, `cardTemplate` will override the `cardShape` settings.
7474
:::
7575

76-
**Related articles:**
76+
**Related articles**:
7777

78-
- [Defining the structure of cards](/guides/configuration/#defining-the-structure-of-cards)
79-
- [`cardTemplate`](/api/config/booking-cardtemplate)
78+
- [Defining the structure of cards](guides/configuration.md#define-the-structure-of-cards)
79+
- [`cardTemplate`](api/config/booking-cardtemplate.md)

docs/api/config/booking-cardtemplate.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ description: You can learn about the cardTemplate config in the documentation of
1313
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.
1414

1515
:::info
16-
You can also specify which fields to display using the [`cardShape`](/api/config/booking-cardshape) property
16+
You can also specify which fields to display using the [`cardShape`](api/config/booking-cardshape.md) property
1717
:::
1818

1919
### Usage
@@ -24,11 +24,11 @@ cardTemplate?: ({item: obj}) => string;
2424

2525
### Parameters
2626

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.
27+
`cardTemplate` expects a function that takes an `item` (card) object as input and returns a string of HTML that defines how the card should look.
2828

2929
### Example
3030

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.
31+
In the example below we create a function that takes the `item` (card) object and returns HTML for a card that includes a preview image (item.preview), category (item.category), title (item.title), and price (item.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.
3232

3333
~~~html {}
3434
<style>
@@ -51,41 +51,39 @@ In the example below we create a function that takes the `card` object and retur
5151
<script>
5252
const { Booking, template } = booking; //import template helper
5353
54-
function cardPreviewTemplate({ card }) {
54+
function cardPreviewTemplate({ item }) {
5555
return `
5656
<div class="custom-preview" data-action="preview-click">
5757
<div class="preview-left">
5858
<div
59-
style="background-image: url(${card.preview})"
59+
style="background-image: url(${item.preview})"
6060
class="card-photo"
6161
></div>
6262
<!-- <div class="card-photo-empty" /> -->
6363
</div>
6464
6565
<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>
66+
<div class="category">${item.category}</div>
67+
<div class="title">${item.title}</div>
68+
<div class="price">${item.price}</div>
6969
</div>
7070
</div>
7171
`;
7272
}
7373
7474
const widget = new Booking("#root", {
7575
data,
76-
cardTemplate: template(card => cardPreviewTemplate(card)), // pass the function to Booking configuration
76+
cardTemplate: template(cardPreviewTemplate), // pass the function to Booking configuration
7777
});
7878
// other parameters
7979
</script>
8080
~~~
8181

82-
8382
The snippet below demonstrates how to apply a template to the left block of a card:
8483

85-
<iframe src="https://snippet.dhtmlx.com/k2v01vng" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe>
86-
87-
**Related articles:**
84+
<iframe src="https://snippet.dhtmlx.com/k2v01vng?mode=result" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe>
8885

89-
- [Defining the structure of cards](/guides/configuration/#defining-the-structure-of-cards)
90-
- [`cardShape`](/api/config/booking-cardshape)
86+
**Related articles**:
9187

88+
- [Defining the structure of cards](guides/configuration.md#define-the-structure-of-cards)
89+
- [`cardShape`](api/config/booking-cardshape.md)

docs/api/config/booking-data.md

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ data: [
2626
stars: number,
2727
count: number
2828
},
29-
slots: [
29+
slots?: [
3030
{
3131
from: number | string, // hours from 0 to 24
3232
to: number | string, // hours from 0 to 24
@@ -36,12 +36,7 @@ data: [
3636
dates?: array, // exact dates for which rule can be applied, timestamps
3737
}
3838
],
39-
availableSlots?: [
40-
{
41-
id: string|number,
42-
time:[number, number] //timestamp, length in minutes
43-
},
44-
],
39+
availableSlots?: [number, number][], // each slot: [timestamp, slot duration in minutes]
4540
usedSlots?: number[], //timestamps
4641
slotSize?: number, //minutes
4742
slotGap?: number //minutes
@@ -53,34 +48,32 @@ data: [
5348

5449
For each card object you can specify the following parameters:
5550

56-
- `id` - (required) the ID of a card
51+
- `id` - (required) the ID of a card
5752
- `title` - (required) the title of a card (e.g., a specialist's name)
5853
- `category` - (optional) the category name of a card (e.g., a specialist's job)
59-
- `subtitle` - (optional) the subtitle of a card
54+
- `subtitle` - (optional) the subtitle of a card
6055
- `details` - (optional) other details of a card
6156
- `preview` - (optional) a card preview which is the link to the card image
62-
- `price` - (optional) the price of the service
63-
- `review` - (optional) rating information that includes the following parameters:
64-
- `stars` - (optional) the number of rating stars (out of five)
57+
- `price` - (optional) the price of the service
58+
- `review` - (optional) rating information that includes the following parameters:
59+
- `stars` - (optional) the number of rating stars (out of five)
6560
- `count` - (optional) the number of reviews
66-
- `slots` - (required) an array of objects with the following parameters for each slot object:
61+
- `slots` - (optional) an array of objects that defines slot rules (either `slots` or `availableSlots` should be provided to display bookable time); each slot object has the following parameters:
6762
- `from` - (required) a slot start time in hours from 0 to 24
6863
- `to` - (required) a slot end time in hours from 0 to 24
6964
- `size` - (optional) the duration of one slot in minutes
7065
- `gap` - (optional) the gap between slots in minutes; 0 is set by default
71-
- `days` - (optional) days of the week when a slot is available for booking; possible values: from 0 to 6 where 0 is Sunday and 6 is Saturday; if no days are specified, all days are applied by default; if days are specified, the slot parameters (**to**, **from**, **size**, **gap**) defined for these days will be applied
72-
- `dates` - (optional) an array of timestamps in milliseconds which are exact dates when a slot is available; the slot parameters (**to**, **from**, **size**, **gap**) for these specified dates will be applied (timestamps are in a local timezone)
66+
- `days` - (optional) days of the week when a slot is available for booking; possible values: from 0 to 6 where 0 is Sunday and 6 is Saturday; if no days are specified, all days are applied by default; if days are specified, the slot parameters (`to`, `from`, `size`, `gap`) defined for these days will be applied
67+
- `dates` - (optional) an array of timestamps in milliseconds which are exact dates when a slot is available; the slot parameters (`to`, `from`, `size`, `gap`) for these specified dates will be applied (timestamps are in milliseconds and should represent local wall-clock time)
7368

7469
:::note
7570
Slot parameters specified for days will override common parameters defined for all days.
7671
Slot parameters specified for dates will override parameters defined for specific days and all days.
77-
If several slots objects are created for the same day, make sure that slots time ranges (from and to) with **different** size and gap do not overlap, otherwise all slots data for these days will not be applied.
72+
If several slot objects target the same day with different `size` or `gap`, their time ranges (`from``to`) must not overlap. Overlapping ranges make the widget skip all slots for that day.
7873
:::
7974

80-
- `availableSlots` - (optional) an array of timestamps of available slots in milliseconds; if available slots are specified here, all slots from the `slots` array are ignored (i.e., become unavailable); each object in the array has the next parameters:
81-
- `id` - (required) the id of a slot
82-
- `time` - (required) an array that includes timestamp and slot duration in minutes (timestamps are in a local timezone)
83-
- `usedSlots` - (optional) an array of timestamps of booked slots in milliseconds (timestamps are in a local timezone)
75+
- `availableSlots` - (optional) an array of available slots; each slot is an array `[timestamp, duration]` where the timestamp is in milliseconds (representing local wall-clock time) and the duration is the slot length in minutes; if available slots are specified here, all slots from the `slots` array are ignored (i.e., become unavailable)
76+
- `usedSlots` - (optional) an array of timestamps of booked slots in milliseconds (timestamps are in milliseconds and should represent local wall-clock time)
8477
- `slotSize` - (optional) the duration of a slot in minutes; the value will be applied to all slots of this card if other value is not set inside the `slots` object; *60* minutes is set by default
8578
- `slotGap` - (optional) the gap between slots in minutes that is set for all slots in the current card; this value is applied if any other value is not specified inside the `slots` object; 0 is set by default
8679

@@ -93,12 +86,12 @@ const data = [
9386
title: "Debra Weeks",
9487
category: "Allergist",
9588
subtitle: "7 years of experience",
96-
details:
89+
details:
9790
"Silverstone Medical Center (Vanderbilt Avenue 13, Chestnut, New Zealand)",
9891
preview: "https://snippet.dhtmlx.com/codebase/data/booking/01/img/01.jpg",
9992
price: "37 $",
10093
review: {
101-
star: 1,
94+
stars: 1,
10295
count: 40
10396
},
10497
slots: [
@@ -137,4 +130,4 @@ new booking.Booking("#root", {
137130
});
138131
~~~
139132

140-
**Related articles:** [Defining slot rules](/guides/configuration#defining-slot-rules)
133+
**Related articles**: [Defining slot rules](guides/configuration.md#define-slot-rules)

docs/api/config/booking-end.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ end?: Date;
1818

1919
### Parameters
2020

21-
- `Date` - the end date until which to display available slots; the default value is one year from the current date.
21+
- `end` - (optional) the end date until which to display available slots; the default value is one year from the current date.
2222

2323
### Example
2424

@@ -30,6 +30,6 @@ new booking.Booking("#root", {
3030
});
3131
~~~
3232

33-
The snippet below shows how to set the [start](/api/config/booking-start) and end dates:
33+
The snippet below shows how to set the [start](api/config/booking-start.md) and end dates:
3434

35-
<iframe src="https://snippet.dhtmlx.com/cc28whe7?mode=result" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe>
35+
<iframe src="https://snippet.dhtmlx.com/cc28whe7?mode=result" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe>

docs/api/config/booking-filtershape.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ filterShape: {
3131

3232
### Parameters
3333

34-
- `text` - (optional) if **true**, the text input field is displayed (default); if **false**, the text field is hidden
35-
- `id` - (required) the id of a card
36-
- `suggest` - (required) if **true**, the auto-complete is enabled and the values (from the [`data`](/api/config/booking-data) object) that match a user's input text will be displayed
34+
- `text` - (optional) if `true`, the text input field is displayed (default); if `false`, the text field is hidden
35+
- `id` - (required) the name of a card field to filter by (a `data` property, for example `category` or `title`)
36+
- `suggest` - (optional) if `true`, the auto-complete is enabled and the values (from the [`data`](api/config/booking-data.md) object) that match a user's input text will be displayed
3737
- `label` - (optional) the label for the property from the `data` object. See [Default config](#default-config) below.
38-
- `date` - (optional) shows/hides the date field; **true** is set by default (the field is shown)
39-
- `time` - (optional) shows/hides the time field. If set to **true**, it takes an array of objects with default time options for a slot. For each object you can specify the following parameters:
38+
- `date` - (optional) shows/hides the date field; `true` is set by default (the field is shown)
39+
- `time` - (optional) shows/hides the time field. If set to `true`, it takes an array of objects with default time options for a slot. For each object you can specify the following parameters:
4040
- `from` - (required) the start time for a slot; it can be a number from 0 to 24 that specifies the time in hours (e.g., 9 means 9:00, 8.5 means 8:30) or a string in the format "h:m" (for example, "8:30")
4141
- `to` - (required) the end time for a slot; it can be a number from 0 to 24 that specifies the time in hours (e.g., 9 means 9:00, 8.5 means 8:30) or a string in the format "h:m" (for example, "8:30")
4242
- `label` - (optional) placeholder for the time field
4343
If the `time` parameters are not set, the default values are applied: see [Default config](#default-config) below.
44-
- `autoApply` - (optional) if **true**, the search criteria will be automatically applied (no need to initiate the search by clicking the button); **false** is set by default
44+
- `autoApply` - (optional) if `true`, the search criteria will be automatically applied (no need to initiate the search by clicking the button); `false` is set by default
4545

4646
### Default config
4747

@@ -84,6 +84,6 @@ new booking.Booking("#root", {
8484
});
8585
~~~
8686

87-
The snippet below demonstrates how to configure filter:
87+
The snippet below demonstrates how to configure the filter:
8888

8989
<iframe src="https://snippet.dhtmlx.com/b5uj78bs?mode=result" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe>

docs/api/config/booking-formshape.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,26 @@ description: You can learn about the formShape config in the documentation of th
1313
### Usage
1414

1515
~~~jsx {}
16-
formShape: {
16+
formShape: [{
1717
comp: "text" | "textarea",
1818
key: string,
1919
label?: string,
20-
required?: boolean
21-
};
20+
required?: boolean,
21+
validation?: (value: any) => boolean,
22+
errorMessage?: string
23+
}];
2224
~~~
2325

2426
### Parameters
2527

2628
For each field you can specify the following parameters:
2729

28-
- `comp` - (required) the field type (**text** or **textarea**)
30+
- `comp` - (required) the field type (`text` or `textarea`)
2931
- `key` - (required) the id of a field
3032
- `label` - (optional) the field label
31-
- `required` - (optional) if the value is set to **true**, the field should not be empty and it's required to submit the booking form; if **false**, the field can be empty
33+
- `required` - (optional) if the value is set to `true`, the field should not be empty and it's required to submit the booking form; if `false`, the field can be empty
34+
- `validation` - (optional) a function that takes the field value and returns a boolean; the field is considered valid when the function returns `true`
35+
- `errorMessage` - (optional) the message shown when the value does not pass validation
3236

3337
### Default config
3438

@@ -68,17 +72,17 @@ const defaultFormShape = [
6872
~~~jsx {1-17,21}
6973
const formShape = [
7074
{
71-
type: "text",
75+
comp: "text",
7276
key: "name",
7377
label: "Name"
7478
},
7579
{
76-
type: "text",
80+
comp: "text",
7781
key: "contact",
7882
label: "Mobile"
7983
},
8084
{
81-
type: "textarea",
85+
comp: "textarea",
8286
key: "description",
8387
label: "Details"
8488
},

docs/api/config/booking-infoshape.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ The snippet below shows how to configure what to display on the left side of the
6464
<iframe src="https://snippet.dhtmlx.com/pd6wp1xc?mode=result" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe>
6565

6666
:::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.
67+
You can also control which fields to display in the information block of the Booking dialog using the [`infoTemplate`](api/config/booking-infotemplate.md) property. But if both properties are applied, `infoTemplate` will override the `infoShape` settings.
6868
:::
6969

70-
**Related articles:**
70+
**Related articles**:
7171

72-
- [Configuring the Booking dialog](/guides/configuration/#configuring-the-booking-dialog)
73-
- [`infoTemplate`](/api/config/booking-infotemplate)
72+
- [Configuring the Booking dialog](guides/configuration.md#configure-the-booking-dialog)
73+
- [`infoTemplate`](api/config/booking-infotemplate.md)

0 commit comments

Comments
 (0)