@sprucelabs/spruce-location-utils 9.4.142 → 10.0.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/build/esm/viewControllers/LocationListCard.vc.d.ts +2 -2
- package/build/esm/viewControllers/LocationListCard.vc.js +3 -1
- package/build/tests/locationListCardAssert.js +1 -0
- package/build/viewControllers/LocationListCard.vc.d.ts +2 -2
- package/build/viewControllers/LocationListCard.vc.js +14 -9
- package/package.json +1 -1
|
@@ -23,7 +23,7 @@ export default class LocationListCardViewController extends AbstractViewControll
|
|
|
23
23
|
}
|
|
24
24
|
type OnDeleteHandler = (location: Location) => void;
|
|
25
25
|
type OnEditHandler = (location: Location) => void;
|
|
26
|
-
export
|
|
26
|
+
export interface LocationListCardViewControllerOptions {
|
|
27
27
|
onDelete?: OnDeleteHandler;
|
|
28
28
|
onClick?: OnEditHandler;
|
|
29
29
|
currentOrganizationId?: string;
|
|
@@ -32,6 +32,6 @@ export type LocationListCardViewControllerOptions = {
|
|
|
32
32
|
shouldRenderDeleteButtons?: boolean;
|
|
33
33
|
header?: CardHeader;
|
|
34
34
|
id?: string;
|
|
35
|
-
}
|
|
35
|
+
}
|
|
36
36
|
export type LocationListLoadOptions = SpruceSchemas.Mercury.v2020_12_25.ListLocationsEmitTargetAndPayload;
|
|
37
37
|
export {};
|
|
@@ -28,7 +28,9 @@ class LocationListCardViewController extends AbstractViewController {
|
|
|
28
28
|
const { currentOrganizationId, footerButtons, id, header } = options;
|
|
29
29
|
return this.Controller('activeRecordCard', buildActiveRecordCard({
|
|
30
30
|
id,
|
|
31
|
-
columnWidths: this.onClickHandler
|
|
31
|
+
columnWidths: this.onClickHandler
|
|
32
|
+
? ['fill']
|
|
33
|
+
: ['content', 'fill'],
|
|
32
34
|
header: header !== null && header !== void 0 ? header : {
|
|
33
35
|
title: 'Your locations',
|
|
34
36
|
},
|
|
@@ -23,7 +23,7 @@ export default class LocationListCardViewController extends AbstractViewControll
|
|
|
23
23
|
}
|
|
24
24
|
type OnDeleteHandler = (location: Location) => void;
|
|
25
25
|
type OnEditHandler = (location: Location) => void;
|
|
26
|
-
export
|
|
26
|
+
export interface LocationListCardViewControllerOptions {
|
|
27
27
|
onDelete?: OnDeleteHandler;
|
|
28
28
|
onClick?: OnEditHandler;
|
|
29
29
|
currentOrganizationId?: string;
|
|
@@ -32,6 +32,6 @@ export type LocationListCardViewControllerOptions = {
|
|
|
32
32
|
shouldRenderDeleteButtons?: boolean;
|
|
33
33
|
header?: CardHeader;
|
|
34
34
|
id?: string;
|
|
35
|
-
}
|
|
35
|
+
}
|
|
36
36
|
export type LocationListLoadOptions = SpruceSchemas.Mercury.v2020_12_25.ListLocationsEmitTargetAndPayload;
|
|
37
37
|
export {};
|
|
@@ -3,10 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
|
|
4
4
|
const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
|
|
5
5
|
class LocationListCardViewController extends heartwood_view_controllers_1.AbstractViewController {
|
|
6
|
+
static id = 'location-list-card';
|
|
7
|
+
onDeleteHandler;
|
|
8
|
+
selectedLocationId;
|
|
9
|
+
onClickHandler;
|
|
10
|
+
activeRecordCardVc;
|
|
11
|
+
shouldRenderDeleteButtons;
|
|
6
12
|
constructor(options) {
|
|
7
13
|
super(options);
|
|
8
14
|
const { id, onDelete, selectedLocationId, footerButtons, currentOrganizationId, onClick, shouldRenderDeleteButtons, header, } = options;
|
|
9
|
-
this.shouldRenderDeleteButtons = shouldRenderDeleteButtons
|
|
15
|
+
this.shouldRenderDeleteButtons = shouldRenderDeleteButtons ?? false;
|
|
10
16
|
this.onDeleteHandler = onDelete;
|
|
11
17
|
this.selectedLocationId = selectedLocationId;
|
|
12
18
|
this.onClickHandler = onClick;
|
|
@@ -21,8 +27,10 @@ class LocationListCardViewController extends heartwood_view_controllers_1.Abstra
|
|
|
21
27
|
const { currentOrganizationId, footerButtons, id, header } = options;
|
|
22
28
|
return this.Controller('activeRecordCard', (0, heartwood_view_controllers_1.buildActiveRecordCard)({
|
|
23
29
|
id,
|
|
24
|
-
columnWidths: this.onClickHandler
|
|
25
|
-
|
|
30
|
+
columnWidths: this.onClickHandler
|
|
31
|
+
? ['fill']
|
|
32
|
+
: ['content', 'fill'],
|
|
33
|
+
header: header ?? {
|
|
26
34
|
title: 'Your locations',
|
|
27
35
|
},
|
|
28
36
|
eventName: 'list-locations::v2020_12_25',
|
|
@@ -91,15 +99,13 @@ class LocationListCardViewController extends heartwood_view_controllers_1.Abstra
|
|
|
91
99
|
await rowVc.setValue('isSelected', true);
|
|
92
100
|
}
|
|
93
101
|
async handleClickLocation(location) {
|
|
94
|
-
var _a;
|
|
95
102
|
if (this.onClickHandler) {
|
|
96
|
-
|
|
103
|
+
this.onClickHandler?.(location);
|
|
97
104
|
return;
|
|
98
105
|
}
|
|
99
106
|
await this.selectLocation(location.id);
|
|
100
107
|
}
|
|
101
108
|
async handleDeleteLocation(location) {
|
|
102
|
-
var _a;
|
|
103
109
|
const shouldDelete = await this.confirm({
|
|
104
110
|
title: `Delete ${location.name}?`,
|
|
105
111
|
isDestructive: true,
|
|
@@ -115,7 +121,7 @@ class LocationListCardViewController extends heartwood_view_controllers_1.Abstra
|
|
|
115
121
|
locationId: location.id,
|
|
116
122
|
},
|
|
117
123
|
});
|
|
118
|
-
|
|
124
|
+
this.onDeleteHandler?.(location);
|
|
119
125
|
this.activeRecordCardVc.deleteRow(location.id);
|
|
120
126
|
}
|
|
121
127
|
catch (err) {
|
|
@@ -139,7 +145,7 @@ class LocationListCardViewController extends heartwood_view_controllers_1.Abstra
|
|
|
139
145
|
return this.activeRecordCardVc.getListVc();
|
|
140
146
|
}
|
|
141
147
|
async load(targetAndPayload) {
|
|
142
|
-
const { target, payload } = targetAndPayload
|
|
148
|
+
const { target, payload } = targetAndPayload ?? {};
|
|
143
149
|
if (target) {
|
|
144
150
|
this.activeRecordCardVc.setTarget(target);
|
|
145
151
|
}
|
|
@@ -155,5 +161,4 @@ class LocationListCardViewController extends heartwood_view_controllers_1.Abstra
|
|
|
155
161
|
return this.activeRecordCardVc.render();
|
|
156
162
|
}
|
|
157
163
|
}
|
|
158
|
-
LocationListCardViewController.id = 'location-list-card';
|
|
159
164
|
exports.default = LocationListCardViewController;
|