@sprucelabs/spruce-calendar-components 38.1.10 → 38.1.12

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.
@@ -10,6 +10,7 @@ export default class VenueSelectionToolViewController extends AbstractViewContro
10
10
  private isLoaded;
11
11
  constructor(options: ViewControllerOptions & CalendarToolOptions);
12
12
  private VenueListVc;
13
+ private handleSelectVenueFromList;
13
14
  private get router();
14
15
  private CardVc;
15
16
  handleUpdateContext(context: CalendarToolBeltContext): Promise<void>;
@@ -21,11 +21,14 @@ class VenueSelectionToolViewController extends AbstractViewController {
21
21
  VenueListVc() {
22
22
  return this.Controller('calendar.venues-list', {
23
23
  router: this.router,
24
- onSelect: (venue) => __awaiter(this, void 0, void 0, function* () {
25
- yield this.updateContextHandler({
26
- 'event.venue': venue,
27
- });
28
- }),
24
+ onSelect: this.handleSelectVenueFromList.bind(this),
25
+ });
26
+ }
27
+ handleSelectVenueFromList(venue) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ yield this.updateContextHandler({
30
+ 'event.venue': venue,
31
+ });
29
32
  });
30
33
  }
31
34
  get router() {
@@ -47,10 +50,9 @@ class VenueSelectionToolViewController extends AbstractViewController {
47
50
  }
48
51
  handleUpdateContext(context) {
49
52
  return __awaiter(this, void 0, void 0, function* () {
50
- var _a;
51
- const provider = (_a = context.event.venue) === null || _a === void 0 ? void 0 : _a.provider;
52
- if (provider && this.isLoaded) {
53
- yield this.venueListVc.selectVenue(provider);
53
+ const venue = context.event.venue;
54
+ if (venue && this.isLoaded) {
55
+ yield this.venueListVc.selectVenue(venue);
54
56
  }
55
57
  });
56
58
  }
@@ -63,7 +65,7 @@ class VenueSelectionToolViewController extends AbstractViewController {
63
65
  organizationId: organization.id,
64
66
  });
65
67
  if ((_a = this.venue) === null || _a === void 0 ? void 0 : _a.provider) {
66
- yield this.venueListVc.selectVenue(this.venue.provider);
68
+ yield this.venueListVc.selectVenue(this.venue);
67
69
  }
68
70
  });
69
71
  }
@@ -5,22 +5,28 @@ export default class VenuesListViewController extends AbstractViewController<Lis
5
5
  protected listVc: ListViewController;
6
6
  private venues;
7
7
  protected onSelectHandler?: (venue: Venue) => void;
8
- private router;
8
+ private router?;
9
9
  private isLoaded;
10
+ private selectedVenue?;
10
11
  constructor(options: ViewControllerOptions & VenuesListConstructorOptions);
11
12
  private ListVc;
12
13
  load(options: VenuesListLoadOptions): Promise<void>;
13
14
  private populateList;
15
+ private renderDetailsRow;
14
16
  private renderVenueRow;
15
- selectVenue(provider: string): Promise<void>;
17
+ private renderVenueLabelCell;
18
+ selectVenue(venue: Venue): Promise<void>;
19
+ private optionallyRenderJoinUrlCell;
20
+ private isSelected;
21
+ private renderCheckboxCell;
16
22
  private handleOnClickJoinUrl;
17
- private handleChange;
23
+ private handleClickedCheckbox;
18
24
  render(): List;
19
25
  }
20
26
  export interface VenuesListLoadOptions {
21
27
  organizationId: string;
22
28
  }
23
29
  export interface VenuesListConstructorOptions {
24
- router: Router;
30
+ router?: Router;
25
31
  onSelect?: (venue: Venue) => void;
26
32
  }
@@ -21,6 +21,7 @@ class VenuesListViewController extends AbstractViewController {
21
21
  ListVc() {
22
22
  return this.Controller('list', {
23
23
  id: 'venues-list',
24
+ columnWidths: ['content', 'fill'],
24
25
  });
25
26
  }
26
27
  load(options) {
@@ -51,70 +52,91 @@ class VenuesListViewController extends AbstractViewController {
51
52
  });
52
53
  }
