@sprucelabs/spruce-appointment-utils 5.1.4

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.
Files changed (34) hide show
  1. package/README.md +5 -0
  2. package/build/esm/index-module.d.ts +7 -0
  3. package/build/esm/index-module.js +7 -0
  4. package/build/esm/types-module.d.ts +21 -0
  5. package/build/esm/types-module.js +1 -0
  6. package/build/esm/viewControllers/AbstractCapabilityCardViewController.d.ts +32 -0
  7. package/build/esm/viewControllers/AbstractCapabilityCardViewController.js +143 -0
  8. package/build/esm/viewControllers/DurationCard.vc.d.ts +33 -0
  9. package/build/esm/viewControllers/DurationCard.vc.js +75 -0
  10. package/build/esm/viewControllers/DurationList.vc.d.ts +37 -0
  11. package/build/esm/viewControllers/DurationList.vc.js +188 -0
  12. package/build/esm/viewControllers/EditOverrideDetailsCard.vc.d.ts +44 -0
  13. package/build/esm/viewControllers/EditOverrideDetailsCard.vc.js +98 -0
  14. package/build/esm/viewControllers/EditTimeBlockTitleCard.vc.d.ts +33 -0
  15. package/build/esm/viewControllers/EditTimeBlockTitleCard.vc.js +69 -0
  16. package/build/esm/viewControllers/RolesCard.vc.d.ts +22 -0
  17. package/build/esm/viewControllers/RolesCard.vc.js +75 -0
  18. package/build/index-module.d.ts +7 -0
  19. package/build/index-module.js +29 -0
  20. package/build/types-module.d.ts +21 -0
  21. package/build/types-module.js +2 -0
  22. package/build/viewControllers/AbstractCapabilityCardViewController.d.ts +32 -0
  23. package/build/viewControllers/AbstractCapabilityCardViewController.js +131 -0
  24. package/build/viewControllers/DurationCard.vc.d.ts +33 -0
  25. package/build/viewControllers/DurationCard.vc.js +69 -0
  26. package/build/viewControllers/DurationList.vc.d.ts +37 -0
  27. package/build/viewControllers/DurationList.vc.js +178 -0
  28. package/build/viewControllers/EditOverrideDetailsCard.vc.d.ts +44 -0
  29. package/build/viewControllers/EditOverrideDetailsCard.vc.js +92 -0
  30. package/build/viewControllers/EditTimeBlockTitleCard.vc.d.ts +33 -0
  31. package/build/viewControllers/EditTimeBlockTitleCard.vc.js +72 -0
  32. package/build/viewControllers/RolesCard.vc.d.ts +22 -0
  33. package/build/viewControllers/RolesCard.vc.js +66 -0
  34. package/package.json +64 -0
