@sprucelabs/spruce-calendar-components 20.1.0 → 20.1.3
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/build/esm/viewControllers/Calendar.vc.d.ts +1 -1
- package/build/esm/viewControllers/Calendar.vc.js +1 -1
- package/build/esm/viewControllers/EventDateTimeTool.vc.d.ts +5 -1
- package/build/esm/viewControllers/EventDateTimeTool.vc.js +24 -0
- package/build/viewControllers/Calendar.vc.d.ts +1 -1
- package/build/viewControllers/Calendar.vc.js +1 -1
- package/build/viewControllers/EventDateTimeTool.vc.d.ts +5 -1
- package/build/viewControllers/EventDateTimeTool.vc.js +22 -0
- package/package.json +1 -1
|
@@ -40,7 +40,7 @@ export default class CalendarViewController extends CoreCalendarViewController {
|
|
|
40
40
|
private getDraftEvent;
|
|
41
41
|
private removeDraftEvent;
|
|
42
42
|
private addDraftEventFromClick;
|
|
43
|
-
addDraftEvent(event: Event): Promise<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent |
|
|
43
|
+
addDraftEvent(event: Event): Promise<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent | SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent>;
|
|
44
44
|
getIsSwappingEvent(): boolean;
|
|
45
45
|
private swapEvent;
|
|
46
46
|
updateEvent(id: string, updates: Partial<UpdateEvent>): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent;
|
|
@@ -131,7 +131,7 @@ export default class CalendarViewController extends CoreCalendarViewController {
|
|
|
131
131
|
const draftAddedPromise = this.draftAddedHandler(event);
|
|
132
132
|
const saved = yield this.persist(event);
|
|
133
133
|
yield draftAddedPromise;
|
|
134
|
-
return saved;
|
|
134
|
+
return saved !== null && saved !== void 0 ? saved : event;
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
getIsSwappingEvent() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractViewController, FormViewController, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
1
|
+
import { AbstractViewController, CalendarViewController, FormViewController, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { CalendarTool, CalendarToolBeltContext, CalendarToolOptions } from '../types/calendar.types';
|
|
3
3
|
declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
4
4
|
export default class EventDateTimeToolViewController extends AbstractViewController<Card> implements CalendarTool {
|
|
@@ -8,8 +8,12 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
|
|
|
8
8
|
private formVc;
|
|
9
9
|
private updateContext;
|
|
10
10
|
private getContext;
|
|
11
|
+
private calendarVc;
|
|
11
12
|
constructor(options: ViewControllerOptions & CalendarToolOptions);
|
|
13
|
+
private handleSelectDateFromCalendar;
|
|
14
|
+
private getSelectedDate;
|
|
12
15
|
private CardVc;
|
|
16
|
+
getCalendarVc(): CalendarViewController;
|
|
13
17
|
private FormVc;
|
|
14
18
|
handleUpdateContext(context: CalendarToolBeltContext): Promise<void>;
|
|
15
19
|
private handleChangeForm;
|
|
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { dateUtil } from '@sprucelabs/calendar-utils';
|
|
10
11
|
import { AbstractViewController, buildForm, } from '@sprucelabs/heartwood-view-controllers';
|
|
11
12
|
import { buildSchema } from '@sprucelabs/schema';
|
|
12
13
|
const schema = buildSchema({
|
|
@@ -24,9 +25,25 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
|
|
|
24
25
|
this.shouldPersistContextChangesImmediately = true;
|
|
25
26
|
this.updateContext = options.updateContext;
|
|
26
27
|
this.getContext = options.getContext;
|
|
28
|
+
this.calendarVc = this.Controller('calendar', {
|
|
29
|
+
view: 'month',
|
|
30
|
+
selectedDates: [this.getSelectedDate()],
|
|
31
|
+
onClick: this.handleSelectDateFromCalendar.bind(this),
|
|
32
|
+
});
|
|
27
33
|
this.formVc = this.FormVc();
|
|
28
34
|
this.cardVc = this.CardVc();
|
|
29
35
|
}
|
|
36
|
+
handleSelectDateFromCalendar({ dateTimeMs, }) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const { hour, minute } = dateUtil.splitDate(this.getContext().event.startDateTimeMs);
|
|
39
|
+
yield this.formVc.setValue('startDateTime', dateUtil.setTimeOfDay(dateTimeMs, hour, minute, 0, 0));
|
|
40
|
+
this.calendarVc.setSelectedDates([this.getSelectedDate(dateTimeMs)]);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
getSelectedDate(dateTimeMs) {
|
|
44
|
+
const { year, month, day } = dateUtil.splitDate(dateTimeMs !== null && dateTimeMs !== void 0 ? dateTimeMs : this.getContext().event.startDateTimeMs);
|
|
45
|
+
return { year, month, day };
|
|
46
|
+
}
|
|
30
47
|
CardVc() {
|
|
31
48
|
return this.Controller('card', {
|
|
32
49
|
header: {
|
|
@@ -34,6 +51,9 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
|
|
|
34
51
|
},
|
|
35
52
|
body: {
|
|
36
53
|
sections: [
|
|
54
|
+
{
|
|
55
|
+
calendar: this.calendarVc.render(),
|
|
56
|
+
},
|
|
37
57
|
{
|
|
38
58
|
form: this.formVc.render(),
|
|
39
59
|
},
|
|
@@ -41,6 +61,9 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
|
|
|
41
61
|
},
|
|
42
62
|
});
|
|
43
63
|
}
|
|
64
|
+
getCalendarVc() {
|
|
65
|
+
return this.calendarVc;
|
|
66
|
+
}
|
|
44
67
|
FormVc() {
|
|
45
68
|
return this.Controller('form', buildForm({
|
|
46
69
|
schema,
|
|
@@ -59,6 +82,7 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
|
|
|
59
82
|
handleUpdateContext(context) {
|
|
60
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
84
|
yield this.formVc.setValue('startDateTime', context.event.startDateTimeMs);
|
|
85
|
+
this.calendarVc.setSelectedDates([this.getSelectedDate()]);
|
|
62
86
|
});
|
|
63
87
|
}
|
|
64
88
|
handleChangeForm({ values }) {
|
|
@@ -40,7 +40,7 @@ export default class CalendarViewController extends CoreCalendarViewController {
|
|
|
40
40
|
private getDraftEvent;
|
|
41
41
|
private removeDraftEvent;
|
|
42
42
|
private addDraftEventFromClick;
|
|
43
|
-
addDraftEvent(event: Event): Promise<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent |
|
|
43
|
+
addDraftEvent(event: Event): Promise<SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent | SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent>;
|
|
44
44
|
getIsSwappingEvent(): boolean;
|
|
45
45
|
private swapEvent;
|
|
46
46
|
updateEvent(id: string, updates: Partial<UpdateEvent>): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.CalendarEvent;
|
|
@@ -118,7 +118,7 @@ class CalendarViewController extends heartwood_view_controllers_1.CalendarViewCo
|
|
|
118
118
|
const draftAddedPromise = this.draftAddedHandler(event);
|
|
119
119
|
const saved = await this.persist(event);
|
|
120
120
|
await draftAddedPromise;
|
|
121
|
-
return saved;
|
|
121
|
+
return saved !== null && saved !== void 0 ? saved : event;
|
|
122
122
|
}
|
|
123
123
|
getIsSwappingEvent() {
|
|
124
124
|
return this.isSwapping;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractViewController, FormViewController, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
1
|
+
import { AbstractViewController, CalendarViewController, FormViewController, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { CalendarTool, CalendarToolBeltContext, CalendarToolOptions } from '../types/calendar.types';
|
|
3
3
|
declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
4
4
|
export default class EventDateTimeToolViewController extends AbstractViewController<Card> implements CalendarTool {
|
|
@@ -8,8 +8,12 @@ export default class EventDateTimeToolViewController extends AbstractViewControl
|
|
|
8
8
|
private formVc;
|
|
9
9
|
private updateContext;
|
|
10
10
|
private getContext;
|
|
11
|
+
private calendarVc;
|
|
11
12
|
constructor(options: ViewControllerOptions & CalendarToolOptions);
|
|
13
|
+
private handleSelectDateFromCalendar;
|
|
14
|
+
private getSelectedDate;
|
|
12
15
|
private CardVc;
|
|
16
|
+
getCalendarVc(): CalendarViewController;
|
|
13
17
|
private FormVc;
|
|
14
18
|
handleUpdateContext(context: CalendarToolBeltContext): Promise<void>;
|
|
15
19
|
private handleChangeForm;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const calendar_utils_1 = require("@sprucelabs/calendar-utils");
|
|
3
4
|
const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
|
|
4
5
|
const schema_1 = require("@sprucelabs/schema");
|
|
5
6
|
const schema = (0, schema_1.buildSchema)({
|
|
@@ -17,9 +18,23 @@ class EventDateTimeToolViewController extends heartwood_view_controllers_1.Abstr
|
|
|
17
18
|
this.shouldPersistContextChangesImmediately = true;
|
|
18
19
|
this.updateContext = options.updateContext;
|
|
19
20
|
this.getContext = options.getContext;
|
|
21
|
+
this.calendarVc = this.Controller('calendar', {
|
|
22
|
+
view: 'month',
|
|
23
|
+
selectedDates: [this.getSelectedDate()],
|
|
24
|
+
onClick: this.handleSelectDateFromCalendar.bind(this),
|
|
25
|
+
});
|
|
20
26
|
this.formVc = this.FormVc();
|
|
21
27
|
this.cardVc = this.CardVc();
|
|
22
28
|
}
|
|
29
|
+
async handleSelectDateFromCalendar({ dateTimeMs, }) {
|
|
30
|
+
const { hour, minute } = calendar_utils_1.dateUtil.splitDate(this.getContext().event.startDateTimeMs);
|
|
31
|
+
await this.formVc.setValue('startDateTime', calendar_utils_1.dateUtil.setTimeOfDay(dateTimeMs, hour, minute, 0, 0));
|
|
32
|
+
this.calendarVc.setSelectedDates([this.getSelectedDate(dateTimeMs)]);
|
|
33
|
+
}
|
|
34
|
+
getSelectedDate(dateTimeMs) {
|
|
35
|
+
const { year, month, day } = calendar_utils_1.dateUtil.splitDate(dateTimeMs !== null && dateTimeMs !== void 0 ? dateTimeMs : this.getContext().event.startDateTimeMs);
|
|
36
|
+
return { year, month, day };
|
|
37
|
+
}
|
|
23
38
|
CardVc() {
|
|
24
39
|
return this.Controller('card', {
|
|
25
40
|
header: {
|
|
@@ -27,6 +42,9 @@ class EventDateTimeToolViewController extends heartwood_view_controllers_1.Abstr
|
|
|
27
42
|
},
|
|
28
43
|
body: {
|
|
29
44
|
sections: [
|
|
45
|
+
{
|
|
46
|
+
calendar: this.calendarVc.render(),
|
|
47
|
+
},
|
|
30
48
|
{
|
|
31
49
|
form: this.formVc.render(),
|
|
32
50
|
},
|
|
@@ -34,6 +52,9 @@ class EventDateTimeToolViewController extends heartwood_view_controllers_1.Abstr
|
|
|
34
52
|
},
|
|
35
53
|
});
|
|
36
54
|
}
|
|
55
|
+
getCalendarVc() {
|
|
56
|
+
return this.calendarVc;
|
|
57
|
+
}
|
|
37
58
|
FormVc() {
|
|
38
59
|
return this.Controller('form', (0, heartwood_view_controllers_1.buildForm)({
|
|
39
60
|
schema,
|
|
@@ -51,6 +72,7 @@ class EventDateTimeToolViewController extends heartwood_view_controllers_1.Abstr
|
|
|
51
72
|
}
|
|
52
73
|
async handleUpdateContext(context) {
|
|
53
74
|
await this.formVc.setValue('startDateTime', context.event.startDateTimeMs);
|
|
75
|
+
this.calendarVc.setSelectedDates([this.getSelectedDate()]);
|
|
54
76
|
}
|
|
55
77
|
async handleChangeForm({ values }) {
|
|
56
78
|
var _a;
|