@meetelise/chat 1.65.0 → 1.67.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/booking-confirmation.d.ts +33 -0
- package/dist/src/WebComponent/SchedulerV2/community-picker.d.ts +22 -17
- package/dist/src/WebComponent/SchedulerV2/contact-form.d.ts +49 -0
- 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/booking-confirmation.ts +205 -0
- package/src/WebComponent/SchedulerV2/community-picker.ts +110 -126
- package/src/WebComponent/SchedulerV2/contact-form.ts +269 -0
- 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
|
@@ -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.
|