@meetelise/chat 1.65.0 → 1.66.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 +22 -17
- package/dist/src/WebComponent/SchedulerV2/itinerary-editor.d.ts +72 -0
- package/dist/src/WebComponent/SchedulerV2/itineraryStopStyles.d.ts +6 -0
- package/dist/src/WebComponent/SchedulerV2/tourItineraryApi.d.ts +9 -0
- package/dist/src/WebComponent/SchedulerV2/tourTimes.d.ts +5 -2
- package/dist/src/WebComponent/icons/GripIcon.d.ts +2 -0
- package/dist/src/WebComponent/icons/PencilIcon.d.ts +2 -0
- package/dist/src/WebComponent/icons/TrashIcon.d.ts +2 -0
- package/package.json +1 -1
- package/src/WebComponent/SchedulerV2/community-picker.ts +110 -126
- package/src/WebComponent/SchedulerV2/itinerary-editor.ts +617 -0
- package/src/WebComponent/SchedulerV2/itineraryStopStyles.ts +45 -0
- package/src/WebComponent/SchedulerV2/tourItineraryApi.ts +20 -0
- package/src/WebComponent/SchedulerV2/tourTimes.ts +26 -5
- package/src/WebComponent/icons/GripIcon.ts +18 -0
- package/src/WebComponent/icons/PencilIcon.ts +21 -0
- package/src/WebComponent/icons/TrashIcon.ts +19 -0
|
@@ -1,40 +1,31 @@
|
|
|
1
|
-
import { LitElement,
|
|
1
|
+
import { LitElement, TemplateResult } from "lit";
|
|
2
2
|
import "../actions/action-confirm-button";
|
|
3
3
|
import "../shared/simple-tooltip";
|
|
4
|
-
import { CommunitiesResponse,
|
|
5
|
-
/** What the scheduler keeps about a community the prospect picked. */
|
|
6
|
-
export interface CommunitySummary {
|
|
7
|
-
building_id: number;
|
|
8
|
-
name: string;
|
|
9
|
-
address: CommunityAddress | null;
|
|
10
|
-
timezone: string | null;
|
|
11
|
-
}
|
|
12
|
-
export declare const toCommunitySummary: (c: Community) => CommunitySummary;
|
|
13
|
-
export declare const formatAddress: (address: CommunityAddress | null) => string;
|
|
4
|
+
import { CommunitiesResponse, CommunityFilters, CommunitySummary } from "./tourItineraryApi";
|
|
14
5
|
export declare type CommunityLoader = (filters: CommunityFilters) => Promise<CommunitiesResponse>;
|
|
15
6
|
/**
|
|
16
7
|
* Lists a central group's top communities so the prospect can pick up to the
|
|
17
8
|
* number of stops left. In the "extend" variant it offers more communities
|
|
18
9
|
* after a booking. Ranking and every reason come from the server. The cards and
|
|
19
|
-
* badges are the fee calculator's.
|
|
10
|
+
* badges are the fee calculator's. The scheduler holds the picks and shows them,
|
|
11
|
+
* with Continue, in its footer (`renderSelectionTray`).
|
|
20
12
|
*/
|
|
21
13
|
export declare class CommunityPicker extends LitElement {
|
|
22
14
|
variant: "select" | "extend";
|
|
23
15
|
load: CommunityLoader | null;
|
|
24
16
|
/** The first, unfiltered page, when the scheduler already has it. */
|
|
25
17
|
initial: CommunitiesResponse | null;
|
|
26
|
-
|
|
18
|
+
/** The picks so far; a click asks for a change with `selection-change`. */
|
|
19
|
+
selected: CommunitySummary[];
|
|
27
20
|
/** How many communities may be picked: the stops left in the itinerary. */
|
|
28
21
|
maxSelectable: number;
|
|
29
|
-
mobile: boolean;
|
|
30
22
|
private filters;
|
|
31
23
|
private openFilter;
|
|
32
24
|
private communities;
|
|
33
25
|
private loading;
|
|
34
26
|
private error;
|
|
35
|
-
private selected;
|
|
36
27
|
private requestId;
|
|
37
|
-
willUpdate(
|
|
28
|
+
willUpdate(): void;
|
|
38
29
|
firstUpdated(): void;
|
|
39
30
|
private reload;
|
|
40
31
|
private setFilters;
|
|
@@ -48,10 +39,24 @@ export declare class CommunityPicker extends LitElement {
|
|
|
48
39
|
private renderFilters;
|
|
49
40
|
private renderCard;
|
|
50
41
|
private renderList;
|
|
51
|
-
private renderTray;
|
|
52
42
|
render(): TemplateResult;
|
|
53
43
|
static styles: import("lit").CSSResult[];
|
|
54
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* The picks and Continue, in the scheduler's footer under either picker. The
|
|
47
|
+
* scheduler renders it so the footer stays its own, as on every other step.
|
|
48
|
+
*/
|
|
49
|
+
export declare const renderSelectionTray: ({ selected, mobile, onRemove, onContinue, }: {
|
|
50
|
+
selected: CommunitySummary[];
|
|
51
|
+
mobile: boolean;
|
|
52
|
+
onRemove: (buildingId: number) => void;
|
|
53
|
+
onContinue: () => void;
|
|
54
|
+
}) => TemplateResult | string;
|
|
55
|
+
/**
|
|
56
|
+
* Styles for `renderSelectionTray`: the fee calculator's badges (its padding and
|
|
57
|
+
* radius), without the rest of its stylesheet, which also styles `:host`.
|
|
58
|
+
*/
|
|
59
|
+
export declare const selectionTrayStyles: import("lit").CSSResult;
|
|
55
60
|
declare global {
|
|
56
61
|
interface HTMLElementTagNameMap {
|
|
57
62
|
"community-picker": CommunityPicker;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { LitElement, PropertyValues, TemplateResult } from "lit";
|
|
2
|
+
import "../Scheduler/date-picker";
|
|
3
|
+
import "../Scheduler/time-picker";
|
|
4
|
+
import "../Scheduler/tour-type-option";
|
|
5
|
+
import "../mini-loader";
|
|
6
|
+
import { CommunitySummary, PlanStop, TourTypeId } from "./tourItineraryApi";
|
|
7
|
+
export interface TourTypeChoice {
|
|
8
|
+
id: TourTypeId;
|
|
9
|
+
/** The building sends this tour type to its own booking link. */
|
|
10
|
+
opensLink: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** A stop the server could not chain, with its reason. */
|
|
13
|
+
export interface StopProblem {
|
|
14
|
+
building_id: number;
|
|
15
|
+
text: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The schedule step's first two columns: tour type, then the date and either
|
|
19
|
+
* the time (one community) or the stops in order with their times. It shows
|
|
20
|
+
* what /plan returned and reports the prospect's changes, which the scheduler
|
|
21
|
+
* sends back to /plan. It renders today's scheduler's columns and pickers.
|
|
22
|
+
*/
|
|
23
|
+
export declare class ItineraryEditor extends LitElement {
|
|
24
|
+
stops: PlanStop[];
|
|
25
|
+
communities: Map<number, CommunitySummary>;
|
|
26
|
+
problems: StopProblem[];
|
|
27
|
+
tourTypes: TourTypeChoice[];
|
|
28
|
+
tourType: TourTypeId | null;
|
|
29
|
+
bookableDates: string[];
|
|
30
|
+
date: string | null;
|
|
31
|
+
/** One community: today's time grid. */
|
|
32
|
+
single: boolean;
|
|
33
|
+
/** The prospect may change which communities they tour. */
|
|
34
|
+
canEditCommunities: boolean;
|
|
35
|
+
/** The server allows another stop. */
|
|
36
|
+
canAddStop: boolean;
|
|
37
|
+
loading: boolean;
|
|
38
|
+
primaryColor: string;
|
|
39
|
+
foregroundColorOnPrimaryBackgroundColor: string;
|
|
40
|
+
private editingTimeFor;
|
|
41
|
+
private dragIndex;
|
|
42
|
+
private dropIndex;
|
|
43
|
+
private get selectedTypeOpensLink();
|
|
44
|
+
private newStopIds;
|
|
45
|
+
private name;
|
|
46
|
+
private move;
|
|
47
|
+
/** The new stop under a pointer's height, for dragging by the grip. */
|
|
48
|
+
private newIndexAt;
|
|
49
|
+
/** The stop moved with the arrow keys, whose grip keeps focus in the new order. */
|
|
50
|
+
private refocusGripOf;
|
|
51
|
+
updated(changed: PropertyValues<this>): void;
|
|
52
|
+
private endDrag;
|
|
53
|
+
private renderCommunity;
|
|
54
|
+
private renderTourTypes;
|
|
55
|
+
private renderDatePicker;
|
|
56
|
+
private renderTimePicker;
|
|
57
|
+
private renderLinkPrompt;
|
|
58
|
+
private renderSingleDateAndTime;
|
|
59
|
+
private renderStop;
|
|
60
|
+
private renderRemove;
|
|
61
|
+
private renderProblem;
|
|
62
|
+
/** Several communities: the date sits under the tour type, as in the design. */
|
|
63
|
+
private renderItineraryDate;
|
|
64
|
+
private renderItinerary;
|
|
65
|
+
render(): TemplateResult;
|
|
66
|
+
static styles: import("lit").CSSResult[];
|
|
67
|
+
}
|
|
68
|
+
declare global {
|
|
69
|
+
interface HTMLElementTagNameMap {
|
|
70
|
+
"itinerary-editor": ItineraryEditor;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The list of stops in an itinerary, shared by the schedule step and the
|
|
3
|
+
* confirmation. Each stop is a fee calculator card (`.floorplan-image-card`);
|
|
4
|
+
* this adds only the numbering and the distance between stops.
|
|
5
|
+
*/
|
|
6
|
+
export declare const itineraryStopStyles: import("lit").CSSResult;
|
|
@@ -31,6 +31,15 @@ export interface Community {
|
|
|
31
31
|
/** The text to show when the community can't be toured. */
|
|
32
32
|
unavailable_reason: string | null;
|
|
33
33
|
}
|
|
34
|
+
/** What the scheduler keeps about a community the prospect picked. */
|
|
35
|
+
export interface CommunitySummary {
|
|
36
|
+
building_id: number;
|
|
37
|
+
name: string;
|
|
38
|
+
address: CommunityAddress | null;
|
|
39
|
+
timezone: string | null;
|
|
40
|
+
}
|
|
41
|
+
export declare const toCommunitySummary: (c: Community) => CommunitySummary;
|
|
42
|
+
export declare const formatAddress: (address: CommunityAddress | null) => string;
|
|
34
43
|
/**
|
|
35
44
|
* Most stops in one itinerary, counting ones already booked. The server's cap,
|
|
36
45
|
* mirrored here for the picker; booking enforces the real one.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SVGTemplateResult } from "lit";
|
|
1
2
|
import type { TourTypeId } from "./tourItineraryApi";
|
|
2
3
|
/** "2026-10-15T10:45:00-05:00" -> "2026-10-15" */
|
|
3
4
|
export declare const isoDate: (iso: string) => string;
|
|
@@ -19,8 +20,10 @@ export declare const formatMonthDay: (date: string) => string;
|
|
|
19
20
|
export declare const formatLongDate: (date: string) => string;
|
|
20
21
|
/** A Date as the "YYYY-MM-DD" the API uses. */
|
|
21
22
|
export declare const toIsoDate: (date: Date) => string;
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
/** The Central Agent design's names for each tour type, with today's icons. */
|
|
24
|
+
export declare const TOUR_TYPES: Record<TourTypeId, {
|
|
25
|
+
heading: string;
|
|
24
26
|
subtitle: string;
|
|
27
|
+
icon: (color: string) => SVGTemplateResult;
|
|
25
28
|
}>;
|
|
26
29
|
export declare const TOUR_TYPE_ORDER: TourTypeId[];
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { css, html, LitElement,
|
|
1
|
+
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";
|
|
@@ -12,32 +12,14 @@ import { XOutlineIcon } from "../icons/XOutlineIcon";
|
|
|
12
12
|
import {
|
|
13
13
|
CommunitiesResponse,
|
|
14
14
|
Community,
|
|
15
|
-
CommunityAddress,
|
|
16
15
|
CommunityFilters,
|
|
16
|
+
CommunitySummary,
|
|
17
|
+
formatAddress,
|
|
18
|
+
toCommunitySummary,
|
|
17
19
|
} from "./tourItineraryApi";
|
|
18
20
|
import { formatHourMinute, formatShortDate } from "./tourTimes";
|
|
19
21
|
import { formatCurrency } from "../../utils";
|
|
20
22
|
|
|
21
|
-
/** What the scheduler keeps about a community the prospect picked. */
|
|
22
|
-
export interface CommunitySummary {
|
|
23
|
-
building_id: number;
|
|
24
|
-
name: string;
|
|
25
|
-
address: CommunityAddress | null;
|
|
26
|
-
timezone: string | null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const toCommunitySummary = (c: Community): CommunitySummary => ({
|
|
30
|
-
building_id: c.building_id,
|
|
31
|
-
name: c.name,
|
|
32
|
-
address: c.address,
|
|
33
|
-
timezone: c.timezone,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
export const formatAddress = (address: CommunityAddress | null): string =>
|
|
37
|
-
address
|
|
38
|
-
? [address.line1, address.city, address.state].filter(Boolean).join(", ")
|
|
39
|
-
: "";
|
|
40
|
-
|
|
41
23
|
export type CommunityLoader = (
|
|
42
24
|
filters: CommunityFilters
|
|
43
25
|
) => Promise<CommunitiesResponse>;
|
|
@@ -63,7 +45,8 @@ const FILTER_IDS: FilterId[] = ["bedrooms", "moveIn", "budget"];
|
|
|
63
45
|
* Lists a central group's top communities so the prospect can pick up to the
|
|
64
46
|
* number of stops left. In the "extend" variant it offers more communities
|
|
65
47
|
* after a booking. Ranking and every reason come from the server. The cards and
|
|
66
|
-
* badges are the fee calculator's.
|
|
48
|
+
* badges are the fee calculator's. The scheduler holds the picks and shows them,
|
|
49
|
+
* with Continue, in its footer (`renderSelectionTray`).
|
|
67
50
|
*/
|
|
68
51
|
@customElement("community-picker")
|
|
69
52
|
export class CommunityPicker extends LitElement {
|
|
@@ -77,30 +60,23 @@ export class CommunityPicker extends LitElement {
|
|
|
77
60
|
@property({ attribute: false })
|
|
78
61
|
initial: CommunitiesResponse | null = null;
|
|
79
62
|
|
|
63
|
+
/** The picks so far; a click asks for a change with `selection-change`. */
|
|
80
64
|
@property({ attribute: false })
|
|
81
|
-
|
|
65
|
+
selected: CommunitySummary[] = [];
|
|
82
66
|
|
|
83
67
|
/** How many communities may be picked: the stops left in the itinerary. */
|
|
84
68
|
@property({ type: Number })
|
|
85
69
|
maxSelectable = 0;
|
|
86
70
|
|
|
87
|
-
@property({ type: Boolean })
|
|
88
|
-
mobile = false;
|
|
89
|
-
|
|
90
71
|
@state() private filters: CommunityFilters = EMPTY_FILTERS;
|
|
91
72
|
@state() private openFilter: FilterId | null = null;
|
|
92
73
|
@state() private communities: Community[] = [];
|
|
93
74
|
@state() private loading = false;
|
|
94
75
|
@state() private error: string | null = null;
|
|
95
|
-
@state() private selected: CommunitySummary[] = [];
|
|
96
76
|
|
|
97
77
|
private requestId = 0;
|
|
98
78
|
|
|
99
|
-
willUpdate(
|
|
100
|
-
// Only the starting picks: later renders of the scheduler mustn't undo the prospect's.
|
|
101
|
-
if (changed.has("preselected") && !this.hasUpdated) {
|
|
102
|
-
this.selected = [...this.preselected];
|
|
103
|
-
}
|
|
79
|
+
willUpdate(): void {
|
|
104
80
|
// Show the page the scheduler already has from the first paint.
|
|
105
81
|
if (!this.hasUpdated && this.initial) {
|
|
106
82
|
this.communities = this.initial.communities;
|
|
@@ -140,17 +116,17 @@ export class CommunityPicker extends LitElement {
|
|
|
140
116
|
private toggle(community: Community): void {
|
|
141
117
|
if (!community.tourable) return;
|
|
142
118
|
if (this.isSelected(community.building_id)) {
|
|
143
|
-
this.
|
|
144
|
-
(s) => s.building_id !== community.building_id
|
|
119
|
+
this.emitSelection(
|
|
120
|
+
this.selected.filter((s) => s.building_id !== community.building_id)
|
|
145
121
|
);
|
|
146
122
|
} else if (this.selected.length < this.maxSelectable) {
|
|
147
|
-
this.
|
|
123
|
+
this.emitSelection([...this.selected, toCommunitySummary(community)]);
|
|
148
124
|
}
|
|
149
125
|
}
|
|
150
126
|
|
|
151
127
|
private emitSelection(communities: CommunitySummary[]): void {
|
|
152
128
|
this.dispatchEvent(
|
|
153
|
-
new CustomEvent("
|
|
129
|
+
new CustomEvent("selection-change", {
|
|
154
130
|
detail: { communities },
|
|
155
131
|
bubbles: true,
|
|
156
132
|
composed: true,
|
|
@@ -380,45 +356,9 @@ export class CommunityPicker extends LitElement {
|
|
|
380
356
|
</ul>`;
|
|
381
357
|
}
|
|
382
358
|
|
|
383
|
-
private renderTray(): TemplateResult | string {
|
|
384
|
-
if (this.selected.length === 0) return "";
|
|
385
|
-
return html`<div
|
|
386
|
-
id="tour-scheduler-footer"
|
|
387
|
-
class=${classMap({
|
|
388
|
-
tray: true,
|
|
389
|
-
stacked: this.mobile,
|
|
390
|
-
pinned: this.variant === "extend",
|
|
391
|
-
})}
|
|
392
|
-
>
|
|
393
|
-
<ul class="floor-plan-selector-badges" aria-label="Selected communities">
|
|
394
|
-
${this.selected.map(
|
|
395
|
-
(s) => html`<li class="floor-plan-badge">
|
|
396
|
-
${s.name}
|
|
397
|
-
<button
|
|
398
|
-
class="remove"
|
|
399
|
-
aria-label=${`Remove ${s.name}`}
|
|
400
|
-
@click=${() =>
|
|
401
|
-
(this.selected = this.selected.filter(
|
|
402
|
-
(x) => x.building_id !== s.building_id
|
|
403
|
-
))}
|
|
404
|
-
>
|
|
405
|
-
${XOutlineIcon("#737373")}
|
|
406
|
-
</button>
|
|
407
|
-
</li>`
|
|
408
|
-
)}
|
|
409
|
-
</ul>
|
|
410
|
-
<action-confirm-button
|
|
411
|
-
id="continue-bttn"
|
|
412
|
-
text="Continue"
|
|
413
|
-
height="50px"
|
|
414
|
-
width=${this.mobile ? "100%" : "145px"}
|
|
415
|
-
.onClick=${() => this.emitSelection(this.selected)}
|
|
416
|
-
></action-confirm-button>
|
|
417
|
-
</div>`;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
359
|
render(): TemplateResult {
|
|
421
|
-
|
|
360
|
+
return html`<div class=${classMap({ extend: this.variant === "extend" })}>
|
|
361
|
+
<div class="picker-heading">
|
|
422
362
|
${BuildingIcon()}
|
|
423
363
|
<h2>${this.heading()}</h2>
|
|
424
364
|
</div>
|
|
@@ -428,16 +368,8 @@ export class CommunityPicker extends LitElement {
|
|
|
428
368
|
? "Loading communities"
|
|
429
369
|
: `${this.communities.length} communities`}
|
|
430
370
|
</span>
|
|
431
|
-
${this.renderList()}
|
|
432
|
-
|
|
433
|
-
? html`<div class="extend">${body}</div>
|
|
434
|
-
${this.renderTray()}`
|
|
435
|
-
: html`<div
|
|
436
|
-
id=${this.mobile ? "mobile-body-container" : "scheduler-container"}
|
|
437
|
-
>
|
|
438
|
-
${body}
|
|
439
|
-
</div>
|
|
440
|
-
${this.renderTray()}`;
|
|
371
|
+
${this.renderList()}
|
|
372
|
+
</div>`;
|
|
441
373
|
}
|
|
442
374
|
|
|
443
375
|
static styles = [
|
|
@@ -446,9 +378,9 @@ export class CommunityPicker extends LitElement {
|
|
|
446
378
|
floorPlanSelectorStyles,
|
|
447
379
|
floorplanImageCardStyles,
|
|
448
380
|
css`
|
|
449
|
-
/* New layout only: the filter chips
|
|
381
|
+
/* New layout only: the filter chips and the card grid. */
|
|
450
382
|
:host {
|
|
451
|
-
display:
|
|
383
|
+
display: block;
|
|
452
384
|
}
|
|
453
385
|
|
|
454
386
|
.picker-heading {
|
|
@@ -619,45 +551,6 @@ export class CommunityPicker extends LitElement {
|
|
|
619
551
|
font-weight: 500;
|
|
620
552
|
}
|
|
621
553
|
|
|
622
|
-
.tray {
|
|
623
|
-
gap: 12px;
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
/* Under a confirmation the picker scrolls with it, so its tray stays in view. */
|
|
627
|
-
.tray.pinned {
|
|
628
|
-
background: #ffffff;
|
|
629
|
-
/* Past the scrolling body's 24px padding, onto its bottom edge. */
|
|
630
|
-
bottom: -24px;
|
|
631
|
-
position: sticky;
|
|
632
|
-
z-index: 1;
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
.tray .floor-plan-selector-badges {
|
|
636
|
-
margin: 0;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
.tray .floor-plan-badge {
|
|
640
|
-
background: #f3f3f3;
|
|
641
|
-
border-color: #e7e7e7;
|
|
642
|
-
cursor: default;
|
|
643
|
-
font-size: 13px;
|
|
644
|
-
gap: 6px;
|
|
645
|
-
white-space: nowrap;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
.remove {
|
|
649
|
-
background: none;
|
|
650
|
-
border: none;
|
|
651
|
-
cursor: pointer;
|
|
652
|
-
display: inline-flex;
|
|
653
|
-
padding: 0;
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
.remove svg {
|
|
657
|
-
height: 9px;
|
|
658
|
-
width: 9px;
|
|
659
|
-
}
|
|
660
|
-
|
|
661
554
|
.extend {
|
|
662
555
|
border-top: 1px solid #e7e7e7;
|
|
663
556
|
padding-top: 24px;
|
|
@@ -666,6 +559,97 @@ export class CommunityPicker extends LitElement {
|
|
|
666
559
|
];
|
|
667
560
|
}
|
|
668
561
|
|
|
562
|
+
/**
|
|
563
|
+
* The picks and Continue, in the scheduler's footer under either picker. The
|
|
564
|
+
* scheduler renders it so the footer stays its own, as on every other step.
|
|
565
|
+
*/
|
|
566
|
+
export const renderSelectionTray = ({
|
|
567
|
+
selected,
|
|
568
|
+
mobile,
|
|
569
|
+
onRemove,
|
|
570
|
+
onContinue,
|
|
571
|
+
}: {
|
|
572
|
+
selected: CommunitySummary[];
|
|
573
|
+
mobile: boolean;
|
|
574
|
+
onRemove: (buildingId: number) => void;
|
|
575
|
+
onContinue: () => void;
|
|
576
|
+
}): TemplateResult | string =>
|
|
577
|
+
selected.length === 0
|
|
578
|
+
? ""
|
|
579
|
+
: html`<div
|
|
580
|
+
id="tour-scheduler-footer"
|
|
581
|
+
class=${classMap({ tray: true, stacked: mobile })}
|
|
582
|
+
>
|
|
583
|
+
<ul
|
|
584
|
+
class="floor-plan-selector-badges"
|
|
585
|
+
aria-label="Selected communities"
|
|
586
|
+
>
|
|
587
|
+
${selected.map(
|
|
588
|
+
(s) => html`<li class="floor-plan-badge">
|
|
589
|
+
${s.name}
|
|
590
|
+
<button
|
|
591
|
+
class="remove"
|
|
592
|
+
aria-label=${`Remove ${s.name}`}
|
|
593
|
+
@click=${() => onRemove(s.building_id)}
|
|
594
|
+
>
|
|
595
|
+
${XOutlineIcon("#737373")}
|
|
596
|
+
</button>
|
|
597
|
+
</li>`
|
|
598
|
+
)}
|
|
599
|
+
</ul>
|
|
600
|
+
<action-confirm-button
|
|
601
|
+
id="continue-bttn"
|
|
602
|
+
text="Continue"
|
|
603
|
+
height="50px"
|
|
604
|
+
width=${mobile ? "100%" : "145px"}
|
|
605
|
+
.onClick=${onContinue}
|
|
606
|
+
></action-confirm-button>
|
|
607
|
+
</div>`;
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Styles for `renderSelectionTray`: the fee calculator's badges (its padding and
|
|
611
|
+
* radius), without the rest of its stylesheet, which also styles `:host`.
|
|
612
|
+
*/
|
|
613
|
+
export const selectionTrayStyles = css`
|
|
614
|
+
.tray {
|
|
615
|
+
gap: 12px;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
.tray .floor-plan-selector-badges {
|
|
619
|
+
display: flex;
|
|
620
|
+
flex-wrap: wrap;
|
|
621
|
+
gap: 8px;
|
|
622
|
+
list-style: none;
|
|
623
|
+
margin: 0;
|
|
624
|
+
padding: 0;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
.tray .floor-plan-badge {
|
|
628
|
+
align-items: center;
|
|
629
|
+
background: #f3f3f3;
|
|
630
|
+
border: 1px solid #e7e7e7;
|
|
631
|
+
border-radius: 16px;
|
|
632
|
+
display: inline-flex;
|
|
633
|
+
font-size: 13px;
|
|
634
|
+
gap: 6px;
|
|
635
|
+
padding: 6px 12px;
|
|
636
|
+
white-space: nowrap;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
.remove {
|
|
640
|
+
background: none;
|
|
641
|
+
border: none;
|
|
642
|
+
cursor: pointer;
|
|
643
|
+
display: inline-flex;
|
|
644
|
+
padding: 0;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
.remove svg {
|
|
648
|
+
height: 9px;
|
|
649
|
+
width: 9px;
|
|
650
|
+
}
|
|
651
|
+
`;
|
|
652
|
+
|
|
669
653
|
declare global {
|
|
670
654
|
interface HTMLElementTagNameMap {
|
|
671
655
|
"community-picker": CommunityPicker;
|
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
import {
|
|
2
|
+
css,
|
|
3
|
+
html,
|
|
4
|
+
LitElement,
|
|
5
|
+
nothing,
|
|
6
|
+
PropertyValues,
|
|
7
|
+
TemplateResult,
|
|
8
|
+
} from "lit";
|
|
9
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
10
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
11
|
+
import "../Scheduler/date-picker";
|
|
12
|
+
import "../Scheduler/time-picker";
|
|
13
|
+
import "../Scheduler/tour-type-option";
|
|
14
|
+
import "../mini-loader";
|
|
15
|
+
import type { DatePicker } from "../Scheduler/date-picker";
|
|
16
|
+
import type { TimePicker, TimePickerOption } from "../Scheduler/time-picker";
|
|
17
|
+
import { unselectedTourTypeForegroundColor } from "../Scheduler/tour-type-option";
|
|
18
|
+
import { tourSchedulerStyles } from "../Scheduler/tourSchedulerStyles";
|
|
19
|
+
import { InputStyles } from "../actions/InputStyles";
|
|
20
|
+
import { itineraryStopStyles } from "./itineraryStopStyles";
|
|
21
|
+
import floorplanImageCardStyles from "../FeeCalculator/components/floorplan-image-card/floorplan-image-card-styles";
|
|
22
|
+
import floorPlanSelectorStyles from "../FeeCalculator/components/floor-plan-selector/floor-plan-selector-styles";
|
|
23
|
+
import { GripIcon } from "../icons/GripIcon";
|
|
24
|
+
import { PencilIcon } from "../icons/PencilIcon";
|
|
25
|
+
import { TrashIcon } from "../icons/TrashIcon";
|
|
26
|
+
import { defaultPrimaryColor } from "../../themes";
|
|
27
|
+
import {
|
|
28
|
+
CommunitySummary,
|
|
29
|
+
formatAddress,
|
|
30
|
+
PlanStop,
|
|
31
|
+
TourTypeId,
|
|
32
|
+
} from "./tourItineraryApi";
|
|
33
|
+
import {
|
|
34
|
+
dateFromIsoDate,
|
|
35
|
+
formatMonthDay,
|
|
36
|
+
formatTime,
|
|
37
|
+
formatTimeRange,
|
|
38
|
+
isoDate,
|
|
39
|
+
toIsoDate,
|
|
40
|
+
TOUR_TYPES,
|
|
41
|
+
} from "./tourTimes";
|
|
42
|
+
|
|
43
|
+
export interface TourTypeChoice {
|
|
44
|
+
id: TourTypeId;
|
|
45
|
+
/** The building sends this tour type to its own booking link. */
|
|
46
|
+
opensLink: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** A stop the server could not chain, with its reason. */
|
|
50
|
+
export interface StopProblem {
|
|
51
|
+
building_id: number;
|
|
52
|
+
text: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** An API start time as today's time picker shows it. */
|
|
56
|
+
const timeOption = (iso: string): TimePickerOption => ({
|
|
57
|
+
displayTime: formatTime(iso),
|
|
58
|
+
displayTimeZoned: formatTime(iso),
|
|
59
|
+
dateWithTimeZoneOffset: {
|
|
60
|
+
datetime: iso.slice(0, 19),
|
|
61
|
+
offset: iso.slice(19),
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const emit = (el: HTMLElement, name: string, detail: unknown): void => {
|
|
66
|
+
el.dispatchEvent(
|
|
67
|
+
new CustomEvent(name, { detail, bubbles: true, composed: true })
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The schedule step's first two columns: tour type, then the date and either
|
|
73
|
+
* the time (one community) or the stops in order with their times. It shows
|
|
74
|
+
* what /plan returned and reports the prospect's changes, which the scheduler
|
|
75
|
+
* sends back to /plan. It renders today's scheduler's columns and pickers.
|
|
76
|
+
*/
|
|
77
|
+
@customElement("itinerary-editor")
|
|
78
|
+
export class ItineraryEditor extends LitElement {
|
|
79
|
+
@property({ attribute: false })
|
|
80
|
+
stops: PlanStop[] = [];
|
|
81
|
+
|
|
82
|
+
@property({ attribute: false })
|
|
83
|
+
communities: Map<number, CommunitySummary> = new Map();
|
|
84
|
+
|
|
85
|
+
@property({ attribute: false })
|
|
86
|
+
problems: StopProblem[] = [];
|
|
87
|
+
|
|
88
|
+
@property({ attribute: false })
|
|
89
|
+
tourTypes: TourTypeChoice[] = [];
|
|
90
|
+
|
|
91
|
+
@property({ attribute: false })
|
|
92
|
+
tourType: TourTypeId | null = null;
|
|
93
|
+
|
|
94
|
+
@property({ attribute: false })
|
|
95
|
+
bookableDates: string[] = [];
|
|
96
|
+
|
|
97
|
+
@property({ attribute: false })
|
|
98
|
+
date: string | null = null;
|
|
99
|
+
|
|
100
|
+
/** One community: today's time grid. */
|
|
101
|
+
@property({ type: Boolean })
|
|
102
|
+
single = false;
|
|
103
|
+
|
|
104
|
+
/** The prospect may change which communities they tour. */
|
|
105
|
+
@property({ type: Boolean })
|
|
106
|
+
canEditCommunities = false;
|
|
107
|
+
|
|
108
|
+
/** The server allows another stop. */
|
|
109
|
+
@property({ type: Boolean })
|
|
110
|
+
canAddStop = false;
|
|
111
|
+
|
|
112
|
+
@property({ type: Boolean })
|
|
113
|
+
loading = false;
|
|
114
|
+
|
|
115
|
+
@property({ attribute: false })
|
|
116
|
+
primaryColor = defaultPrimaryColor;
|
|
117
|
+
|
|
118
|
+
@property({ attribute: false })
|
|
119
|
+
foregroundColorOnPrimaryBackgroundColor = "white";
|
|
120
|
+
|
|
121
|
+
@state() private editingTimeFor: number | null = null;
|
|
122
|
+
@state() private dragIndex: number | null = null;
|
|
123
|
+
@state() private dropIndex: number | null = null;
|
|
124
|
+
|
|
125
|
+
private get selectedTypeOpensLink(): boolean {
|
|
126
|
+
return !!this.tourTypes.find((t) => t.id === this.tourType)?.opensLink;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private newStopIds(): number[] {
|
|
130
|
+
return this.stops.filter((s) => !s.fixed).map((s) => s.building_id);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private name(id: number): string {
|
|
134
|
+
return this.communities.get(id)?.name ?? "";
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private move(from: number, to: number): void {
|
|
138
|
+
const ids = this.newStopIds();
|
|
139
|
+
if (to < 0 || to >= ids.length || from === to) return;
|
|
140
|
+
const [moved] = ids.splice(from, 1);
|
|
141
|
+
ids.splice(to, 0, moved);
|
|
142
|
+
emit(this, "stops-reorder", { buildingIds: ids });
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** The new stop under a pointer's height, for dragging by the grip. */
|
|
146
|
+
private newIndexAt(y: number): number | null {
|
|
147
|
+
const items = [
|
|
148
|
+
...this.renderRoot.querySelectorAll<HTMLElement>(
|
|
149
|
+
".stop-item[data-index]"
|
|
150
|
+
),
|
|
151
|
+
];
|
|
152
|
+
const over =
|
|
153
|
+
items.find((el) => y < el.getBoundingClientRect().bottom) ??
|
|
154
|
+
items[items.length - 1];
|
|
155
|
+
return over ? Number(over.dataset.index) : null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** The stop moved with the arrow keys, whose grip keeps focus in the new order. */
|
|
159
|
+
private refocusGripOf: number | null = null;
|
|
160
|
+
|
|
161
|
+
updated(changed: PropertyValues<this>): void {
|
|
162
|
+
if (changed.has("stops") && this.refocusGripOf !== null) {
|
|
163
|
+
this.renderRoot
|
|
164
|
+
.querySelector<HTMLElement>(
|
|
165
|
+
`.grip[data-building-id="${this.refocusGripOf}"]`
|
|
166
|
+
)
|
|
167
|
+
?.focus();
|
|
168
|
+
this.refocusGripOf = null;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private endDrag(drop: boolean): void {
|
|
173
|
+
if (drop && this.dragIndex !== null && this.dropIndex !== null) {
|
|
174
|
+
this.move(this.dragIndex, this.dropIndex);
|
|
175
|
+
}
|
|
176
|
+
this.dragIndex = null;
|
|
177
|
+
this.dropIndex = null;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
private renderCommunity(): TemplateResult | string {
|
|
181
|
+
if (!this.single) return "";
|
|
182
|
+
const id = this.stops.find((s) => !s.fixed)?.building_id;
|
|
183
|
+
const community = id === undefined ? undefined : this.communities.get(id);
|
|
184
|
+
return html`<h2 class="journey-header">Community</h2>
|
|
185
|
+
<div class="floorplan-image-card community">
|
|
186
|
+
<div class="section-right">
|
|
187
|
+
<p class="image-card-title">${community?.name ?? ""}</p>
|
|
188
|
+
<p class="image-card-subtitle">
|
|
189
|
+
${formatAddress(community?.address ?? null)}
|
|
190
|
+
</p>
|
|
191
|
+
</div>
|
|
192
|
+
${this.canEditCommunities
|
|
193
|
+
? html`<button
|
|
194
|
+
class="floor-plan-badge"
|
|
195
|
+
@click=${() => emit(this, "edit-communities", {})}
|
|
196
|
+
>
|
|
197
|
+
Change
|
|
198
|
+
</button>`
|
|
199
|
+
: ""}
|
|
200
|
+
</div>
|
|
201
|
+
${this.canEditCommunities && this.canAddStop
|
|
202
|
+
? html`<button
|
|
203
|
+
class="floor-plan-badge add-stop"
|
|
204
|
+
@click=${() => emit(this, "edit-communities", {})}
|
|
205
|
+
>
|
|
206
|
+
+ Tour more communities the same day
|
|
207
|
+
</button>`
|
|
208
|
+
: ""}`;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
private renderTourTypes(): TemplateResult {
|
|
212
|
+
return html`<h2 id="tour-type-heading" class="journey-header">Tour Type</h2>
|
|
213
|
+
<div
|
|
214
|
+
id="tour-type-menu"
|
|
215
|
+
role="radiogroup"
|
|
216
|
+
aria-labelledby="tour-type-heading"
|
|
217
|
+
>
|
|
218
|
+
${this.tourTypes.map(({ id }) => {
|
|
219
|
+
const selected = id === this.tourType;
|
|
220
|
+
const choose = () => emit(this, "tour-type-change", { tourType: id });
|
|
221
|
+
return html`<tour-type-option
|
|
222
|
+
outlined
|
|
223
|
+
heading=${TOUR_TYPES[id].heading}
|
|
224
|
+
subtitle=${TOUR_TYPES[id].subtitle}
|
|
225
|
+
.primaryColor=${this.primaryColor}
|
|
226
|
+
.foregroundColorOnPrimaryBackgroundColor=${this
|
|
227
|
+
.foregroundColorOnPrimaryBackgroundColor}
|
|
228
|
+
?selected=${selected}
|
|
229
|
+
@click=${choose}
|
|
230
|
+
@keydown=${(e: KeyboardEvent) => {
|
|
231
|
+
if ([" ", "Enter"].includes(e.key)) {
|
|
232
|
+
e.preventDefault();
|
|
233
|
+
choose();
|
|
234
|
+
}
|
|
235
|
+
}}
|
|
236
|
+
>
|
|
237
|
+
${TOUR_TYPES[id].icon(
|
|
238
|
+
selected ? this.primaryColor : unselectedTourTypeForegroundColor
|
|
239
|
+
)}
|
|
240
|
+
</tour-type-option>`;
|
|
241
|
+
})}
|
|
242
|
+
</div>
|
|
243
|
+
${this.tourTypes.length === 0 && !this.loading
|
|
244
|
+
? html`<p class="explanation">
|
|
245
|
+
No tour type is offered at every community you picked.
|
|
246
|
+
</p>`
|
|
247
|
+
: ""}`;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
private renderDatePicker(): TemplateResult {
|
|
251
|
+
// The month of the chosen or first bookable date, which may not be this month.
|
|
252
|
+
const shown = this.date ?? this.bookableDates[0];
|
|
253
|
+
return html`<date-picker
|
|
254
|
+
outlined
|
|
255
|
+
.shownMonth=${shown?.slice(0, 7)}
|
|
256
|
+
.availabilities=${Object.fromEntries(
|
|
257
|
+
this.bookableDates.map((d) => [d, [dateFromIsoDate(d)]])
|
|
258
|
+
)}
|
|
259
|
+
.defaultDate=${this.date ? dateFromIsoDate(this.date) : undefined}
|
|
260
|
+
@change=${(e: Event) => {
|
|
261
|
+
const picked = (e.target as DatePicker).selectedDate;
|
|
262
|
+
if (picked && toIsoDate(picked) !== this.date) {
|
|
263
|
+
emit(this, "date-change", { date: toIsoDate(picked) });
|
|
264
|
+
}
|
|
265
|
+
}}
|
|
266
|
+
></date-picker>`;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
private renderTimePicker(stop: PlanStop): TemplateResult {
|
|
270
|
+
const times = [...new Set([stop.start, ...stop.alternatives])].sort();
|
|
271
|
+
return html`<time-picker
|
|
272
|
+
selecteddateexists
|
|
273
|
+
.timezone=${stop.timezone}
|
|
274
|
+
.options=${times.map(timeOption)}
|
|
275
|
+
.defaultSelectedTime=${timeOption(stop.start)}
|
|
276
|
+
@change=${(e: Event) => {
|
|
277
|
+
const picked = (e.target as TimePicker).selectedTime;
|
|
278
|
+
if (!picked) {
|
|
279
|
+
// A second click unselects, but every stop needs a time: hand the
|
|
280
|
+
// picker this stop's time again, which it selects when none is.
|
|
281
|
+
(e.target as TimePicker).defaultSelectedTime = timeOption(stop.start);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
const start = `${picked.dateWithTimeZoneOffset.datetime}${picked.dateWithTimeZoneOffset.offset}`;
|
|
285
|
+
this.editingTimeFor = null;
|
|
286
|
+
if (start !== stop.start) {
|
|
287
|
+
emit(this, "stop-time-change", {
|
|
288
|
+
buildingId: stop.building_id,
|
|
289
|
+
start,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}}
|
|
293
|
+
></time-picker>`;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
private renderLinkPrompt(): TemplateResult {
|
|
297
|
+
return html`<h2 class="journey-header">Date and Time</h2>
|
|
298
|
+
<div id="dateAndTimeMenu">
|
|
299
|
+
<button
|
|
300
|
+
id="self-guided-redirect-bttn"
|
|
301
|
+
@click=${() => emit(this, "open-tour-link", {})}
|
|
302
|
+
>
|
|
303
|
+
View Tour Times
|
|
304
|
+
</button>
|
|
305
|
+
</div>`;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
private renderSingleDateAndTime(): TemplateResult {
|
|
309
|
+
const stop = this.stops.find((s) => !s.fixed);
|
|
310
|
+
return html`<h2 class="journey-header">
|
|
311
|
+
Date and Time ${this.loading ? html`<mini-loader></mini-loader>` : ""}
|
|
312
|
+
</h2>
|
|
313
|
+
<div id="dateAndTimeMenu">
|
|
314
|
+
<div id="datePicker">
|
|
315
|
+
${this.renderDatePicker()}
|
|
316
|
+
${stop
|
|
317
|
+
? html`<div>${this.renderTimePicker(stop)}</div>`
|
|
318
|
+
: html`<p class="explanation">
|
|
319
|
+
${this.bookableDates.length === 0 && !this.loading
|
|
320
|
+
? "No tour times in the next 30 days."
|
|
321
|
+
: ""}
|
|
322
|
+
</p>`}
|
|
323
|
+
</div>
|
|
324
|
+
</div>`;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
private renderStop(stop: PlanStop, index: number): TemplateResult {
|
|
328
|
+
const community = this.communities.get(stop.building_id);
|
|
329
|
+
const ids = this.newStopIds();
|
|
330
|
+
const newIndex = ids.indexOf(stop.building_id);
|
|
331
|
+
const editing = this.editingTimeFor === stop.building_id;
|
|
332
|
+
const canReorder = !stop.fixed && ids.length > 1;
|
|
333
|
+
// With no other time to pick, the time is plain text rather than a picker.
|
|
334
|
+
const canChangeTime =
|
|
335
|
+
!stop.fixed && stop.alternatives.some((t) => t !== stop.start);
|
|
336
|
+
const time = `${formatMonthDay(isoDate(stop.start))} · ${formatTimeRange(
|
|
337
|
+
stop.start,
|
|
338
|
+
stop.end
|
|
339
|
+
)}`;
|
|
340
|
+
const dragging = this.dragIndex !== null;
|
|
341
|
+
return html`<li
|
|
342
|
+
class=${classMap({
|
|
343
|
+
"stop-item": true,
|
|
344
|
+
dragging: dragging && this.dragIndex === newIndex,
|
|
345
|
+
"drop-target":
|
|
346
|
+
dragging &&
|
|
347
|
+
this.dropIndex === newIndex &&
|
|
348
|
+
this.dragIndex !== newIndex,
|
|
349
|
+
})}
|
|
350
|
+
data-index=${stop.fixed ? nothing : newIndex}
|
|
351
|
+
>
|
|
352
|
+
${index > 0
|
|
353
|
+
? html`<p class="image-card-subtitle leg">
|
|
354
|
+
${stop.distance_from_prev_mi !== null
|
|
355
|
+
? html`${stop.distance_from_prev_mi.toFixed(1)} mi<span
|
|
356
|
+
class="sr-only"
|
|
357
|
+
>
|
|
358
|
+
from the previous stop</span
|
|
359
|
+
>`
|
|
360
|
+
: ""}
|
|
361
|
+
</p>`
|
|
362
|
+
: ""}
|
|
363
|
+
<div class="floorplan-image-card">
|
|
364
|
+
${canReorder
|
|
365
|
+
? html`<button
|
|
366
|
+
class="icon-button grip"
|
|
367
|
+
data-building-id=${stop.building_id}
|
|
368
|
+
aria-label=${`Reorder ${
|
|
369
|
+
community?.name ?? ""
|
|
370
|
+
}. Use the up and down arrow keys to move it.`}
|
|
371
|
+
@pointerdown=${(e: PointerEvent) => {
|
|
372
|
+
// Pointer events rather than HTML drag and drop, which iOS Safari lacks.
|
|
373
|
+
(e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);
|
|
374
|
+
this.dragIndex = newIndex;
|
|
375
|
+
this.dropIndex = newIndex;
|
|
376
|
+
}}
|
|
377
|
+
@pointermove=${(e: PointerEvent) => {
|
|
378
|
+
if (this.dragIndex !== null) {
|
|
379
|
+
this.dropIndex = this.newIndexAt(e.clientY);
|
|
380
|
+
}
|
|
381
|
+
}}
|
|
382
|
+
@pointerup=${() => this.endDrag(true)}
|
|
383
|
+
@pointercancel=${() => this.endDrag(false)}
|
|
384
|
+
@keydown=${(e: KeyboardEvent) => {
|
|
385
|
+
const to = { ArrowUp: newIndex - 1, ArrowDown: newIndex + 1 }[
|
|
386
|
+
e.key
|
|
387
|
+
];
|
|
388
|
+
if (to === undefined) return;
|
|
389
|
+
e.preventDefault();
|
|
390
|
+
if (to < 0 || to >= ids.length) return;
|
|
391
|
+
this.refocusGripOf = stop.building_id;
|
|
392
|
+
this.move(newIndex, to);
|
|
393
|
+
}}
|
|
394
|
+
>
|
|
395
|
+
${GripIcon()}
|
|
396
|
+
</button>`
|
|
397
|
+
: ""}
|
|
398
|
+
<span class="stop-number" aria-hidden="true">${index + 1}</span>
|
|
399
|
+
<div class="section-right">
|
|
400
|
+
<p class="image-card-title">
|
|
401
|
+
<span class="sr-only">Stop ${index + 1}:</span>
|
|
402
|
+
${community?.name ?? ""}
|
|
403
|
+
</p>
|
|
404
|
+
<p class="image-card-subtitle">
|
|
405
|
+
${formatAddress(community?.address ?? null)}
|
|
406
|
+
</p>
|
|
407
|
+
${!canChangeTime
|
|
408
|
+
? html`<p class="stop-time">
|
|
409
|
+
${time}
|
|
410
|
+
${stop.fixed
|
|
411
|
+
? html`<span class="floor-plan-badge selected">Booked</span>`
|
|
412
|
+
: ""}
|
|
413
|
+
</p>`
|
|
414
|
+
: html`<button
|
|
415
|
+
class="stop-time edit-time"
|
|
416
|
+
aria-expanded=${String(editing)}
|
|
417
|
+
aria-label=${`Change the time at ${community?.name ?? ""}`}
|
|
418
|
+
@click=${() =>
|
|
419
|
+
(this.editingTimeFor = editing ? null : stop.building_id)}
|
|
420
|
+
>
|
|
421
|
+
${time} ${PencilIcon()}
|
|
422
|
+
</button>`}
|
|
423
|
+
${editing ? this.renderTimePicker(stop) : ""}
|
|
424
|
+
</div>
|
|
425
|
+
${!stop.fixed && (ids.length > 1 || this.problems.length > 0)
|
|
426
|
+
? this.renderRemove(stop.building_id, community?.name ?? "")
|
|
427
|
+
: ""}
|
|
428
|
+
</div>
|
|
429
|
+
</li>`;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
private renderRemove(buildingId: number, name: string): TemplateResult {
|
|
433
|
+
return html`<button
|
|
434
|
+
class="icon-button remove"
|
|
435
|
+
aria-label=${`Remove ${name}`}
|
|
436
|
+
@click=${() => emit(this, "stop-remove", { buildingId })}
|
|
437
|
+
>
|
|
438
|
+
${TrashIcon()}
|
|
439
|
+
</button>`;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
private renderProblem(problem: StopProblem): TemplateResult {
|
|
443
|
+
const community = this.communities.get(problem.building_id);
|
|
444
|
+
return html`<li class="stop-item">
|
|
445
|
+
<div class="floorplan-image-card">
|
|
446
|
+
<div class="section-right">
|
|
447
|
+
<p class="image-card-title">${community?.name ?? ""}</p>
|
|
448
|
+
<p class="error-message">${problem.text}</p>
|
|
449
|
+
</div>
|
|
450
|
+
${this.renderRemove(problem.building_id, community?.name ?? "")}
|
|
451
|
+
</div>
|
|
452
|
+
</li>`;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/** Several communities: the date sits under the tour type, as in the design. */
|
|
456
|
+
private renderItineraryDate(): TemplateResult {
|
|
457
|
+
return html`<h2 class="journey-header date-header">Date</h2>
|
|
458
|
+
<div id="datePicker">${this.renderDatePicker()}</div>
|
|
459
|
+
${this.bookableDates.length === 0 && !this.loading
|
|
460
|
+
? html`<p class="explanation">
|
|
461
|
+
These communities have no back-to-back tour times in the next 30
|
|
462
|
+
days. Try removing one.
|
|
463
|
+
</p>`
|
|
464
|
+
: ""}`;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
private renderItinerary(): TemplateResult {
|
|
468
|
+
return html`<h2 class="journey-header">
|
|
469
|
+
Your Itinerary ${this.loading ? html`<mini-loader></mini-loader>` : ""}
|
|
470
|
+
</h2>
|
|
471
|
+
<ol class="stops" aria-busy=${String(this.loading)}>
|
|
472
|
+
${this.stops.map((stop, i) => this.renderStop(stop, i))}
|
|
473
|
+
${this.problems.map((p) => this.renderProblem(p))}
|
|
474
|
+
</ol>
|
|
475
|
+
${this.canEditCommunities && this.canAddStop
|
|
476
|
+
? html`<button
|
|
477
|
+
class="floor-plan-badge add-stop"
|
|
478
|
+
@click=${() => emit(this, "edit-communities", {})}
|
|
479
|
+
>
|
|
480
|
+
+ Add a community
|
|
481
|
+
</button>`
|
|
482
|
+
: ""}`;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
render(): TemplateResult {
|
|
486
|
+
const itinerary = !this.selectedTypeOpensLink && !this.single;
|
|
487
|
+
return html`<div id="tour-type-menu-outer-container">
|
|
488
|
+
${this.renderCommunity()} ${this.renderTourTypes()}
|
|
489
|
+
${itinerary ? this.renderItineraryDate() : ""}
|
|
490
|
+
</div>
|
|
491
|
+
<div id="date-and-time-menu-outer-container">
|
|
492
|
+
${this.selectedTypeOpensLink
|
|
493
|
+
? this.renderLinkPrompt()
|
|
494
|
+
: this.single
|
|
495
|
+
? this.renderSingleDateAndTime()
|
|
496
|
+
: this.renderItinerary()}
|
|
497
|
+
</div>`;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
static styles = [
|
|
501
|
+
tourSchedulerStyles,
|
|
502
|
+
InputStyles,
|
|
503
|
+
floorPlanSelectorStyles,
|
|
504
|
+
floorplanImageCardStyles,
|
|
505
|
+
itineraryStopStyles,
|
|
506
|
+
css`
|
|
507
|
+
/* New layout only: the stop list and the community card's actions. */
|
|
508
|
+
:host {
|
|
509
|
+
display: contents;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
.journey-header {
|
|
513
|
+
align-items: center;
|
|
514
|
+
display: flex;
|
|
515
|
+
gap: 8px;
|
|
516
|
+
margin: 0;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
.floorplan-image-card {
|
|
520
|
+
min-width: 0;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
.community {
|
|
524
|
+
align-items: center;
|
|
525
|
+
margin-bottom: 8px;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
.add-stop {
|
|
529
|
+
margin-bottom: 20px;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
#tour-type-menu-outer-container .journey-header:not(:first-child) {
|
|
533
|
+
margin-top: 4px;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
#tour-type-menu-outer-container .journey-header.date-header {
|
|
537
|
+
margin-top: 20px;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
.community {
|
|
541
|
+
background: #ffffff;
|
|
542
|
+
border: 1px solid #e7e7e7;
|
|
543
|
+
border-radius: 8px;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
.stop-item.dragging {
|
|
547
|
+
opacity: 0.5;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
.stop-item.drop-target .floorplan-image-card {
|
|
551
|
+
border-color: var(--primary-color, #646987);
|
|
552
|
+
border-style: dashed;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
.section-right {
|
|
556
|
+
flex: 1;
|
|
557
|
+
min-width: 0;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
.icon-button {
|
|
561
|
+
align-items: center;
|
|
562
|
+
align-self: flex-start;
|
|
563
|
+
background: none;
|
|
564
|
+
border: none;
|
|
565
|
+
border-radius: 4px;
|
|
566
|
+
color: #737373;
|
|
567
|
+
cursor: pointer;
|
|
568
|
+
display: inline-flex;
|
|
569
|
+
flex-shrink: 0;
|
|
570
|
+
padding: 4px;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
.icon-button:hover {
|
|
574
|
+
color: #202020;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/* Beside the stop number, even while the stop's time picker is open. */
|
|
578
|
+
.grip {
|
|
579
|
+
cursor: grab;
|
|
580
|
+
touch-action: none;
|
|
581
|
+
padding: 4px 0;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
.stop-time {
|
|
585
|
+
align-items: center;
|
|
586
|
+
display: inline-flex;
|
|
587
|
+
gap: 6px;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
.edit-time {
|
|
591
|
+
background: none;
|
|
592
|
+
border: none;
|
|
593
|
+
color: inherit;
|
|
594
|
+
cursor: pointer;
|
|
595
|
+
font: inherit;
|
|
596
|
+
font-size: 0.9rem;
|
|
597
|
+
padding: 0;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
.edit-time svg {
|
|
601
|
+
color: #737373;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
.stop-time .floor-plan-badge {
|
|
605
|
+
cursor: default;
|
|
606
|
+
font-size: 0.7rem;
|
|
607
|
+
padding: 2px 8px;
|
|
608
|
+
}
|
|
609
|
+
`,
|
|
610
|
+
];
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
declare global {
|
|
614
|
+
interface HTMLElementTagNameMap {
|
|
615
|
+
"itinerary-editor": ItineraryEditor;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The list of stops in an itinerary, shared by the schedule step and the
|
|
5
|
+
* confirmation. Each stop is a fee calculator card (`.floorplan-image-card`);
|
|
6
|
+
* this adds only the numbering and the distance between stops.
|
|
7
|
+
*/
|
|
8
|
+
export const itineraryStopStyles = css`
|
|
9
|
+
.stops {
|
|
10
|
+
list-style: none;
|
|
11
|
+
margin: 0 0 12px;
|
|
12
|
+
padding: 0;
|
|
13
|
+
width: 100%;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.stops .floorplan-image-card {
|
|
17
|
+
background: #ffffff;
|
|
18
|
+
border: 1px solid #e7e7e7;
|
|
19
|
+
border-radius: 8px;
|
|
20
|
+
min-width: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.leg {
|
|
24
|
+
border-left: 1px dashed #ddd;
|
|
25
|
+
margin: 0 0 0 24px;
|
|
26
|
+
min-height: 12px;
|
|
27
|
+
padding: 4px 0 4px 12px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.stop-number {
|
|
31
|
+
align-items: center;
|
|
32
|
+
border: 1px solid #ddd;
|
|
33
|
+
border-radius: 50%;
|
|
34
|
+
display: inline-flex;
|
|
35
|
+
flex: 0 0 24px;
|
|
36
|
+
font-size: 0.8rem;
|
|
37
|
+
height: 24px;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.stop-time {
|
|
42
|
+
font-size: 0.9rem;
|
|
43
|
+
margin: 4px 0;
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
@@ -34,6 +34,26 @@ export interface Community {
|
|
|
34
34
|
unavailable_reason: string | null;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/** What the scheduler keeps about a community the prospect picked. */
|
|
38
|
+
export interface CommunitySummary {
|
|
39
|
+
building_id: number;
|
|
40
|
+
name: string;
|
|
41
|
+
address: CommunityAddress | null;
|
|
42
|
+
timezone: string | null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const toCommunitySummary = (c: Community): CommunitySummary => ({
|
|
46
|
+
building_id: c.building_id,
|
|
47
|
+
name: c.name,
|
|
48
|
+
address: c.address,
|
|
49
|
+
timezone: c.timezone,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const formatAddress = (address: CommunityAddress | null): string =>
|
|
53
|
+
address
|
|
54
|
+
? [address.line1, address.city, address.state].filter(Boolean).join(", ")
|
|
55
|
+
: "";
|
|
56
|
+
|
|
37
57
|
/**
|
|
38
58
|
* Most stops in one itinerary, counting ones already booked. The server's cap,
|
|
39
59
|
* mirrored here for the picker; booking enforces the real one.
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import format from "date-fns/format";
|
|
2
|
+
import type { SVGTemplateResult } from "lit";
|
|
2
3
|
import type { TourTypeId } from "./tourItineraryApi";
|
|
4
|
+
import { TourSelfGuidedIcon } from "../icons/TourSelfGuidedIcon";
|
|
5
|
+
import { TourVirtuallyIcon } from "../icons/TourVirtuallyIcon";
|
|
6
|
+
import { TourWithAgentIcon } from "../icons/TourWithAgentIcon";
|
|
3
7
|
|
|
4
8
|
/*
|
|
5
9
|
* The API sends each time as ISO 8601 in its building's own time zone
|
|
@@ -66,13 +70,30 @@ export const formatLongDate = (date: string): string =>
|
|
|
66
70
|
/** A Date as the "YYYY-MM-DD" the API uses. */
|
|
67
71
|
export const toIsoDate = (date: Date): string => format(date, "yyyy-MM-dd");
|
|
68
72
|
|
|
69
|
-
|
|
73
|
+
/** The Central Agent design's names for each tour type, with today's icons. */
|
|
74
|
+
export const TOUR_TYPES: Record<
|
|
70
75
|
TourTypeId,
|
|
71
|
-
{
|
|
76
|
+
{
|
|
77
|
+
heading: string;
|
|
78
|
+
subtitle: string;
|
|
79
|
+
icon: (color: string) => SVGTemplateResult;
|
|
80
|
+
}
|
|
72
81
|
> = {
|
|
73
|
-
"escorted-tour": {
|
|
74
|
-
|
|
75
|
-
|
|
82
|
+
"escorted-tour": {
|
|
83
|
+
heading: "Escorted Tour",
|
|
84
|
+
subtitle: "With an agent",
|
|
85
|
+
icon: TourWithAgentIcon,
|
|
86
|
+
},
|
|
87
|
+
"live-virtual-tour": {
|
|
88
|
+
heading: "Virtual Tour",
|
|
89
|
+
subtitle: "Over video",
|
|
90
|
+
icon: TourVirtuallyIcon,
|
|
91
|
+
},
|
|
92
|
+
"self-guided-tour": {
|
|
93
|
+
heading: "Self-Guided Tour",
|
|
94
|
+
subtitle: "On your own",
|
|
95
|
+
icon: TourSelfGuidedIcon,
|
|
96
|
+
},
|
|
76
97
|
};
|
|
77
98
|
|
|
78
99
|
export const TOUR_TYPE_ORDER: TourTypeId[] = [
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { svg, SVGTemplateResult } from "lit";
|
|
2
|
+
|
|
3
|
+
export const GripIcon = (color = "currentColor"): SVGTemplateResult => svg`<svg
|
|
4
|
+
aria-hidden="true"
|
|
5
|
+
focusable="false"
|
|
6
|
+
width="16"
|
|
7
|
+
height="16"
|
|
8
|
+
viewBox="0 0 24 24"
|
|
9
|
+
fill="${color}"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
>
|
|
12
|
+
<circle cx="9" cy="6" r="1.5" />
|
|
13
|
+
<circle cx="15" cy="6" r="1.5" />
|
|
14
|
+
<circle cx="9" cy="12" r="1.5" />
|
|
15
|
+
<circle cx="15" cy="12" r="1.5" />
|
|
16
|
+
<circle cx="9" cy="18" r="1.5" />
|
|
17
|
+
<circle cx="15" cy="18" r="1.5" />
|
|
18
|
+
</svg>`;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { svg, SVGTemplateResult } from "lit";
|
|
2
|
+
|
|
3
|
+
export const PencilIcon = (
|
|
4
|
+
color = "currentColor"
|
|
5
|
+
): SVGTemplateResult => svg`<svg
|
|
6
|
+
aria-hidden="true"
|
|
7
|
+
focusable="false"
|
|
8
|
+
width="16"
|
|
9
|
+
height="16"
|
|
10
|
+
viewBox="0 0 24 24"
|
|
11
|
+
fill="none"
|
|
12
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
13
|
+
>
|
|
14
|
+
<path
|
|
15
|
+
d="M4 20h4L19 9l-4-4L4 16v4z M13.5 6.5l4 4"
|
|
16
|
+
stroke="${color}"
|
|
17
|
+
stroke-width="1.75"
|
|
18
|
+
stroke-linecap="round"
|
|
19
|
+
stroke-linejoin="round"
|
|
20
|
+
/>
|
|
21
|
+
</svg>`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { svg, SVGTemplateResult } from "lit";
|
|
2
|
+
|
|
3
|
+
export const TrashIcon = (color = "currentColor"): SVGTemplateResult => svg`<svg
|
|
4
|
+
aria-hidden="true"
|
|
5
|
+
focusable="false"
|
|
6
|
+
width="16"
|
|
7
|
+
height="16"
|
|
8
|
+
viewBox="0 0 24 24"
|
|
9
|
+
fill="none"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
>
|
|
12
|
+
<path
|
|
13
|
+
d="M4 7h16 M9 7V4h6v3 M6 7l1 13h10l1-13 M10 11v6 M14 11v6"
|
|
14
|
+
stroke="${color}"
|
|
15
|
+
stroke-width="1.75"
|
|
16
|
+
stroke-linecap="round"
|
|
17
|
+
stroke-linejoin="round"
|
|
18
|
+
/>
|
|
19
|
+
</svg>`;
|