@@ -0,0 +1,37 @@
1
+ import { AbstractViewController, ListViewController, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
2
+ import { EventTimeBlock } from './DurationCard.vc';
3
+ import { FormVc } from './EditTimeBlockTitleCard.vc';
4
+ declare type List = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.List;
5
+ declare type TimeBlockWithId = EventTimeBlock & {
6
+ id: string;
7
+ };
8
+ export declare type DurationListViewControllerOptions = ViewControllerOptions;
9
+ export default class DurationListViewController extends AbstractViewController<List> {
10
+ static id: string;
11
+ private listVc;
12
+ private timeBlocksWithId;
13
+ private timeBlockRowIdx;
14
+ private editTitleFormVc?;
15
+ constructor(options: DurationListViewControllerOptions);
16
+ private ListVc;
17
+ setValues(timeBlocks: EventTimeBlock[] | undefined): void;
18
+ private generateBlockId;
19
+ private addRow;
20
+ getListVc(): ListViewController;
21
+ getTimeBlocks(): {
22
+ title?: string | null | undefined;
23
+ subtitle?: string | null | undefined;
24
+ isBusy: boolean;
25
+ rightIcons?: SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventLineIcon[] | null | undefined;
26
+ leftIcons?: SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEventLineIcon[] | null | undefined;
27
+ durationMinutes?: number | undefined;
28
+ id: string;
29
+ }[];
30
+ private buildRow;
31
+ addNewTimeBlock(): void;
32
+ handleClickEditTitle(timeBlock: TimeBlockWithId): Promise<void>;
33
+ private handleClickDelete;
34
+ getEditTitleFormVc(): FormVc | undefined;
35
+ render(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.List;
36
+ }
37
+ export {};
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
15
+ class DurationListViewController extends heartwood_view_controllers_1.AbstractViewController {
16
+ constructor(options) {
17
+ super(options);
18
+ this.timeBlocksWithId = [];
19
+ this.timeBlockRowIdx = 0;
20
+ this.listVc = this.ListVc();
21
+ }
22
+ ListVc() {
23
+ return this.Controller('list', {
24
+ columnWidths: ['content', 'content', 'fill'],
25
+ rows: [],
26
+ });
27
+ }
28
+ setValues(timeBlocks) {
29
+ if (!timeBlocks || timeBlocks.length === 0) {
30
+ timeBlocks = [
31
+ { title: 'Duration', isBusy: true, durationMinutes: undefined },
32
+ ];
33
+ }
34
+ this.timeBlocksWithId = timeBlocks.map((tb) => (Object.assign({ id: this.generateBlockId() }, tb)));
35
+ for (const timeBlock of this.timeBlocksWithId) {
36
+ this.addRow(timeBlock);
37
+ }
38
+ }
39
+ generateBlockId() {
40
+ return `timeblock-${this.timeBlockRowIdx++}`;
41
+ }
42
+ addRow(timeBlock) {
43
+ this.listVc.addRow(this.buildRow(timeBlock));
44
+ }
45
+ getListVc() {
46
+ return this.listVc;
47
+ }
48
+ getTimeBlocks() {
49
+ return this.timeBlocksWithId.map((tb) => {
50
+ const values = __rest(tb
51
+ //@ts-ignore
52
+ , []);
53
+ //@ts-ignore
54
+ delete values.id;
55
+ return values;
56
+ });
57
+ }
58
+ buildRow(timeBlockWithId) {
59
+ var _a, _b;
60
+ const { id: rowId } = timeBlockWithId, timeBlock = __rest(timeBlockWithId, ["id"]);
61
+ return {
62
+ id: rowId,
63
+ height: 'content',
64
+ cells: [
65
+ {
66
+ button: {
67
+ id: 'edit-title',
68
+ lineIcon: 'edit-line',
69
+ onClick: async () => {
70
+ await this.handleClickEditTitle(timeBlockWithId);
71
+ },
72
+ },
73
+ },
74
+ {
75
+ text: {
76
+ content: (_a = timeBlock.title) !== null && _a !== void 0 ? _a : 'Duration',
77
+ },
78
+ },
79
+ {
80
+ textInput: {
81
+ name: 'durationMinutes',
82
+ label: 'Minutes',
83
+ value: (timeBlock === null || timeBlock === void 0 ? void 0 : timeBlock.durationMinutes)
84
+ ? `${timeBlock === null || timeBlock === void 0 ? void 0 : timeBlock.durationMinutes}`
85
+ : undefined,
86
+ onChange: async (value) => {
87
+ if (value) {
88
+ const cleaned = value.replace(/[^0-9]/, '');
89
+ if (cleaned !== value) {
90
+ await this.listVc
91
+ .getRowVc(rowId)
92
+ .setValue('durationMinutes', cleaned);
93
+ return false;
94
+ }
95
+ timeBlockWithId.durationMinutes = parseInt(value, 10);
96
+ }
97
+ return true;
98
+ },
99
+ },
100
+ },
101
+ {
102
+ toggleInput: {
103
+ name: 'isBusy',
104
+ value: (_b = timeBlock === null || timeBlock === void 0 ? void 0 : timeBlock.isBusy) !== null && _b !== void 0 ? _b : true,
105
+ onChange: (value) => {
106
+ timeBlockWithId.isBusy = value !== null && value !== void 0 ? value : false;
107
+ },
108
+ },
109
+ },
110
+ {
111
+ button: {
112
+ lineIcon: 'help-circle',
113
+ onClick: async () => {
114
+ await this.alert({
115
+ style: 'info',
116
+ title: 'Mark time as busy?',
117
+ message: `This toggle is how you set this time to be marked as busy or not. If the time is busy, nobody can book the provider during this time. If the time is not busy, people can book over this time.`,
118
+ });
119
+ },
120
+ },
121
+ },
122
+ {
123
+ button: {
124
+ id: 'delete',
125
+ lineIcon: 'delete',
126
+ type: 'destructive',
127
+ onClick: () => {
128
+ return this.handleClickDelete(timeBlockWithId);
129
+ },
130
+ },
131
+ },
132
+ ],
133
+ };
134
+ }
135
+ addNewTimeBlock() {
136
+ const timeBlock = {
137
+ id: this.generateBlockId(),
138
+ isBusy: true,
139
+ };
140
+ this.timeBlocksWithId.push(timeBlock);
141
+ this.addRow(timeBlock);
142
+ }
143
+ async handleClickEditTitle(timeBlock) {
144
+ var _a;
145
+ const editVc = this.Controller('appointments.edit-time-block-title-card', {
146
+ onCancel: () => { },
147
+ onSubmit: async (title) => {
148
+ timeBlock.title = title;
149
+ this.listVc.upsertRow(timeBlock.id, Object.assign({}, this.buildRow(timeBlock)));
150
+ this.listVc.triggerRender();
151
+ await dlgVc.hide();
152
+ },
153
+ title: (_a = timeBlock === null || timeBlock === void 0 ? void 0 : timeBlock.title) !== null && _a !== void 0 ? _a : '',
154
+ });
155
+ this.editTitleFormVc = editVc.getFormVc();
156
+ const dlgVc = this.renderInDialog(Object.assign({}, editVc.render()));
157
+ }
158
+ async handleClickDelete(timeBlock) {
159
+ const shouldDelete = await this.confirm({
160
+ title: `You sure?`,
161
+ isDestructive: true,
162
+ });
163
+ if (!shouldDelete) {
164
+ return;
165
+ }
166
+ this.listVc.deleteRow(timeBlock.id);
167
+ const idx = this.timeBlocksWithId.indexOf(timeBlock);
168
+ this.timeBlocksWithId.splice(idx, 1);
169
+ }
170
+ getEditTitleFormVc() {
171
+ return this.editTitleFormVc;
172
+ }
173
+ render() {
174
+ return this.listVc.render();
175
+ }
176
+ }
177
+ exports.default = DurationListViewController;
178
+ DurationListViewController.id = 'duration-list';
@@ -0,0 +1,44 @@
1
+ import { SpruceSchemas as SpruceSchemasCalendarUtils } from '@sprucelabs/calendar-utils';
2
+ import { AbstractViewController, FormViewController, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
3
+ import DurationCardViewController from './DurationCard.vc';
4
+ declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
5
+ declare type EventTimeBlock = Omit<SpruceSchemasCalendarUtils.CalendarUtils.v2021_05_19.EventTimeBlock, 'durationMinutes'> & {
6
+ durationMinutes?: number;
7
+ };
8
+ declare const schema: {
9
+ id: string;
10
+ fields: {
11
+ price: {
12
+ type: "text";
13
+ label: string;
14
+ };
15
+ };
16
+ };
17
+ declare type Schema = typeof schema;
18
+ export declare type FormVc = FormViewController<Schema>;
19
+ interface EditOverrideDetailsOptions {
20
+ service?: any;
21
+ serviceRoleCapability?: any;
22
+ onCancel: () => void;
23
+ onSubmit: (price: string | undefined, timeBlocks: EventTimeBlock[] | undefined, service: any | undefined, serviceRoleCapability: any | undefined) => void;
24
+ }
25
+ export declare type EditOverrideDetailsCardViewControllerOptions = ViewControllerOptions & EditOverrideDetailsOptions;
26
+ export default class EditOverrideDetailsCardViewController extends AbstractViewController<Card> {
27
+ static id: string;
28
+ private cardVc;
29
+ private formVc;
30
+ private durationVc;
31
+ private durationListVc;
32
+ private onSubmitHandler;
33
+ private onCancelHandler;
34
+ private service;
35
+ private serviceRoleCapability;
36
+ constructor(options: EditOverrideDetailsCardViewControllerOptions);
37
+ private FormVc;
38
+ private handleClickAddTimeBlock;
39
+ private CardVc;
40
+ getFormVc(): FormVc;
41
+ getDurationVc(): DurationCardViewController;
42
+ render(): SpruceSchemasCalendarUtils.HeartwoodViewControllers.v2021_02_11.Card;
43
+ }
44
+ export {};
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
4
+ const schema_1 = require("@sprucelabs/schema");
5
+ const schema = (0, schema_1.buildSchema)({
6
+ id: 'priceSchema',
7
+ fields: {
8
+ price: {
9
+ type: 'text',
10
+ label: 'Price',
11
+ },
12
+ },
13
+ });
14
+ class EditOverrideDetailsCardViewController extends heartwood_view_controllers_1.AbstractViewController {
15
+ constructor(options) {
16
+ var _a, _b, _c;
17
+ super(options);
18
+ (0, schema_1.assertOptions)(options, ['onCancel', 'onSubmit']);
19
+ this.service = options === null || options === void 0 ? void 0 : options.service;
20
+ this.serviceRoleCapability = options === null || options === void 0 ? void 0 : options.serviceRoleCapability;
21
+ this.onSubmitHandler = options.onSubmit;
22
+ this.onCancelHandler = options.onCancel;
23
+ this.durationVc = this.Controller('appointments.duration-card', {});
24
+ void this.durationVc.load((_b = (_a = this.serviceRoleCapability) === null || _a === void 0 ? void 0 : _a.timeBlocks) !== null && _b !== void 0 ? _b : (_c = this.service) === null || _c === void 0 ? void 0 : _c.timeBlocks);
25
+ this.durationListVc = this.durationVc.getDurationListVc();
26
+ this.formVc = this.FormVc();
27
+ this.cardVc = this.CardVc();
28
+ }
29
+ FormVc() {
30
+ var _a, _b, _c;
31
+ return this.Controller('form', (0, heartwood_view_controllers_1.buildForm)({
32
+ id: 'editOverrideForm',
33
+ schema,
34
+ shouldShowCancelButton: false,
35
+ onSubmit: ({ values }) => {
36
+ var _a;
37
+ this.onSubmitHandler((_a = values.price) !== null && _a !== void 0 ? _a : undefined, this.getDurationVc().getTimeBlocks(), this.service, this.serviceRoleCapability);
38
+ },
39
+ onCancel: () => {
40
+ this.onCancelHandler();
41
+ },
42
+ sections: [
43
+ {
44
+ fields: ['price'],
45
+ },
46
+ {
47
+ title: 'Duration',
48
+ list: this.durationVc.getDurationListVc().render(),
49
+ },
50
+ ],
51
+ footer: {
52
+ buttons: [
53
+ {
54
+ id: 'addDuration',
55
+ label: 'Add block of time',
56
+ onClick: async () => {
57
+ this.handleClickAddTimeBlock();
58
+ },
59
+ },
60
+ ],
61
+ },
62
+ values: {
63
+ price: (_b = (_a = this.serviceRoleCapability) === null || _a === void 0 ? void 0 : _a.price) !== null && _b !== void 0 ? _b : (_c = this.service) === null || _c === void 0 ? void 0 : _c.price,
64
+ },
65
+ }));
66
+ }
67
+ handleClickAddTimeBlock() {
68
+ this.durationListVc.addNewTimeBlock();
69
+ }
70
+ CardVc() {
71
+ return this.Controller('card', {
72
+ header: {
73
+ title: 'Overrides',
74
+ subtitle: `You can set a custom price and duration for this service!`,
75
+ },
76
+ body: {
77
+ sections: [{ form: this.formVc.render() }],
78
+ },
79
+ });
80
+ }
81
+ getFormVc() {
82
+ return this.formVc;
83
+ }
84
+ getDurationVc() {
85
+ return this.durationVc;
86
+ }
87
+ render() {
88
+ return this.cardVc.render();
89
+ }
90
+ }
91
+ exports.default = EditOverrideDetailsCardViewController;
92
+ EditOverrideDetailsCardViewController.id = 'edit-override-details-card';
@@ -0,0 +1,33 @@
1
+ import { AbstractViewController, FormViewController, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
2
+ declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
3
+ declare const schema: {
4
+ id: string;
5
+ fields: {
6
+ title: {
7
+ type: "text";
8
+ label: string;
9
+ };
10
+ };
11
+ };
12
+ declare type Schema = typeof schema;
13
+ export declare type FormVc = FormViewController<Schema>;
14
+ interface EditTimeBlockOptions {
15
+ title?: string;
16
+ onCancel: () => void;
17
+ onSubmit: (title: string | undefined) => void;
18
+ }
19
+ export declare type EditTimeBlockTitleCardViewControllerOptions = ViewControllerOptions & EditTimeBlockOptions;
20
+ export default class EditTimeBlockTitleCardViewController extends AbstractViewController<Card> {
21
+ static id: string;
22
+ private cardVc;
23
+ private formVc;
24
+ private onSubmitHandler;
25
+ private onCancelHandler;
26
+ private title?;
27
+ constructor(options: EditTimeBlockTitleCardViewControllerOptions);
28
+ private FormVc;
29
+ private CardVc;
30
+ getFormVc(): FormVc;
31
+ render(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
32
+ }
33
+ export {};
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
4
+ const schema_1 = require("@sprucelabs/schema");
5
+ const schema = (0, schema_1.buildSchema)({
6
+ id: 'titleSchema',
7
+ fields: {
8
+ title: {
9
+ type: 'text',
10
+ label: 'Name of timeblock',
11
+ },
12
+ },
13
+ });
14
+ class EditTimeBlockTitleCardViewController extends heartwood_view_controllers_1.AbstractViewController {
15
+ constructor(options) {
16
+ super(options);
17
+ (0, schema_1.assertOptions)(options, ['onCancel', 'onSubmit']);
18
+ this.title = options === null || options === void 0 ? void 0 : options.title;
19
+ this.onSubmitHandler = options.onSubmit;
20
+ this.onCancelHandler = options.onCancel;
21
+ this.formVc = this.FormVc();
22
+ this.cardVc = this.CardVc();
23
+ }
24
+ FormVc() {
25
+ return this.Controller('form', (0, heartwood_view_controllers_1.buildForm)({
26
+ id: 'titleForm',
27
+ schema,
28
+ shouldShowCancelButton: false,
29
+ onSubmit: ({ values }) => {
30
+ var _a;
31
+ this.onSubmitHandler((_a = values.title) !== null && _a !== void 0 ? _a : undefined);
32
+ },
33
+ onCancel: () => {
34
+ this.onCancelHandler();
35
+ },
36
+ sections: [
37
+ {
38
+ fields: ['title'],
39
+ },
40
+ ],
41
+ values: { title: this.title },
42
+ }));
43
+ }
44
+ CardVc() {
45
+ return this.Controller('card', {
46
+ header: {
47
+ title: 'Name this block of time!',
48
+ subtitle: `You only need to think about this if a service takes more than one discrete chunk of time.`,
49
+ },
50
+ body: {
51
+ sections: [
52
+ {
53
+ text: {
54
+ content: 'Here we go!',
55
+ },
56
+ },
57
+ {
58
+ form: this.formVc.render(),
59
+ },
60
+ ],
61
+ },
62
+ });
63
+ }
64
+ getFormVc() {
65
+ return this.formVc;
66
+ }
67
+ render() {
68
+ return this.cardVc.render();
69
+ }
70
+ }
71
+ exports.default = EditTimeBlockTitleCardViewController;
72
+ EditTimeBlockTitleCardViewController.id = 'edit-time-block-title-card';
@@ -0,0 +1,22 @@
1
+ import { SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
2
+ import AbstractCapabilityCardViewController from './AbstractCapabilityCardViewController';
3
+ declare type Role = SpruceSchemas.Spruce.v2020_07_22.Role;
4
+ declare type ToggleHandler = (serviceId: string, isSelected: boolean) => void;
5
+ export declare type RolesCardViewControllerOptions = ViewControllerOptions & {
6
+ role: Role;
7
+ onUpdateHasCapability?: ToggleHandler;
8
+ onEdit?: (row: any) => void;
9
+ };
10
+ export default class RolesCardViewController extends AbstractCapabilityCardViewController {
11
+ static id: string;
12
+ private role;
13
+ constructor(options: RolesCardViewControllerOptions);
14
+ load(options: {
15
+ organizationId?: string;
16
+ shouldIncludePrivateFields?: boolean;
17
+ }): Promise<void>;
18
+ protected loadCapabilities(): Promise<void>;
19
+ protected insertOrUpdateCapability(serviceId: string, values: any, serviceCapability: SpruceSchemas.Appointments.v2021_06_23.ListRoleCapability | undefined): Promise<SpruceSchemas.Appointments.v2021_06_23.ListRoleCapability | undefined>;
20
+ getCapabilities(): any[];
21
+ }
22
+ export {};
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const spruce_event_utils_1 = require("@sprucelabs/spruce-event-utils");
7
+ const AbstractCapabilityCardViewController_1 = __importDefault(require("./AbstractCapabilityCardViewController"));
8
+ class RolesCardViewController extends AbstractCapabilityCardViewController_1.default {
9
+ constructor(options) {
10
+ super(options);
11
+ this.role = options.role;
12
+ this.onUpdateHasCapability = options.onUpdateHasCapability;
13
+ this.onEdit = options.onEdit;
14
+ this.activeRecordCardVc = this.ActiveRecordCard(options.role);
15
+ }
16
+ async load(options) {
17
+ var _a;
18
+ await this.loadVc((_a = options.organizationId) !== null && _a !== void 0 ? _a : 'missing-org');
19
+ }
20
+ async loadCapabilities() {
21
+ const client = await this.connectToApi();
22
+ const results = await client.emit('appointments.list-role-capabilities::v2021_06_23', {
23
+ target: {
24
+ organizationId: this.organizationId,
25
+ roleId: this.role.id,
26
+ },
27
+ });
28
+ const { capabilities } = spruce_event_utils_1.eventResponseUtil.getFirstResponseOrThrow(results);
29
+ this.capabilities = capabilities;
30
+ }
31
+ async insertOrUpdateCapability(serviceId, values, serviceCapability) {
32
+ var _a, _b;
33
+ const client = await this.connectToApi();
34
+ try {
35
+ if (serviceCapability) {
36
+ const [{ capability }] = await client.emitAndFlattenResponses('appointments.update-role-capability::v2021_06_23', {
37
+ target: {
38
+ organizationId: (_a = this.organizationId) !== null && _a !== void 0 ? _a : 'org id',
39
+ capabilityId: serviceCapability.id,
40
+ },
41
+ payload: Object.assign({}, values),
42
+ });
43
+ return capability;
44
+ }
45
+ else {
46
+ const [{ capability }] = await client.emitAndFlattenResponses('appointments.create-role-capability::v2021_06_23', {
47
+ target: {
48
+ organizationId: (_b = this.organizationId) !== null && _b !== void 0 ? _b : 'org id',
49
+ roleId: this.role.id,
50
+ },
51
+ payload: Object.assign({ serviceId, isEnabled: true }, values),
52
+ });
53
+ return capability;
54
+ }
55
+ }
56
+ catch (err) {
57
+ await this.alert({ message: err.message });
58
+ }
59
+ return;
60
+ }
61
+ getCapabilities() {
62
+ return this.capabilities;
63
+ }
64
+ }
65
+ exports.default = RolesCardViewController;
66
+ RolesCardViewController.id = 'roles-card';
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@sprucelabs/spruce-appointment-utils",
3
+ "description": "",
4
+ "version": "5.1.4",
5
+ "skill": {
6
+ "namespace": "appointments"
7
+ },
8
+ "homepage": "https://github.com/sprucelabsai/spruce-appointments-skill",
9
+ "bugs": {
10
+ "url": "https://github.com/sprucelabsai/spruce-appointments-skill/issues"
11
+ },
12
+ "main": "./build/index-module.js",
13
+ "types": "./build/index-module.d.ts",
14
+ "module": "./build/esm/index-module.js",
15
+ "sideEffects": false,
16
+ "files": [
17
+ "build/index-module.js",
18
+ "build/index-module.d.ts",
19
+ "build/types-module.js",
20
+ "build/types-module.d.ts",
21
+ "build/viewControllers/AbstractCapabilityCardViewController.js",
22
+ "build/viewControllers/AbstractCapabilityCardViewController.d.ts",
23
+ "build/viewControllers/DurationCard.vc.js",
24
+ "build/viewControllers/DurationCard.vc.d.ts",
25
+ "build/viewControllers/DurationList.vc.js",
26
+ "build/viewControllers/DurationList.vc.d.ts",
27
+ "build/viewControllers/EditOverrideDetailsCard.vc.js",
28
+ "build/viewControllers/EditOverrideDetailsCard.vc.d.ts",
29
+ "build/viewControllers/EditTimeBlockTitleCard.vc.js",
30
+ "build/viewControllers/EditTimeBlockTitleCard.vc.d.ts",
31
+ "build/viewControllers/RolesCard.vc.js",
32
+ "build/viewControllers/RolesCard.vc.d.ts",
33
+ "build/esm/index-module.js",
34
+ "build/esm/index-module.d.ts",
35
+ "build/esm/types-module.js",
36
+ "build/esm/types-module.d.ts",
37
+ "build/esm/viewControllers/AbstractCapabilityCardViewController.js",
38
+ "build/esm/viewControllers/AbstractCapabilityCardViewController.d.ts",
39
+ "build/esm/viewControllers/DurationCard.vc.js",
40
+ "build/esm/viewControllers/DurationCard.vc.d.ts",
41
+ "build/esm/viewControllers/DurationList.vc.js",
42
+ "build/esm/viewControllers/DurationList.vc.d.ts",
43
+ "build/esm/viewControllers/EditOverrideDetailsCard.vc.js",
44
+ "build/esm/viewControllers/EditOverrideDetailsCard.vc.d.ts",
45
+ "build/esm/viewControllers/EditTimeBlockTitleCard.vc.js",
46
+ "build/esm/viewControllers/EditTimeBlockTitleCard.vc.d.ts",
47
+ "build/esm/viewControllers/RolesCard.vc.js",
48
+ "build/esm/viewControllers/RolesCard.vc.d.ts"
49
+ ],
50
+ "keywords": [],
51
+ "scripts": {
52
+ "release": "npm publish"
53
+ },
54
+ "dependencies": {
55
+ "@sprucelabs/calendar-utils": "latest",
56
+ "@sprucelabs/heartwood-view-controllers": "latest",
57
+ "@sprucelabs/schema": "latest",
58
+ "@sprucelabs/spruce-event-utils": "latest"
59
+ },
60
+ "engines": {
61
+ "node": "16.x",
62
+ "yarn": "1.x"
63
+ }
64
+ }