53
54
  populateList() {
54
- this.venues.forEach((venue) => this.listVc.addRow(this.renderVenueRow(venue)));
55
+ const rows = [];
56
+ this.venues.forEach((venue) => {
57
+ var _a;
58
+ rows.push(this.renderVenueRow(venue));
59
+ if (this.isSelected(venue) && ((_a = this.selectedVenue) === null || _a === void 0 ? void 0 : _a.details)) {
60
+ rows.push(this.renderDetailsRow());
61
+ }
62
+ });
63
+ this.listVc.setRows(rows);
55
64
  }
56
- renderVenueRow(venue) {
65
+ renderDetailsRow() {
66
+ var _a;
57
67
  return {
58
- id: venue.provider,
68
+ id: 'details',
59
69
  cells: [
60
70
  {
61
- checkboxInput: {
62
- name: 'isSelected',
63
- value: false,
64
- onChange: (value) => {
65
- if (value) {
66
- this.handleChange(venue);
67
- }
68
- },
71
+ text: {
72
+ markdown: (_a = this.selectedVenue) === null || _a === void 0 ? void 0 : _a.details,
69
73
  },
70
74
  },
71
- { text: { content: venue.label } },
72
- (venue.joinUrl
73
- ? {
74
- button: {
75
- id: `joinUrl`,
76
- label: venue.label,
77
- lineIcon: 'link-angle',
78
- onClick: this.handleOnClickJoinUrl.bind(this, venue.joinUrl),
79
- },
80
- }
81
- : {}),
82
75
  ],
83
76
  };
84
77
  }
85
- selectVenue(provider) {
78
+ renderVenueRow(venue) {
79
+ return {
80
+ id: venue.provider,
81
+ cells: [
82
+ this.renderCheckboxCell(venue),
83
+ this.renderVenueLabelCell(venue),
84
+ this.optionallyRenderJoinUrlCell(venue),
85
+ ].filter(Boolean),
86
+ };
87
+ }
88
+ renderVenueLabelCell(venue) {
89
+ return { text: { content: venue.label } };
90
+ }
91
+ selectVenue(venue) {
86
92
  return __awaiter(this, void 0, void 0, function* () {
87
- yield this.listVc.getRowVc(provider).setValue('isSelected', true);
93
+ this.selectedVenue = venue;
94
+ this.populateList();
88
95
  });
89
96
  }
97
+ optionallyRenderJoinUrlCell(venue) {
98
+ var _a;
99
+ const joinUrl = this.isSelected(venue) && ((_a = this.selectedVenue) === null || _a === void 0 ? void 0 : _a.joinUrl);
100
+ return (joinUrl
101
+ ? {
102
+ button: {
103
+ id: `joinUrl`,
104
+ lineIcon: 'link-angle',
105
+ onClick: this.handleOnClickJoinUrl.bind(this, joinUrl),
106
+ },
107
+ }
108
+ : null);
109
+ }
110
+ isSelected(venue) {
111
+ var _a;
112
+ return ((_a = this.selectedVenue) === null || _a === void 0 ? void 0 : _a.provider) === venue.provider;
113
+ }
114
+ renderCheckboxCell(venue) {
115
+ return {
116
+ checkboxInput: {
117
+ name: 'isSelected',
118
+ value: this.isSelected(venue),
119
+ onChange: (value) => {
120
+ if (value) {
121
+ this.handleClickedCheckbox(venue);
122
+ }
123
+ },
124
+ },
125
+ };
126
+ }
90
127
  handleOnClickJoinUrl(joinUrl) {
91
128
  return __awaiter(this, void 0, void 0, function* () {
92
- yield this.router.redirect(joinUrl);
129
+ var _a;
130
+ yield ((_a = this.router) === null || _a === void 0 ? void 0 : _a.redirect(joinUrl));
93
131
  });
94
132
  }
95
- handleChange(venue) {
133
+ handleClickedCheckbox(venue) {
96
134
  var _a;
97
135
  this.venues.forEach((v) => __awaiter(this, void 0, void 0, function* () {
98
136
  if (v.provider === venue.provider) {
99
- if (venue.details) {
100
- const index = this.listVc
101
- .getRowVcs()
102
- .findIndex((r) => r.getId() === v.provider);
103
- this.listVc.addRow({
104
- id: 'details',
105
- atIndex: index + 1,
106
- cells: [
107
- {
108
- text: {
109
- markdown: venue.details,
110
- },
111
- },
112
- ],
113
- });
114
- }
115
137
  return;
116
138
  }
117
- yield this.listVc.getRowVc(v.provider).setValue('isSelected', false);
139
+ yield this.listVc.setValue(v.provider, 'isSelected', false);
118
140
  }));
119
141
  (_a = this.onSelectHandler) === null || _a === void 0 ? void 0 : _a.call(this, venue);
120
142
  }
@@ -10,6 +10,7 @@ export default class VenueSelectionToolViewController extends AbstractViewContro
10
10
  private isLoaded;
11
11
  constructor(options: ViewControllerOptions & CalendarToolOptions);
12
12
  private VenueListVc;
13
+ private handleSelectVenueFromList;
13
14
  private get router();
14
15
  private CardVc;
15
16
  handleUpdateContext(context: CalendarToolBeltContext): Promise<void>;
@@ -14,11 +14,12 @@ class VenueSelectionToolViewController extends heartwood_view_controllers_1.Abst
14
14
  VenueListVc() {
15
15
  return this.Controller('calendar.venues-list', {
16
16
  router: this.router,
17
- onSelect: async (venue) => {
18
- await this.updateContextHandler({
19
- 'event.venue': venue,
20
- });
21
- },
17
+ onSelect: this.handleSelectVenueFromList.bind(this),
18
+ });
19
+ }
20
+ async handleSelectVenueFromList(venue) {
21
+ await this.updateContextHandler({
22
+ 'event.venue': venue,
22
23
  });
23
24
  }
24
25
  get router() {
@@ -39,9 +40,9 @@ class VenueSelectionToolViewController extends heartwood_view_controllers_1.Abst
39
40
  });
40
41
  }
41
42
  async handleUpdateContext(context) {
42
- const provider = context.event.venue?.provider;
43
- if (provider && this.isLoaded) {
44
- await this.venueListVc.selectVenue(provider);
43
+ const venue = context.event.venue;
44
+ if (venue && this.isLoaded) {
45
+ await this.venueListVc.selectVenue(venue);
45
46
  }
46
47
  }
47
48
  async load() {
@@ -51,7 +52,7 @@ class VenueSelectionToolViewController extends heartwood_view_controllers_1.Abst
51
52
  organizationId: organization.id,
52
53
  });
53
54
  if (this.venue?.provider) {
54
- await this.venueListVc.selectVenue(this.venue.provider);
55
+ await this.venueListVc.selectVenue(this.venue);
55
56
  }
56
57
  }
57
58
  get event() {
@@ -5,22 +5,28 @@ export default class VenuesListViewController extends AbstractViewController<Lis
5
5
  protected listVc: ListViewController;
6
6
  private venues;
7
7
  protected onSelectHandler?: (venue: Venue) => void;
8
- private router;
8
+ private router?;
9
9
  private isLoaded;
10
+ private selectedVenue?;
10
11
  constructor(options: ViewControllerOptions & VenuesListConstructorOptions);
11
12
  private ListVc;
12
13
  load(options: VenuesListLoadOptions): Promise<void>;
13
14
  private populateList;
15
+ private renderDetailsRow;
14
16
  private renderVenueRow;
15
- selectVenue(provider: string): Promise<void>;
17
+ private renderVenueLabelCell;
18
+ selectVenue(venue: Venue): Promise<void>;
19
+ private optionallyRenderJoinUrlCell;
20
+ private isSelected;
21
+ private renderCheckboxCell;
16
22
  private handleOnClickJoinUrl;
17
- private handleChange;
23
+ private handleClickedCheckbox;
18
24
  render(): List;
19
25
  }
20
26
  export interface VenuesListLoadOptions {
21
27
  organizationId: string;
22
28
  }
23
29
  export interface VenuesListConstructorOptions {
24
- router: Router;
30
+ router?: Router;
25
31
  onSelect?: (venue: Venue) => void;
26
32
  }
@@ -14,6 +14,7 @@ class VenuesListViewController extends heartwood_view_controllers_1.AbstractView
14
14
  ListVc() {
15
15
  return this.Controller('list', {
16
16
  id: 'venues-list',
17
+ columnWidths: ['content', 'fill'],
17
18
  });
18
19
  }
19
20
  async load(options) {
@@ -42,65 +43,81 @@ class VenuesListViewController extends heartwood_view_controllers_1.AbstractView
42
43
  this.triggerRender();
43
44
  }
44
45
  populateList() {
45
- this.venues.forEach((venue) => this.listVc.addRow(this.renderVenueRow(venue)));
46
+ const rows = [];
47
+ this.venues.forEach((venue) => {
48
+ rows.push(this.renderVenueRow(venue));
49
+ if (this.isSelected(venue) && this.selectedVenue?.details) {
50
+ rows.push(this.renderDetailsRow());
51
+ }
52
+ });
53
+ this.listVc.setRows(rows);
46
54
  }
47
- renderVenueRow(venue) {
55
+ renderDetailsRow() {
48
56
  return {
49
- id: venue.provider,
57
+ id: 'details',
50
58
  cells: [
51
59
  {
52
- checkboxInput: {
53
- name: 'isSelected',
54
- value: false,
55
- onChange: (value) => {
56
- if (value) {
57
- this.handleChange(venue);
58
- }
59
- },
60
+ text: {
61
+ markdown: this.selectedVenue?.details,
60
62
  },
61
63
  },
62
- { text: { content: venue.label } },
63
- (venue.joinUrl
64
- ? {
65
- button: {
66
- id: `joinUrl`,
67
- label: venue.label,
68
- lineIcon: 'link-angle',
69
- onClick: this.handleOnClickJoinUrl.bind(this, venue.joinUrl),
70
- },
71
- }
72
- : {}),
73
64
  ],
74
65
  };
75
66
  }
76
- async selectVenue(provider) {
77
- await this.listVc.getRowVc(provider).setValue('isSelected', true);
67
+ renderVenueRow(venue) {
68
+ return {
69
+ id: venue.provider,
70
+ cells: [
71
+ this.renderCheckboxCell(venue),
72
+ this.renderVenueLabelCell(venue),
73
+ this.optionallyRenderJoinUrlCell(venue),
74
+ ].filter(Boolean),
75
+ };
76
+ }
77
+ renderVenueLabelCell(venue) {
78
+ return { text: { content: venue.label } };
79
+ }
80
+ async selectVenue(venue) {
81
+ this.selectedVenue = venue;
82
+ this.populateList();
83
+ }
84
+ optionallyRenderJoinUrlCell(venue) {
85
+ const joinUrl = this.isSelected(venue) && this.selectedVenue?.joinUrl;
86
+ return (joinUrl
87
+ ? {
88
+ button: {
89
+ id: `joinUrl`,
90
+ lineIcon: 'link-angle',
91
+ onClick: this.handleOnClickJoinUrl.bind(this, joinUrl),
92
+ },
93
+ }
94
+ : null);
95
+ }
96
+ isSelected(venue) {
97
+ return this.selectedVenue?.provider === venue.provider;
98
+ }
99
+ renderCheckboxCell(venue) {
100
+ return {
101
+ checkboxInput: {
102
+ name: 'isSelected',
103
+ value: this.isSelected(venue),
104
+ onChange: (value) => {
105
+ if (value) {
106
+ this.handleClickedCheckbox(venue);
107
+ }
108
+ },
109
+ },
110
+ };
78
111
  }
79
112
  async handleOnClickJoinUrl(joinUrl) {
80
- await this.router.redirect(joinUrl);
113
+ await this.router?.redirect(joinUrl);
81
114
  }
82
- handleChange(venue) {
115
+ handleClickedCheckbox(venue) {
83
116
  this.venues.forEach(async (v) => {
84
117
  if (v.provider === venue.provider) {
85
- if (venue.details) {
86
- const index = this.listVc
87
- .getRowVcs()
88
- .findIndex((r) => r.getId() === v.provider);
89
- this.listVc.addRow({
90
- id: 'details',
91
- atIndex: index + 1,
92
- cells: [
93
- {
94
- text: {
95
- markdown: venue.details,
96
- },
97
- },
98
- ],
99
- });
100
- }
101
118
  return;
102
119
  }
103
- await this.listVc.getRowVc(v.provider).setValue('isSelected', false);
120
+ await this.listVc.setValue(v.provider, 'isSelected', false);
104
121
  });
105
122
  this.onSelectHandler?.(venue);
106
123
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-calendar-components",
3
3
  "description": "Calendar components for working with calendars and Sprucebot.",
4
- "version": "38.1.10",
4
+ "version": "38.1.12",
5
5
  "skill": {
6
6
  "namespace": "calendar"
7
7
  },