@sprucelabs/spruce-location-utils 10.0.1 → 10.0.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.
|
@@ -3,16 +3,10 @@ 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;
|
|
12
6
|
constructor(options) {
|
|
13
7
|
super(options);
|
|
14
8
|
const { id, onDelete, selectedLocationId, footerButtons, currentOrganizationId, onClick, shouldRenderDeleteButtons, header, } = options;
|
|
15
|
-
this.shouldRenderDeleteButtons = shouldRenderDeleteButtons
|
|
9
|
+
this.shouldRenderDeleteButtons = shouldRenderDeleteButtons !== null && shouldRenderDeleteButtons !== void 0 ? shouldRenderDeleteButtons : false;
|
|
16
10
|
this.onDeleteHandler = onDelete;
|
|
17
11
|
this.selectedLocationId = selectedLocationId;
|
|
18
12
|
this.onClickHandler = onClick;
|
|
@@ -30,7 +24,7 @@ class LocationListCardViewController extends heartwood_view_controllers_1.Abstra
|
|
|
30
24
|
columnWidths: this.onClickHandler
|
|
31
25
|
? ['fill']
|
|
32
26
|
: ['content', 'fill'],
|
|
33
|
-
header: header
|
|
27
|
+
header: header !== null && header !== void 0 ? header : {
|
|
34
28
|
title: 'Your locations',
|
|
35
29
|
},
|
|
36
30
|
eventName: 'list-locations::v2020_12_25',
|
|
@@ -99,13 +93,15 @@ class LocationListCardViewController extends heartwood_view_controllers_1.Abstra
|
|
|
99
93
|
await rowVc.setValue('isSelected', true);
|
|
100
94
|
}
|
|
101
95
|
async handleClickLocation(location) {
|
|
96
|
+
var _a;
|
|
102
97
|
if (this.onClickHandler) {
|
|
103
|
-
this.onClickHandler
|
|
98
|
+
(_a = this.onClickHandler) === null || _a === void 0 ? void 0 : _a.call(this, location);
|
|
104
99
|
return;
|
|
105
100
|
}
|
|
106
101
|
await this.selectLocation(location.id);
|
|
107
102
|
}
|
|
108
103
|
async handleDeleteLocation(location) {
|
|
104
|
+
var _a;
|
|
109
105
|
const shouldDelete = await this.confirm({
|
|
110
106
|
title: `Delete ${location.name}?`,
|
|
111
107
|
isDestructive: true,
|
|
@@ -121,7 +117,7 @@ class LocationListCardViewController extends heartwood_view_controllers_1.Abstra
|
|
|
121
117
|
locationId: location.id,
|
|
122
118
|
},
|
|
123
119
|
});
|
|
124
|
-
this.onDeleteHandler
|
|
120
|
+
(_a = this.onDeleteHandler) === null || _a === void 0 ? void 0 : _a.call(this, location);
|
|
125
121
|
this.activeRecordCardVc.deleteRow(location.id);
|
|
126
122
|
}
|
|
127
123
|
catch (err) {
|
|
@@ -145,7 +141,7 @@ class LocationListCardViewController extends heartwood_view_controllers_1.Abstra
|
|
|
145
141
|
return this.activeRecordCardVc.getListVc();
|
|
146
142
|
}
|
|
147
143
|
async load(targetAndPayload) {
|
|
148
|
-
const { target, payload } = targetAndPayload
|
|
144
|
+
const { target, payload } = targetAndPayload !== null && targetAndPayload !== void 0 ? targetAndPayload : {};
|
|
149
145
|
if (target) {
|
|
150
146
|
this.activeRecordCardVc.setTarget(target);
|
|
151
147
|
}
|
|
@@ -161,4 +157,5 @@ class LocationListCardViewController extends heartwood_view_controllers_1.Abstra
|
|
|
161
157
|
return this.activeRecordCardVc.render();
|
|
162
158
|
}
|
|
163
159
|
}
|
|
160
|
+
LocationListCardViewController.id = 'location-list-card';
|
|
164
161
|
exports.default = LocationListCardViewController;
|