@sprucelabs/spruce-location-utils 2.1.0 → 2.1.1
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/tests/utilities/organizationAssert.d.ts +4 -4
- package/build/esm/tests/utilities/organizationAssert.js +13 -13
- package/build/esm/viewControllers/LocationListCard.vc.d.ts +2 -1
- package/build/esm/viewControllers/LocationListCard.vc.js +11 -13
- package/build/tests/utilities/organizationAssert.d.ts +4 -4
- package/build/tests/utilities/organizationAssert.js +13 -13
- package/build/viewControllers/LocationListCard.vc.d.ts +2 -1
- package/build/viewControllers/LocationListCard.vc.js +11 -13
- package/package.json +1 -1
|
@@ -2,15 +2,15 @@ import { SkillViewController } from '@sprucelabs/heartwood-view-controllers';
|
|
|
2
2
|
import { OrganizationFixture, ViewFixture } from '@sprucelabs/spruce-test-fixtures';
|
|
3
3
|
declare const organizationAssert: {
|
|
4
4
|
assertRedirectsToAddOrgIfNoOrgExists(options: {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
views: ViewFixture;
|
|
6
|
+
organizations: OrganizationFixture;
|
|
7
7
|
vc: SkillViewController<any>;
|
|
8
8
|
didAddOrgRedirectDestination: string;
|
|
9
9
|
}): Promise<void>;
|
|
10
10
|
assertDoesNotRedirectToAddAOrgIfOrgExists(options: {
|
|
11
11
|
vc: SkillViewController<any>;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
views: ViewFixture;
|
|
13
|
+
organizations: OrganizationFixture;
|
|
14
14
|
}): Promise<void>;
|
|
15
15
|
};
|
|
16
16
|
export default organizationAssert;
|
|
@@ -15,18 +15,18 @@ const organizationAssert = {
|
|
|
15
15
|
assertRedirectsToAddOrgIfNoOrgExists(options) {
|
|
16
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
assertOptions(options, [
|
|
18
|
-
'
|
|
18
|
+
'views',
|
|
19
19
|
'vc',
|
|
20
|
-
'
|
|
20
|
+
'organizations',
|
|
21
21
|
'didAddOrgRedirectDestination',
|
|
22
22
|
]);
|
|
23
|
-
const {
|
|
24
|
-
yield
|
|
23
|
+
const { views, vc, organizations, didAddOrgRedirectDestination: redirectDestination, } = options;
|
|
24
|
+
yield organizations.deleteAllOrganizations();
|
|
25
25
|
TestRouter.setShouldThrowWhenRedirectingToBadSvc(false);
|
|
26
|
-
const router =
|
|
26
|
+
const router = views.getRouter();
|
|
27
27
|
yield vcAssertUtil.assertActionRedirects({
|
|
28
28
|
router,
|
|
29
|
-
action: () =>
|
|
29
|
+
action: () => views.load(vc),
|
|
30
30
|
destination: {
|
|
31
31
|
id: 'organization.add',
|
|
32
32
|
args: {
|
|
@@ -41,19 +41,19 @@ const organizationAssert = {
|
|
|
41
41
|
},
|
|
42
42
|
assertDoesNotRedirectToAddAOrgIfOrgExists(options) {
|
|
43
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
assertOptions(options, ['
|
|
45
|
-
const { vc,
|
|
46
|
-
yield
|
|
47
|
-
const latest = yield
|
|
44
|
+
assertOptions(options, ['views', 'vc', 'organizations']);
|
|
45
|
+
const { vc, views, organizations } = options;
|
|
46
|
+
yield views.loginAsDemoPerson();
|
|
47
|
+
const latest = yield organizations.getNewestOrganization();
|
|
48
48
|
if (!latest) {
|
|
49
|
-
yield
|
|
49
|
+
yield organizations.seedDemoOrganization();
|
|
50
50
|
}
|
|
51
51
|
let wasHit = false;
|
|
52
|
-
yield
|
|
52
|
+
yield views.getRouter().on('did-redirect', () => {
|
|
53
53
|
wasHit = true;
|
|
54
54
|
});
|
|
55
55
|
TestRouter.setShouldThrowWhenRedirectingToBadSvc(false);
|
|
56
|
-
yield
|
|
56
|
+
yield views.load(vc);
|
|
57
57
|
TestRouter.setShouldThrowWhenRedirectingToBadSvc(true);
|
|
58
58
|
assert.isFalse(wasHit, `I was redirected and didn't expect to be.`);
|
|
59
59
|
});
|
|
@@ -4,7 +4,7 @@ declare type Location = SpruceSchemas.Spruce.v2020_07_22.Location;
|
|
|
4
4
|
declare type Button = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Button;
|
|
5
5
|
export default class LocationListCardViewController extends AbstractViewController<Card> {
|
|
6
6
|
static id: string;
|
|
7
|
-
private
|
|
7
|
+
private onDelete?;
|
|
8
8
|
private selectedLocationId?;
|
|
9
9
|
private onEdit?;
|
|
10
10
|
private activeRecordCardVc;
|
|
@@ -15,6 +15,7 @@ export default class LocationListCardViewController extends AbstractViewControll
|
|
|
15
15
|
selectedLocationId?: string;
|
|
16
16
|
footerButtons?: Button[];
|
|
17
17
|
});
|
|
18
|
+
private ActiveRecordCardVc;
|
|
18
19
|
private buildRow;
|
|
19
20
|
private handleDeleteLocation;
|
|
20
21
|
getCardVc(): import("@sprucelabs/heartwood-view-controllers").CardViewController;
|
|
@@ -13,10 +13,13 @@ export default class LocationListCardViewController extends AbstractViewControll
|
|
|
13
13
|
constructor(options) {
|
|
14
14
|
super(options);
|
|
15
15
|
const { onDelete, selectedLocationId, footerButtons, currentOrganizationId, onEdit, } = options;
|
|
16
|
-
this.
|
|
16
|
+
this.onDelete = onDelete;
|
|
17
17
|
this.selectedLocationId = selectedLocationId;
|
|
18
18
|
this.onEdit = onEdit;
|
|
19
|
-
this.activeRecordCardVc = this.
|
|
19
|
+
this.activeRecordCardVc = this.ActiveRecordCardVc(currentOrganizationId, footerButtons);
|
|
20
|
+
}
|
|
21
|
+
ActiveRecordCardVc(currentOrganizationId, footerButtons) {
|
|
22
|
+
return this.Controller('activeRecordCard', buildActiveRecordCard({
|
|
20
23
|
header: {
|
|
21
24
|
title: 'Your locations',
|
|
22
25
|
},
|
|
@@ -37,6 +40,11 @@ export default class LocationListCardViewController extends AbstractViewControll
|
|
|
37
40
|
buildRow(location) {
|
|
38
41
|
return {
|
|
39
42
|
id: location.id,
|
|
43
|
+
isSelected: this.selectedLocationId === location.id,
|
|
44
|
+
onClick: () => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
var _a;
|
|
46
|
+
return (_a = this.onEdit) === null || _a === void 0 ? void 0 : _a.call(this, location);
|
|
47
|
+
}),
|
|
40
48
|
cells: [
|
|
41
49
|
{
|
|
42
50
|
text: {
|
|
@@ -50,16 +58,6 @@ export default class LocationListCardViewController extends AbstractViewControll
|
|
|
50
58
|
: ``}`,
|
|
51
59
|
},
|
|
52
60
|
},
|
|
53
|
-
this.selectedLocationId !== location.id && {
|
|
54
|
-
button: {
|
|
55
|
-
id: 'edit',
|
|
56
|
-
lineIcon: 'edit-box',
|
|
57
|
-
onClick: () => __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
var _a;
|
|
59
|
-
return (_a = this.onEdit) === null || _a === void 0 ? void 0 : _a.call(this, location);
|
|
60
|
-
}),
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
61
|
{
|
|
64
62
|
button: {
|
|
65
63
|
id: 'delete',
|
|
@@ -92,7 +90,7 @@ export default class LocationListCardViewController extends AbstractViewControll
|
|
|
92
90
|
},
|
|
93
91
|
});
|
|
94
92
|
eventResponseUtil.getFirstResponseOrThrow(results);
|
|
95
|
-
(_a = this.
|
|
93
|
+
(_a = this.onDelete) === null || _a === void 0 ? void 0 : _a.call(this, location);
|
|
96
94
|
this.activeRecordCardVc.deleteRow(location.id);
|
|
97
95
|
}
|
|
98
96
|
catch (err) {
|
|
@@ -2,15 +2,15 @@ import { SkillViewController } from '@sprucelabs/heartwood-view-controllers';
|
|
|
2
2
|
import { OrganizationFixture, ViewFixture } from '@sprucelabs/spruce-test-fixtures';
|
|
3
3
|
declare const organizationAssert: {
|
|
4
4
|
assertRedirectsToAddOrgIfNoOrgExists(options: {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
views: ViewFixture;
|
|
6
|
+
organizations: OrganizationFixture;
|
|
7
7
|
vc: SkillViewController<any>;
|
|
8
8
|
didAddOrgRedirectDestination: string;
|
|
9
9
|
}): Promise<void>;
|
|
10
10
|
assertDoesNotRedirectToAddAOrgIfOrgExists(options: {
|
|
11
11
|
vc: SkillViewController<any>;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
views: ViewFixture;
|
|
13
|
+
organizations: OrganizationFixture;
|
|
14
14
|
}): Promise<void>;
|
|
15
15
|
};
|
|
16
16
|
export default organizationAssert;
|
|
@@ -7,18 +7,18 @@ const test_1 = require("@sprucelabs/test");
|
|
|
7
7
|
const organizationAssert = {
|
|
8
8
|
async assertRedirectsToAddOrgIfNoOrgExists(options) {
|
|
9
9
|
(0, schema_1.assertOptions)(options, [
|
|
10
|
-
'
|
|
10
|
+
'views',
|
|
11
11
|
'vc',
|
|
12
|
-
'
|
|
12
|
+
'organizations',
|
|
13
13
|
'didAddOrgRedirectDestination',
|
|
14
14
|
]);
|
|
15
|
-
const {
|
|
16
|
-
await
|
|
15
|
+
const { views, vc, organizations, didAddOrgRedirectDestination: redirectDestination, } = options;
|
|
16
|
+
await organizations.deleteAllOrganizations();
|
|
17
17
|
spruce_test_fixtures_1.TestRouter.setShouldThrowWhenRedirectingToBadSvc(false);
|
|
18
|
-
const router =
|
|
18
|
+
const router = views.getRouter();
|
|
19
19
|
await heartwood_view_controllers_1.vcAssertUtil.assertActionRedirects({
|
|
20
20
|
router,
|
|
21
|
-
action: () =>
|
|
21
|
+
action: () => views.load(vc),
|
|
22
22
|
destination: {
|
|
23
23
|
id: 'organization.add',
|
|
24
24
|
args: {
|
|
@@ -31,19 +31,19 @@ const organizationAssert = {
|
|
|
31
31
|
spruce_test_fixtures_1.TestRouter.setShouldThrowWhenRedirectingToBadSvc(true);
|
|
32
32
|
},
|
|
33
33
|
async assertDoesNotRedirectToAddAOrgIfOrgExists(options) {
|
|
34
|
-
(0, schema_1.assertOptions)(options, ['
|
|
35
|
-
const { vc,
|
|
36
|
-
await
|
|
37
|
-
const latest = await
|
|
34
|
+
(0, schema_1.assertOptions)(options, ['views', 'vc', 'organizations']);
|
|
35
|
+
const { vc, views, organizations } = options;
|
|
36
|
+
await views.loginAsDemoPerson();
|
|
37
|
+
const latest = await organizations.getNewestOrganization();
|
|
38
38
|
if (!latest) {
|
|
39
|
-
await
|
|
39
|
+
await organizations.seedDemoOrganization();
|
|
40
40
|
}
|
|
41
41
|
let wasHit = false;
|
|
42
|
-
await
|
|
42
|
+
await views.getRouter().on('did-redirect', () => {
|
|
43
43
|
wasHit = true;
|
|
44
44
|
});
|
|
45
45
|
spruce_test_fixtures_1.TestRouter.setShouldThrowWhenRedirectingToBadSvc(false);
|
|
46
|
-
await
|
|
46
|
+
await views.load(vc);
|
|
47
47
|
spruce_test_fixtures_1.TestRouter.setShouldThrowWhenRedirectingToBadSvc(true);
|
|
48
48
|
test_1.assert.isFalse(wasHit, `I was redirected and didn't expect to be.`);
|
|
49
49
|
},
|
|
@@ -4,7 +4,7 @@ declare type Location = SpruceSchemas.Spruce.v2020_07_22.Location;
|
|
|
4
4
|
declare type Button = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Button;
|
|
5
5
|
export default class LocationListCardViewController extends AbstractViewController<Card> {
|
|
6
6
|
static id: string;
|
|
7
|
-
private
|
|
7
|
+
private onDelete?;
|
|
8
8
|
private selectedLocationId?;
|
|
9
9
|
private onEdit?;
|
|
10
10
|
private activeRecordCardVc;
|
|
@@ -15,6 +15,7 @@ export default class LocationListCardViewController extends AbstractViewControll
|
|
|
15
15
|
selectedLocationId?: string;
|
|
16
16
|
footerButtons?: Button[];
|
|
17
17
|
});
|
|
18
|
+
private ActiveRecordCardVc;
|
|
18
19
|
private buildRow;
|
|
19
20
|
private handleDeleteLocation;
|
|
20
21
|
getCardVc(): import("@sprucelabs/heartwood-view-controllers").CardViewController;
|
|
@@ -6,10 +6,13 @@ class LocationListCardViewController extends heartwood_view_controllers_1.Abstra
|
|
|
6
6
|
constructor(options) {
|
|
7
7
|
super(options);
|
|
8
8
|
const { onDelete, selectedLocationId, footerButtons, currentOrganizationId, onEdit, } = options;
|
|
9
|
-
this.
|
|
9
|
+
this.onDelete = onDelete;
|
|
10
10
|
this.selectedLocationId = selectedLocationId;
|
|
11
11
|
this.onEdit = onEdit;
|
|
12
|
-
this.activeRecordCardVc = this.
|
|
12
|
+
this.activeRecordCardVc = this.ActiveRecordCardVc(currentOrganizationId, footerButtons);
|
|
13
|
+
}
|
|
14
|
+
ActiveRecordCardVc(currentOrganizationId, footerButtons) {
|
|
15
|
+
return this.Controller('activeRecordCard', (0, heartwood_view_controllers_1.buildActiveRecordCard)({
|
|
13
16
|
header: {
|
|
14
17
|
title: 'Your locations',
|
|
15
18
|
},
|
|
@@ -30,6 +33,11 @@ class LocationListCardViewController extends heartwood_view_controllers_1.Abstra
|
|
|
30
33
|
buildRow(location) {
|
|
31
34
|
return {
|
|
32
35
|
id: location.id,
|
|
36
|
+
isSelected: this.selectedLocationId === location.id,
|
|
37
|
+
onClick: async () => {
|
|
38
|
+
var _a;
|
|
39
|
+
return (_a = this.onEdit) === null || _a === void 0 ? void 0 : _a.call(this, location);
|
|
40
|
+
},
|
|
33
41
|
cells: [
|
|
34
42
|
{
|
|
35
43
|
text: {
|
|
@@ -43,16 +51,6 @@ class LocationListCardViewController extends heartwood_view_controllers_1.Abstra
|
|
|
43
51
|
: ``}`,
|
|
44
52
|
},
|
|
45
53
|
},
|
|
46
|
-
this.selectedLocationId !== location.id && {
|
|
47
|
-
button: {
|
|
48
|
-
id: 'edit',
|
|
49
|
-
lineIcon: 'edit-box',
|
|
50
|
-
onClick: async () => {
|
|
51
|
-
var _a;
|
|
52
|
-
return (_a = this.onEdit) === null || _a === void 0 ? void 0 : _a.call(this, location);
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
54
|
{
|
|
57
55
|
button: {
|
|
58
56
|
id: 'delete',
|
|
@@ -84,7 +82,7 @@ class LocationListCardViewController extends heartwood_view_controllers_1.Abstra
|
|
|
84
82
|
},
|
|
85
83
|
});
|
|
86
84
|
spruce_event_utils_1.eventResponseUtil.getFirstResponseOrThrow(results);
|
|
87
|
-
(_a = this.
|
|
85
|
+
(_a = this.onDelete) === null || _a === void 0 ? void 0 : _a.call(this, location);
|
|
88
86
|
this.activeRecordCardVc.deleteRow(location.id);
|
|
89
87
|
}
|
|
90
88
|
catch (err) {
|