@meetelise/chat 1.71.0 → 1.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/WebComponent/SchedulerV2/community-picker.d.ts +5 -24
- package/dist/src/WebComponent/SchedulerV2/itinerary-editor.d.ts +5 -0
- package/dist/src/WebComponent/SchedulerV2/tour-scheduler-v2.d.ts +21 -3
- package/package.json +1 -1
- package/public/dist/index.js +261 -248
- package/src/WebComponent/SchedulerV2/community-picker.ts +56 -175
- package/src/WebComponent/SchedulerV2/itinerary-editor.ts +41 -7
- package/src/WebComponent/SchedulerV2/tour-scheduler-v2.ts +151 -25
- package/src/tourSchedulerV2Booking.test.ts +84 -3
|
@@ -2,14 +2,12 @@ import { css, html, LitElement, TemplateResult } from "lit";
|
|
|
2
2
|
import { customElement, property, state } from "lit/decorators.js";
|
|
3
3
|
import { classMap } from "lit/directives/class-map.js";
|
|
4
4
|
import "../actions/action-confirm-button";
|
|
5
|
-
import "../shared/simple-tooltip";
|
|
6
5
|
import "./scheduler-popover";
|
|
7
6
|
import { tourSchedulerStyles } from "../Scheduler/tourSchedulerStyles";
|
|
8
7
|
import { InputStyles } from "../actions/InputStyles";
|
|
9
8
|
import floorplanImageCardStyles from "../FeeCalculator/components/floorplan-image-card/floorplan-image-card-styles";
|
|
10
9
|
import floorPlanSelectorStyles from "../FeeCalculator/components/floor-plan-selector/floor-plan-selector-styles";
|
|
11
10
|
import { BuildingIcon } from "../icons/BuildingIcon";
|
|
12
|
-
import { XOutlineIcon } from "../icons/XOutlineIcon";
|
|
13
11
|
import {
|
|
14
12
|
CommunitiesResponse,
|
|
15
13
|
Community,
|
|
@@ -43,11 +41,10 @@ type FilterId = "bedrooms" | "moveIn" | "budget";
|
|
|
43
41
|
const FILTER_IDS: FilterId[] = ["bedrooms", "moveIn", "budget"];
|
|
44
42
|
|
|
45
43
|
/**
|
|
46
|
-
* Lists a central group's top communities so the prospect can pick one
|
|
47
|
-
* the "extend" variant after a booking,
|
|
48
|
-
* and every reason come from the server. The cards and badges
|
|
49
|
-
* calculator's.
|
|
50
|
-
* with Continue, in its footer (`renderSelectionTray`).
|
|
44
|
+
* Lists a central group's top communities so the prospect can pick one: the
|
|
45
|
+
* community to tour, or, in the "extend" variant after a booking, the next stop
|
|
46
|
+
* to add. Ranking and every reason come from the server. The cards and badges
|
|
47
|
+
* are the fee calculator's.
|
|
51
48
|
*/
|
|
52
49
|
@customElement("community-picker")
|
|
53
50
|
export class CommunityPicker extends LitElement {
|
|
@@ -61,14 +58,10 @@ export class CommunityPicker extends LitElement {
|
|
|
61
58
|
@property({ attribute: false })
|
|
62
59
|
initial: CommunitiesResponse | null = null;
|
|
63
60
|
|
|
64
|
-
/** The
|
|
61
|
+
/** The pick so far, if any; a click asks for a change with `selection-change`. */
|
|
65
62
|
@property({ attribute: false })
|
|
66
63
|
selected: CommunitySummary[] = [];
|
|
67
64
|
|
|
68
|
-
/** How many communities may be picked: the stops left in the itinerary. */
|
|
69
|
-
@property({ type: Number })
|
|
70
|
-
maxSelectable = 0;
|
|
71
|
-
|
|
72
65
|
/**
|
|
73
66
|
* The prospect's filters, which the scheduler shares with its form for this
|
|
74
67
|
* visit; a change is reported with `filters-change`.
|
|
@@ -148,15 +141,7 @@ export class CommunityPicker extends LitElement {
|
|
|
148
141
|
private toggle(community: Community): void {
|
|
149
142
|
if (!community.tourable) return;
|
|
150
143
|
// One to pick: a click picks it, in place of any earlier pick.
|
|
151
|
-
|
|
152
|
-
this.emitSelection([toCommunitySummary(community)]);
|
|
153
|
-
} else if (this.isSelected(community.building_id)) {
|
|
154
|
-
this.emitSelection(
|
|
155
|
-
this.selected.filter((s) => s.building_id !== community.building_id)
|
|
156
|
-
);
|
|
157
|
-
} else if (this.selected.length < this.maxSelectable) {
|
|
158
|
-
this.emitSelection([...this.selected, toCommunitySummary(community)]);
|
|
159
|
-
}
|
|
144
|
+
this.emitSelection([toCommunitySummary(community)]);
|
|
160
145
|
}
|
|
161
146
|
|
|
162
147
|
private emitSelection(communities: CommunitySummary[]): void {
|
|
@@ -170,11 +155,8 @@ export class CommunityPicker extends LitElement {
|
|
|
170
155
|
}
|
|
171
156
|
|
|
172
157
|
private heading(): string {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
return this.maxSelectable > 1
|
|
177
|
-
? `Select Up to ${this.maxSelectable} Communities to Tour`
|
|
158
|
+
return this.variant === "extend"
|
|
159
|
+
? "Add Nearby Communities to Your Tour"
|
|
178
160
|
: "Select a Community to Tour";
|
|
179
161
|
}
|
|
180
162
|
|
|
@@ -316,10 +298,6 @@ export class CommunityPicker extends LitElement {
|
|
|
316
298
|
|
|
317
299
|
private renderCard(c: Community): TemplateResult {
|
|
318
300
|
const selected = this.isSelected(c.building_id);
|
|
319
|
-
const full =
|
|
320
|
-
this.maxSelectable > 1 &&
|
|
321
|
-
!selected &&
|
|
322
|
-
this.selected.length >= this.maxSelectable;
|
|
323
301
|
const next = c.next_available;
|
|
324
302
|
// Extension times are all on the day already booked.
|
|
325
303
|
const sameDay = !!next && this.variant === "extend";
|
|
@@ -328,61 +306,55 @@ export class CommunityPicker extends LitElement {
|
|
|
328
306
|
c.price_from.bedrooms === 0 ? "Studio" : `${c.price_from.bedrooms} BR`
|
|
329
307
|
} from ${formatCurrency(c.price_from.amount)}`
|
|
330
308
|
: "";
|
|
331
|
-
const card = html`<button
|
|
332
|
-
class=${classMap({
|
|
333
|
-
"floorplan-image-card": true,
|
|
334
|
-
selected,
|
|
335
|
-
disabled: !c.tourable || full,
|
|
336
|
-
})}
|
|
337
|
-
aria-pressed=${String(selected)}
|
|
338
|
-
aria-disabled=${String(!c.tourable || full)}
|
|
339
|
-
@click=${() => this.toggle(c)}
|
|
340
|
-
>
|
|
341
|
-
${c.image_url
|
|
342
|
-
? html`<span class="section-left"
|
|
343
|
-
><img src=${c.image_url} alt=""
|
|
344
|
-
/></span>`
|
|
345
|
-
: ""}
|
|
346
|
-
<span class="section-right">
|
|
347
|
-
${c.best_match || price || c.distance_mi !== null
|
|
348
|
-
? html`<span class="card-tags">
|
|
349
|
-
${c.best_match
|
|
350
|
-
? html`<span class="floor-plan-badge">Best match</span>`
|
|
351
|
-
: ""}
|
|
352
|
-
${price
|
|
353
|
-
? html`<span class="floor-plan-badge">${price}</span>`
|
|
354
|
-
: ""}
|
|
355
|
-
${c.distance_mi !== null
|
|
356
|
-
? html`<span class="distance"
|
|
357
|
-
>${c.distance_mi.toFixed(1)} mi</span
|
|
358
|
-
>`
|
|
359
|
-
: ""}
|
|
360
|
-
</span>`
|
|
361
|
-
: ""}
|
|
362
|
-
<span class="image-card-title">${c.name}</span>
|
|
363
|
-
<span class="image-card-subtitle">${formatAddress(c.address)}</span>
|
|
364
|
-
${!c.tourable
|
|
365
|
-
? html`<span class="image-card-subtitle"
|
|
366
|
-
>${c.unavailable_reason ?? ""}</span
|
|
367
|
-
>`
|
|
368
|
-
: next
|
|
369
|
-
? html`<span class="next-available"
|
|
370
|
-
>Next available:
|
|
371
|
-
${formatShortDate(next.date)}${this.variant === "extend"
|
|
372
|
-
? ` · ${formatHourMinute(next.time)}`
|
|
373
|
-
: ""}</span
|
|
374
|
-
>`
|
|
375
|
-
: ""}
|
|
376
|
-
${sameDay ? html`<span class="same-day">Same day</span>` : ""}
|
|
377
|
-
</span>
|
|
378
|
-
</button>`;
|
|
379
309
|
return html`<li>
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
310
|
+
<button
|
|
311
|
+
class=${classMap({
|
|
312
|
+
"floorplan-image-card": true,
|
|
313
|
+
selected,
|
|
314
|
+
disabled: !c.tourable,
|
|
315
|
+
})}
|
|
316
|
+
aria-pressed=${String(selected)}
|
|
317
|
+
aria-disabled=${String(!c.tourable)}
|
|
318
|
+
@click=${() => this.toggle(c)}
|
|
319
|
+
>
|
|
320
|
+
${c.image_url
|
|
321
|
+
? html`<span class="section-left"
|
|
322
|
+
><img src=${c.image_url} alt=""
|
|
323
|
+
/></span>`
|
|
324
|
+
: ""}
|
|
325
|
+
<span class="section-right">
|
|
326
|
+
${c.best_match || price || c.distance_mi !== null
|
|
327
|
+
? html`<span class="card-tags">
|
|
328
|
+
${c.best_match
|
|
329
|
+
? html`<span class="floor-plan-badge">Best match</span>`
|
|
330
|
+
: ""}
|
|
331
|
+
${price
|
|
332
|
+
? html`<span class="floor-plan-badge">${price}</span>`
|
|
333
|
+
: ""}
|
|
334
|
+
${c.distance_mi !== null
|
|
335
|
+
? html`<span class="distance"
|
|
336
|
+
>${c.distance_mi.toFixed(1)} mi</span
|
|
337
|
+
>`
|
|
338
|
+
: ""}
|
|
339
|
+
</span>`
|
|
340
|
+
: ""}
|
|
341
|
+
<span class="image-card-title">${c.name}</span>
|
|
342
|
+
<span class="image-card-subtitle">${formatAddress(c.address)}</span>
|
|
343
|
+
${!c.tourable
|
|
344
|
+
? html`<span class="image-card-subtitle"
|
|
345
|
+
>${c.unavailable_reason ?? ""}</span
|
|
346
|
+
>`
|
|
347
|
+
: next
|
|
348
|
+
? html`<span class="next-available"
|
|
349
|
+
>Next available:
|
|
350
|
+
${formatShortDate(next.date)}${this.variant === "extend"
|
|
351
|
+
? ` · ${formatHourMinute(next.time)}`
|
|
352
|
+
: ""}</span
|
|
353
|
+
>`
|
|
354
|
+
: ""}
|
|
355
|
+
${sameDay ? html`<span class="same-day">Same day</span>` : ""}
|
|
356
|
+
</span>
|
|
357
|
+
</button>
|
|
386
358
|
</li>`;
|
|
387
359
|
}
|
|
388
360
|
|
|
@@ -627,97 +599,6 @@ export class CommunityPicker extends LitElement {
|
|
|
627
599
|
];
|
|
628
600
|
}
|
|
629
601
|
|
|
630
|
-
/**
|
|
631
|
-
* The picks and Continue, in the scheduler's footer under either picker. The
|
|
632
|
-
* scheduler renders it so the footer stays its own, as on every other step.
|
|
633
|
-
*/
|
|
634
|
-
export const renderSelectionTray = ({
|
|
635
|
-
selected,
|
|
636
|
-
mobile,
|
|
637
|
-
onRemove,
|
|
638
|
-
onContinue,
|
|
639
|
-
}: {
|
|
640
|
-
selected: CommunitySummary[];
|
|
641
|
-
mobile: boolean;
|
|
642
|
-
onRemove: (buildingId: number) => void;
|
|
643
|
-
onContinue: () => void;
|
|
644
|
-
}): TemplateResult | string =>
|
|
645
|
-
selected.length === 0
|
|
646
|
-
? ""
|
|
647
|
-
: html`<div
|
|
648
|
-
id="tour-scheduler-footer"
|
|
649
|
-
class=${classMap({ tray: true, stacked: mobile })}
|
|
650
|
-
>
|
|
651
|
-
<ul
|
|
652
|
-
class="floor-plan-selector-badges"
|
|
653
|
-
aria-label="Selected communities"
|
|
654
|
-
>
|
|
655
|
-
${selected.map(
|
|
656
|
-
(s) => html`<li class="floor-plan-badge">
|
|
657
|
-
${s.name}
|
|
658
|
-
<button
|
|
659
|
-
class="remove"
|
|
660
|
-
aria-label=${`Remove ${s.name}`}
|
|
661
|
-
@click=${() => onRemove(s.building_id)}
|
|
662
|
-
>
|
|
663
|
-
${XOutlineIcon("#737373")}
|
|
664
|
-
</button>
|
|
665
|
-
</li>`
|
|
666
|
-
)}
|
|
667
|
-
</ul>
|
|
668
|
-
<action-confirm-button
|
|
669
|
-
id="continue-bttn"
|
|
670
|
-
text="Continue"
|
|
671
|
-
height="50px"
|
|
672
|
-
width=${mobile ? "100%" : "145px"}
|
|
673
|
-
.onClick=${onContinue}
|
|
674
|
-
></action-confirm-button>
|
|
675
|
-
</div>`;
|
|
676
|
-
|
|
677
|
-
/**
|
|
678
|
-
* Styles for `renderSelectionTray`: the fee calculator's badges (its padding and
|
|
679
|
-
* radius), without the rest of its stylesheet, which also styles `:host`.
|
|
680
|
-
*/
|
|
681
|
-
export const selectionTrayStyles = css`
|
|
682
|
-
.tray {
|
|
683
|
-
gap: 12px;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
.tray .floor-plan-selector-badges {
|
|
687
|
-
display: flex;
|
|
688
|
-
flex-wrap: wrap;
|
|
689
|
-
gap: 8px;
|
|
690
|
-
list-style: none;
|
|
691
|
-
margin: 0;
|
|
692
|
-
padding: 0;
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
.tray .floor-plan-badge {
|
|
696
|
-
align-items: center;
|
|
697
|
-
background: #f3f3f3;
|
|
698
|
-
border: 1px solid #e7e7e7;
|
|
699
|
-
border-radius: 16px;
|
|
700
|
-
display: inline-flex;
|
|
701
|
-
font-size: 13px;
|
|
702
|
-
gap: 6px;
|
|
703
|
-
padding: 6px 12px;
|
|
704
|
-
white-space: nowrap;
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
.remove {
|
|
708
|
-
background: none;
|
|
709
|
-
border: none;
|
|
710
|
-
cursor: pointer;
|
|
711
|
-
display: inline-flex;
|
|
712
|
-
padding: 0;
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
.remove svg {
|
|
716
|
-
height: 9px;
|
|
717
|
-
width: 9px;
|
|
718
|
-
}
|
|
719
|
-
`;
|
|
720
|
-
|
|
721
602
|
declare global {
|
|
722
603
|
interface HTMLElementTagNameMap {
|
|
723
604
|
"community-picker": CommunityPicker;
|
|
@@ -105,6 +105,14 @@ export class ItineraryEditor extends LitElement {
|
|
|
105
105
|
@property({ type: Boolean })
|
|
106
106
|
canEditCommunities = false;
|
|
107
107
|
|
|
108
|
+
/** Adding stops to a booking: only the stops, as the design's itinerary. */
|
|
109
|
+
@property({ type: Boolean })
|
|
110
|
+
stopsOnly = false;
|
|
111
|
+
|
|
112
|
+
/** With `stopsOnly`, the itinerary has room for another stop. */
|
|
113
|
+
@property({ type: Boolean })
|
|
114
|
+
canAddStop = false;
|
|
115
|
+
|
|
108
116
|
@property({ type: Boolean })
|
|
109
117
|
loading = false;
|
|
110
118
|
|
|
@@ -198,10 +206,11 @@ export class ItineraryEditor extends LitElement {
|
|
|
198
206
|
</div>
|
|
199
207
|
${this.canEditCommunities
|
|
200
208
|
? html`<button
|
|
201
|
-
class="
|
|
209
|
+
class="icon-button change-community"
|
|
210
|
+
aria-label="Change community"
|
|
202
211
|
@click=${() => emit(this, "edit-communities", {})}
|
|
203
212
|
>
|
|
204
|
-
|
|
213
|
+
${PencilIcon()}
|
|
205
214
|
</button>`
|
|
206
215
|
: ""}
|
|
207
216
|
</div> `;
|
|
@@ -421,7 +430,8 @@ export class ItineraryEditor extends LitElement {
|
|
|
421
430
|
</button>`}
|
|
422
431
|
${editing ? this.renderTimePicker(stop) : ""}
|
|
423
432
|
</div>
|
|
424
|
-
${!stop.fixed &&
|
|
433
|
+
${!stop.fixed &&
|
|
434
|
+
(ids.length > 1 || this.problems.length > 0 || this.stopsOnly)
|
|
425
435
|
? this.renderRemove(stop.building_id, community?.name ?? "")
|
|
426
436
|
: ""}
|
|
427
437
|
</div>
|
|
@@ -463,17 +473,32 @@ export class ItineraryEditor extends LitElement {
|
|
|
463
473
|
: ""}`;
|
|
464
474
|
}
|
|
465
475
|
|
|
476
|
+
private renderStops(): TemplateResult {
|
|
477
|
+
return html`<ol class="stops" aria-busy=${String(this.loading)}>
|
|
478
|
+
${this.stops.map((stop, i) => this.renderStop(stop, i))}
|
|
479
|
+
${this.problems.map((p) => this.renderProblem(p))}
|
|
480
|
+
</ol>`;
|
|
481
|
+
}
|
|
482
|
+
|
|
466
483
|
private renderItinerary(): TemplateResult {
|
|
467
484
|
return html`<h2 class="journey-header">
|
|
468
485
|
Your Itinerary ${this.loading ? html`<mini-loader></mini-loader>` : ""}
|
|
469
486
|
</h2>
|
|
470
|
-
|
|
471
|
-
${this.stops.map((stop, i) => this.renderStop(stop, i))}
|
|
472
|
-
${this.problems.map((p) => this.renderProblem(p))}
|
|
473
|
-
</ol>`;
|
|
487
|
+
${this.renderStops()}`;
|
|
474
488
|
}
|
|
475
489
|
|
|
476
490
|
render(): TemplateResult {
|
|
491
|
+
if (this.stopsOnly) {
|
|
492
|
+
return html`${this.renderStops()}
|
|
493
|
+
${this.canAddStop
|
|
494
|
+
? html`<button
|
|
495
|
+
class="floor-plan-badge add-stop"
|
|
496
|
+
@click=${() => emit(this, "add-stop", {})}
|
|
497
|
+
>
|
|
498
|
+
+ Add another stop
|
|
499
|
+
</button>`
|
|
500
|
+
: ""}`;
|
|
501
|
+
}
|
|
477
502
|
const itinerary = !this.selectedTypeOpensLink && !this.single;
|
|
478
503
|
return html`<div id="tour-type-menu-outer-container">
|
|
479
504
|
${this.renderCommunity()} ${this.renderTourTypes()}
|
|
@@ -524,6 +549,15 @@ export class ItineraryEditor extends LitElement {
|
|
|
524
549
|
margin-top: 20px;
|
|
525
550
|
}
|
|
526
551
|
|
|
552
|
+
/* The pencil sits centred on the community card's right. */
|
|
553
|
+
.icon-button.change-community {
|
|
554
|
+
align-self: center;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.add-stop {
|
|
558
|
+
width: 100%;
|
|
559
|
+
}
|
|
560
|
+
|
|
527
561
|
.community {
|
|
528
562
|
background: #ffffff;
|
|
529
563
|
border: 1px solid #e7e7e7;
|
|
@@ -8,6 +8,7 @@ import "./contact-form";
|
|
|
8
8
|
import "./booking-confirmation";
|
|
9
9
|
import "../actions/action-confirm-button";
|
|
10
10
|
import "../loaders/mega-loader";
|
|
11
|
+
import "../mini-loader";
|
|
11
12
|
import { tourSchedulerStyles } from "../Scheduler/tourSchedulerStyles";
|
|
12
13
|
import { InputStyles } from "../actions/InputStyles";
|
|
13
14
|
import { ChevronLeftIcon } from "../icons/ChevronLeftIcon";
|
|
@@ -28,7 +29,6 @@ import {
|
|
|
28
29
|
toCommunitySummary,
|
|
29
30
|
TourTypeId,
|
|
30
31
|
} from "./tourItineraryApi";
|
|
31
|
-
import { renderSelectionTray, selectionTrayStyles } from "./community-picker";
|
|
32
32
|
import type { TourTypeChoice, StopProblem } from "./itinerary-editor";
|
|
33
33
|
import { contactIsValid, ContactValues, EMPTY_CONTACT } from "./contact-form";
|
|
34
34
|
import type { ConfirmedStop } from "./booking-confirmation";
|
|
@@ -139,8 +139,10 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
139
139
|
@state() private group: CommunitiesResponse | null = null;
|
|
140
140
|
@state() private communities = new Map<number, CommunitySummary>();
|
|
141
141
|
@state() private selectedIds: number[] = [];
|
|
142
|
-
/** The
|
|
142
|
+
/** The picker's pick, marked when the prospect goes back to it. */
|
|
143
143
|
@state() private picks: CommunitySummary[] = [];
|
|
144
|
+
/** Adding stops: the nearby communities are open under the itinerary. */
|
|
145
|
+
@state() private addingStop = false;
|
|
144
146
|
@state() private existingEventIds: number[] = [];
|
|
145
147
|
@state() private tourType: TourTypeId = "escorted-tour";
|
|
146
148
|
/** A tour type this building books on its own page, once picked. */
|
|
@@ -373,6 +375,9 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
373
375
|
* type or date isn't offered, moves to the first one it offers and asks again.
|
|
374
376
|
*/
|
|
375
377
|
private async runPlan(keepNotice = false): Promise<void> {
|
|
378
|
+
// The nearby list was fetched after the old last stop, without the old
|
|
379
|
+
// stops; "Add another stop" offers it again once this plan is in.
|
|
380
|
+
this.addingStop = false;
|
|
376
381
|
if (this.selectedIds.length === 0) return;
|
|
377
382
|
const requestId = ++this.planRequestId;
|
|
378
383
|
this.planLoading = true;
|
|
@@ -786,6 +791,62 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
786
791
|
return MAX_ITINERARY_STOPS - this.bookedEventIds.length;
|
|
787
792
|
}
|
|
788
793
|
|
|
794
|
+
/**
|
|
795
|
+
* Another stop fits after the booked ones and those added so far, and the
|
|
796
|
+
* plan shown is for these stops, so the list can start after its last one.
|
|
797
|
+
*/
|
|
798
|
+
private get canAddStop(): boolean {
|
|
799
|
+
return (
|
|
800
|
+
!this.planLoading &&
|
|
801
|
+
!this.planError &&
|
|
802
|
+
this.stopsRemaining() > this.selectedIds.length &&
|
|
803
|
+
(this.plan?.stops.length ?? 0) > 0
|
|
804
|
+
);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
/**
|
|
808
|
+
* As `extendQueryFromBooking`, from the itinerary being added: times after
|
|
809
|
+
* its last planned stop, near it, without any community already in it.
|
|
810
|
+
*/
|
|
811
|
+
private extendQueryFromPlan(): ExtendQuery | null {
|
|
812
|
+
const stops = this.plan?.stops ?? [];
|
|
813
|
+
const last = stops[stops.length - 1];
|
|
814
|
+
if (!last || !this.extendFrom) return null;
|
|
815
|
+
return {
|
|
816
|
+
...this.extendFrom,
|
|
817
|
+
availableAfter: last.end,
|
|
818
|
+
nearBuildingId: last.building_id,
|
|
819
|
+
excludeBuildingIds: [
|
|
820
|
+
...this.extendFrom.excludeBuildingIds,
|
|
821
|
+
...this.selectedIds,
|
|
822
|
+
],
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
private loadAddStopCommunities = (
|
|
827
|
+
filters: CommunityFilters
|
|
828
|
+
): Promise<CommunitiesResponse> => {
|
|
829
|
+
const extend = this.extendQueryFromPlan();
|
|
830
|
+
if (!extend) return Promise.reject(new Error("No stop to add after"));
|
|
831
|
+
return this.client
|
|
832
|
+
.getCommunities({ ...filters, extend })
|
|
833
|
+
.then(this.rememberPage);
|
|
834
|
+
};
|
|
835
|
+
|
|
836
|
+
/** One more community joins the itinerary, after the stops already in it. */
|
|
837
|
+
private onStopAdded(picked: CommunitySummary[]): void {
|
|
838
|
+
const community = picked[0];
|
|
839
|
+
if (!community) return;
|
|
840
|
+
this.rememberOne(community);
|
|
841
|
+
pushGtmEvent("tourCommunitiesSelected", {
|
|
842
|
+
buildingId: this.buildingId,
|
|
843
|
+
count: 1,
|
|
844
|
+
mode: "extend",
|
|
845
|
+
});
|
|
846
|
+
this.selectedIds = [...this.selectedIds, community.building_id];
|
|
847
|
+
void this.runPlan();
|
|
848
|
+
}
|
|
849
|
+
|
|
789
850
|
/** Offers more communities while the itinerary has stops left. */
|
|
790
851
|
private async loadExtension(): Promise<void> {
|
|
791
852
|
const extend = this.extendQueryFromBooking();
|
|
@@ -989,7 +1050,6 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
989
1050
|
.load=${this.loadSelectCommunities}
|
|
990
1051
|
.initial=${this.group}
|
|
991
1052
|
.filters=${this.preferences}
|
|
992
|
-
.maxSelectable=${1}
|
|
993
1053
|
.selected=${this.picks}
|
|
994
1054
|
@filters-change=${this.onFiltersChange}
|
|
995
1055
|
@selection-change=${(
|
|
@@ -998,20 +1058,37 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
998
1058
|
></community-picker>`);
|
|
999
1059
|
}
|
|
1000
1060
|
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1061
|
+
/** Adding stops to a booking: the design's itinerary heading. */
|
|
1062
|
+
private renderItineraryHeading(): TemplateResult {
|
|
1063
|
+
return html`<div class="itinerary-heading">
|
|
1064
|
+
<h2>
|
|
1065
|
+
Create Your Tour Itinerary
|
|
1066
|
+
${this.planLoading ? html`<mini-loader></mini-loader>` : ""}
|
|
1067
|
+
</h2>
|
|
1068
|
+
<p class="explanation">Add up to ${MAX_ITINERARY_STOPS} communities</p>
|
|
1069
|
+
</div>`;
|
|
1070
|
+
}
|
|
1006
1071
|
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1072
|
+
/** "Add another stop": the nearby communities, under the itinerary. */
|
|
1073
|
+
private renderAddStop(): TemplateResult {
|
|
1074
|
+
return html`<div class="add-stop-picker">
|
|
1075
|
+
<button
|
|
1076
|
+
class="close-add-stop"
|
|
1077
|
+
aria-label="Close nearby communities"
|
|
1078
|
+
@click=${() => (this.addingStop = false)}
|
|
1079
|
+
>
|
|
1080
|
+
${XOutlineIcon("#737373")}
|
|
1081
|
+
</button>
|
|
1082
|
+
<community-picker
|
|
1083
|
+
variant="extend"
|
|
1084
|
+
.load=${this.loadAddStopCommunities}
|
|
1085
|
+
.filters=${this.preferences}
|
|
1086
|
+
@filters-change=${this.onFiltersChange}
|
|
1087
|
+
@selection-change=${(
|
|
1088
|
+
e: CustomEvent<{ communities: CommunitySummary[] }>
|
|
1089
|
+
) => this.onStopAdded(e.detail.communities)}
|
|
1090
|
+
></community-picker>
|
|
1091
|
+
</div>`;
|
|
1015
1092
|
}
|
|
1016
1093
|
|
|
1017
1094
|
private renderSchedule(): TemplateResult {
|
|
@@ -1026,10 +1103,14 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
1026
1103
|
</button>
|
|
1027
1104
|
</p>`
|
|
1028
1105
|
: ""}
|
|
1106
|
+
${this.extending ? this.renderItineraryHeading() : ""}
|
|
1029
1107
|
${this.notice
|
|
1030
1108
|
? html`<p class="explanation notice" role="status">${this.notice}</p>`
|
|
1031
1109
|
: ""}
|
|
1032
|
-
<div
|
|
1110
|
+
<div
|
|
1111
|
+
id="book-tour-journey-items"
|
|
1112
|
+
class=${classMap({ itinerary: this.extending })}
|
|
1113
|
+
>
|
|
1033
1114
|
<itinerary-editor
|
|
1034
1115
|
.stops=${plan?.stops ?? []}
|
|
1035
1116
|
.communities=${this.communities}
|
|
@@ -1039,6 +1120,8 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
1039
1120
|
.bookableDates=${plan?.bookable_dates ?? []}
|
|
1040
1121
|
.date=${this.date}
|
|
1041
1122
|
?single=${!this.isMultiStop()}
|
|
1123
|
+
?stopsOnly=${this.extending}
|
|
1124
|
+
?canAddStop=${this.extending && !this.addingStop && this.canAddStop}
|
|
1042
1125
|
?canEditCommunities=${this.group !== null && !this.extending}
|
|
1043
1126
|
?loading=${this.planLoading}
|
|
1044
1127
|
?planned=${plan !== null}
|
|
@@ -1057,6 +1140,7 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
1057
1140
|
@stop-remove=${(e: CustomEvent<{ buildingId: number }>) =>
|
|
1058
1141
|
this.onRemove(e.detail.buildingId)}
|
|
1059
1142
|
@edit-communities=${() => this.onEditCommunities()}
|
|
1143
|
+
@add-stop=${() => (this.addingStop = true)}
|
|
1060
1144
|
@open-tour-link=${() =>
|
|
1061
1145
|
this.activeLinkType && this.openTourLink(this.activeLinkType)}
|
|
1062
1146
|
></itinerary-editor>
|
|
@@ -1082,6 +1166,7 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
1082
1166
|
})}
|
|
1083
1167
|
></contact-form>`}
|
|
1084
1168
|
</div>
|
|
1169
|
+
${this.extending && this.addingStop ? this.renderAddStop() : ""}
|
|
1085
1170
|
`)}
|
|
1086
1171
|
<div
|
|
1087
1172
|
id="tour-scheduler-footer"
|
|
@@ -1102,8 +1187,12 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
1102
1187
|
.onClick=${() => this.submit()}
|
|
1103
1188
|
.isLoading=${this.submitting}
|
|
1104
1189
|
height="50px"
|
|
1105
|
-
width=${this.mobile ? "100%" : "145px"}
|
|
1106
|
-
text=${this.
|
|
1190
|
+
width=${this.mobile ? "100%" : this.extending ? "200px" : "145px"}
|
|
1191
|
+
text=${this.extending
|
|
1192
|
+
? "Confirm tour itinerary"
|
|
1193
|
+
: this.isMultiStop()
|
|
1194
|
+
? "Schedule tours"
|
|
1195
|
+
: "Schedule tour"}
|
|
1107
1196
|
?disabled=${!this.canSubmit()}
|
|
1108
1197
|
></action-confirm-button>
|
|
1109
1198
|
</div>`;
|
|
@@ -1165,14 +1254,13 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
1165
1254
|
.load=${this.loadExtendCommunities}
|
|
1166
1255
|
.initial=${this.extendInitial}
|
|
1167
1256
|
.filters=${this.preferences}
|
|
1168
|
-
.maxSelectable=${this.stopsRemaining()}
|
|
1169
|
-
.selected=${this.picks}
|
|
1170
1257
|
@filters-change=${this.onFiltersChange}
|
|
1171
|
-
@selection-change=${
|
|
1258
|
+
@selection-change=${(
|
|
1259
|
+
e: CustomEvent<{ communities: CommunitySummary[] }>
|
|
1260
|
+
) => this.onCommunitiesSelected(e.detail.communities, "extend")}
|
|
1172
1261
|
></community-picker>`
|
|
1173
1262
|
: ""}
|
|
1174
|
-
</booking-confirmation>`)}
|
|
1175
|
-
${this.extendInitial ? this.renderTray() : ""}`;
|
|
1263
|
+
</booking-confirmation>`)}`;
|
|
1176
1264
|
}
|
|
1177
1265
|
|
|
1178
1266
|
private renderBody(): TemplateResult {
|
|
@@ -1240,7 +1328,6 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
1240
1328
|
static styles = [
|
|
1241
1329
|
tourSchedulerStyles,
|
|
1242
1330
|
InputStyles,
|
|
1243
|
-
selectionTrayStyles,
|
|
1244
1331
|
css`
|
|
1245
1332
|
/* New layout only: the back button beside the title. */
|
|
1246
1333
|
.title {
|
|
@@ -1270,6 +1357,45 @@ export class TourSchedulerV2 extends LitElement {
|
|
|
1270
1357
|
margin: 0 0 16px;
|
|
1271
1358
|
}
|
|
1272
1359
|
|
|
1360
|
+
/* Adding stops: the design's one centred column of stops. */
|
|
1361
|
+
#book-tour-journey-items.itinerary {
|
|
1362
|
+
display: block;
|
|
1363
|
+
margin: 0 auto;
|
|
1364
|
+
max-width: 30rem;
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
.itinerary-heading {
|
|
1368
|
+
margin-bottom: 16px;
|
|
1369
|
+
text-align: center;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
/* The pickers' heading size. */
|
|
1373
|
+
.itinerary-heading h2 {
|
|
1374
|
+
align-items: center;
|
|
1375
|
+
display: flex;
|
|
1376
|
+
font-size: 20px;
|
|
1377
|
+
font-weight: 400;
|
|
1378
|
+
gap: 8px;
|
|
1379
|
+
justify-content: center;
|
|
1380
|
+
margin: 0;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
.add-stop-picker {
|
|
1384
|
+
margin-top: 24px;
|
|
1385
|
+
position: relative;
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
/* The extend picker's top rule and padding put its heading 24px down. */
|
|
1389
|
+
.close-add-stop {
|
|
1390
|
+
background: none;
|
|
1391
|
+
border: none;
|
|
1392
|
+
cursor: pointer;
|
|
1393
|
+
padding: 4px;
|
|
1394
|
+
position: absolute;
|
|
1395
|
+
right: 0;
|
|
1396
|
+
top: 24px;
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1273
1399
|
.link-button {
|
|
1274
1400
|
background: none;
|
|
1275
1401
|
border: none;
|