@sprucelabs/spruce-organization-utils 0.8.5 → 1.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/index-module.d.ts +2 -1
- package/build/esm/index-module.js +2 -1
- package/build/esm/types-module.d.ts +9 -0
- package/build/esm/types-module.js +1 -0
- package/build/index-module.d.ts +2 -1
- package/build/index-module.js +13 -2
- package/build/types-module.d.ts +9 -0
- package/build/types-module.js +2 -0
- package/package.json +7 -3
- package/build/esm/viewControllers/OrgListCard.vc.d.ts +0 -29
- package/build/esm/viewControllers/OrgListCard.vc.js +0 -112
- package/build/viewControllers/OrgListCard.vc.d.ts +0 -29
- package/build/viewControllers/OrgListCard.vc.js +0 -100
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default as OrgListCardViewController } from './viewControllers/
|
|
1
|
+
export { default as OrgListCardViewController } from './viewControllers/OrganizationListCard.vc';
|
|
2
|
+
export * from './types-module';
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default as OrgListCardViewController } from './viewControllers/
|
|
1
|
+
export { default as OrgListCardViewController } from './viewControllers/OrganizationListCard.vc.js';
|
|
2
|
+
export * from './types-module.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import OrganizationListCardViewController, { OrganizationListCardViewControllerOptions } from './viewControllers/OrganizationListCard.vc';
|
|
2
|
+
declare module '@sprucelabs/heartwood-view-controllers/build/types/heartwood.types' {
|
|
3
|
+
interface ViewControllerMap {
|
|
4
|
+
organizationListCard: OrganizationListCardViewController;
|
|
5
|
+
}
|
|
6
|
+
interface ViewControllerOptionsMap {
|
|
7
|
+
organizationListCard: OrganizationListCardViewControllerOptions;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/index-module.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default as OrgListCardViewController } from './viewControllers/
|
|
1
|
+
export { default as OrgListCardViewController } from './viewControllers/OrganizationListCard.vc';
|
|
2
|
+
export * from './types-module';
|
package/build/index-module.js
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
2
12
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
13
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
14
|
};
|
|
5
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
16
|
exports.OrgListCardViewController = void 0;
|
|
7
|
-
var
|
|
8
|
-
Object.defineProperty(exports, "OrgListCardViewController", { enumerable: true, get: function () { return __importDefault(
|
|
17
|
+
var OrganizationListCard_vc_1 = require("./viewControllers/OrganizationListCard.vc");
|
|
18
|
+
Object.defineProperty(exports, "OrgListCardViewController", { enumerable: true, get: function () { return __importDefault(OrganizationListCard_vc_1).default; } });
|
|
19
|
+
__exportStar(require("./types-module"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import OrganizationListCardViewController, { OrganizationListCardViewControllerOptions } from './viewControllers/OrganizationListCard.vc';
|
|
2
|
+
declare module '@sprucelabs/heartwood-view-controllers/build/types/heartwood.types' {
|
|
3
|
+
interface ViewControllerMap {
|
|
4
|
+
organizationListCard: OrganizationListCardViewController;
|
|
5
|
+
}
|
|
6
|
+
interface ViewControllerOptionsMap {
|
|
7
|
+
organizationListCard: OrganizationListCardViewControllerOptions;
|
|
8
|
+
}
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sprucelabs/spruce-organization-utils",
|
|
3
3
|
"description": "Support for working with organizations and Sprucebot. 📈",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"skill": {
|
|
6
6
|
"namespace": "organization"
|
|
7
7
|
},
|
|
@@ -21,7 +21,11 @@
|
|
|
21
21
|
"build/esm/index-module.js",
|
|
22
22
|
"build/esm/index-module.d.ts",
|
|
23
23
|
"build/esm/viewControllers/OrgListCard.vc.js",
|
|
24
|
-
"build/esm/viewControllers/OrgListCard.vc.d.ts"
|
|
24
|
+
"build/esm/viewControllers/OrgListCard.vc.d.ts",
|
|
25
|
+
"build/types-module.js",
|
|
26
|
+
"build/types-module.d.ts",
|
|
27
|
+
"build/esm/types-module.js",
|
|
28
|
+
"build/esm/types-module.d.ts"
|
|
25
29
|
],
|
|
26
30
|
"keywords": [],
|
|
27
31
|
"scripts": {
|
|
@@ -34,4 +38,4 @@
|
|
|
34
38
|
"node": "16.x",
|
|
35
39
|
"yarn": "1.x"
|
|
36
40
|
}
|
|
37
|
-
}
|
|
41
|
+
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { AbstractViewController, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
-
declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
3
|
-
declare type Organization = SpruceSchemas.Spruce.v2020_07_22.Organization;
|
|
4
|
-
declare type Button = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Button;
|
|
5
|
-
declare type Row = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.ListRow;
|
|
6
|
-
declare type OnDeleteHandler = (organization: Organization) => void | Promise<void>;
|
|
7
|
-
declare type OnEditHandler = (organization: Organization) => void | Promise<void>;
|
|
8
|
-
export default class OrgListCardViewController extends AbstractViewController<Card> {
|
|
9
|
-
static id: string;
|
|
10
|
-
private activeRecordCardVc;
|
|
11
|
-
private onDelete;
|
|
12
|
-
private onEdit?;
|
|
13
|
-
private selectedOrgId?;
|
|
14
|
-
constructor(options: {
|
|
15
|
-
onDelete?: OnDeleteHandler;
|
|
16
|
-
onEdit?: OnEditHandler;
|
|
17
|
-
footerButtons?: Button[];
|
|
18
|
-
selectedOrgId?: string;
|
|
19
|
-
} & ViewControllerOptions);
|
|
20
|
-
private ActiveRecordCardVc;
|
|
21
|
-
private handleClickDeleteOrg;
|
|
22
|
-
buildRow(org: Organization): Row;
|
|
23
|
-
handleDeletOrg(org: SpruceSchemas.Spruce.v2020_07_22.Organization): Promise<void>;
|
|
24
|
-
load(): Promise<void>;
|
|
25
|
-
getListVc(): import("@sprucelabs/heartwood-view-controllers").ListViewController;
|
|
26
|
-
getCardVc(): import("@sprucelabs/heartwood-view-controllers").CardViewController;
|
|
27
|
-
render(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
28
|
-
}
|
|
29
|
-
export {};
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { AbstractViewController, buildActiveRecordCard, } from '@sprucelabs/heartwood-view-controllers';
|
|
11
|
-
export default class OrgListCardViewController extends AbstractViewController {
|
|
12
|
-
constructor(options) {
|
|
13
|
-
super(options);
|
|
14
|
-
this.onDelete = options.onDelete;
|
|
15
|
-
this.onEdit = options.onEdit;
|
|
16
|
-
this.selectedOrgId = options.selectedOrgId;
|
|
17
|
-
this.activeRecordCardVc = this.ActiveRecordCardVc(options);
|
|
18
|
-
}
|
|
19
|
-
ActiveRecordCardVc(options) {
|
|
20
|
-
return this.Controller('activeRecordCard', buildActiveRecordCard({
|
|
21
|
-
eventName: 'list-organizations::v2020_12_25',
|
|
22
|
-
responseKey: 'organizations',
|
|
23
|
-
columnWidths: ['fill'],
|
|
24
|
-
shouldRenderRowDividers: true,
|
|
25
|
-
rowTransformer: this.buildRow.bind(this),
|
|
26
|
-
payload: {
|
|
27
|
-
shouldOnlyShowMine: true,
|
|
28
|
-
},
|
|
29
|
-
header: {
|
|
30
|
-
title: 'Your organizations',
|
|
31
|
-
subtitle: 'Each of your brands, companies, or teams are here! 👇',
|
|
32
|
-
},
|
|
33
|
-
footer: {
|
|
34
|
-
buttons: options.footerButtons,
|
|
35
|
-
},
|
|
36
|
-
}));
|
|
37
|
-
}
|
|
38
|
-
handleClickDeleteOrg(org) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
const shouldDelete = yield this.confirm({
|
|
41
|
-
title: `Delete ${org.name}`,
|
|
42
|
-
isDestructive: true,
|
|
43
|
-
});
|
|
44
|
-
if (!shouldDelete) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
yield this.handleDeletOrg(org);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
buildRow(org) {
|
|
51
|
-
return {
|
|
52
|
-
id: org.id,
|
|
53
|
-
isSelected: this.selectedOrgId === org.id,
|
|
54
|
-
onClick: () => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
var _a;
|
|
56
|
-
yield ((_a = this.onEdit) === null || _a === void 0 ? void 0 : _a.call(this, org));
|
|
57
|
-
}),
|
|
58
|
-
//@ts-ignore
|
|
59
|
-
cells: [
|
|
60
|
-
{
|
|
61
|
-
text: {
|
|
62
|
-
content: org.name,
|
|
63
|
-
},
|
|
64
|
-
subText: {
|
|
65
|
-
content: `${org.address
|
|
66
|
-
? `${org.address.street1}${org.address.street2 ? ` ${org.address.street2}` : ``} ${org.address.city} ${org.address.zip}`
|
|
67
|
-
: ``}`,
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
button: {
|
|
72
|
-
type: 'destructive',
|
|
73
|
-
lineIcon: 'delete',
|
|
74
|
-
onClick: () => __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
yield this.handleClickDeleteOrg(org);
|
|
76
|
-
}),
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
].filter((b) => !!b),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
handleDeletOrg(org) {
|
|
83
|
-
var _a;
|
|
84
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
yield ((_a = this.onDelete) === null || _a === void 0 ? void 0 : _a.call(this, org));
|
|
86
|
-
this.activeRecordCardVc.deleteRow(org.id);
|
|
87
|
-
this.activeRecordCardVc.setIsBusy(true);
|
|
88
|
-
const client = yield this.connectToApi();
|
|
89
|
-
yield client.emit('delete-organization::v2020_12_25', {
|
|
90
|
-
target: {
|
|
91
|
-
organizationId: org.id,
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
this.activeRecordCardVc.setIsBusy(false);
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
load() {
|
|
98
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
-
yield this.activeRecordCardVc.load();
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
getListVc() {
|
|
103
|
-
return this.activeRecordCardVc.getListVc();
|
|
104
|
-
}
|
|
105
|
-
getCardVc() {
|
|
106
|
-
return this.activeRecordCardVc.getCardVc();
|
|
107
|
-
}
|
|
108
|
-
render() {
|
|
109
|
-
return this.activeRecordCardVc.render();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
OrgListCardViewController.id = 'org-list-card';
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { AbstractViewController, SpruceSchemas, ViewControllerOptions } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
-
declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
3
|
-
declare type Organization = SpruceSchemas.Spruce.v2020_07_22.Organization;
|
|
4
|
-
declare type Button = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Button;
|
|
5
|
-
declare type Row = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.ListRow;
|
|
6
|
-
declare type OnDeleteHandler = (organization: Organization) => void | Promise<void>;
|
|
7
|
-
declare type OnEditHandler = (organization: Organization) => void | Promise<void>;
|
|
8
|
-
export default class OrgListCardViewController extends AbstractViewController<Card> {
|
|
9
|
-
static id: string;
|
|
10
|
-
private activeRecordCardVc;
|
|
11
|
-
private onDelete;
|
|
12
|
-
private onEdit?;
|
|
13
|
-
private selectedOrgId?;
|
|
14
|
-
constructor(options: {
|
|
15
|
-
onDelete?: OnDeleteHandler;
|
|
16
|
-
onEdit?: OnEditHandler;
|
|
17
|
-
footerButtons?: Button[];
|
|
18
|
-
selectedOrgId?: string;
|
|
19
|
-
} & ViewControllerOptions);
|
|
20
|
-
private ActiveRecordCardVc;
|
|
21
|
-
private handleClickDeleteOrg;
|
|
22
|
-
buildRow(org: Organization): Row;
|
|
23
|
-
handleDeletOrg(org: SpruceSchemas.Spruce.v2020_07_22.Organization): Promise<void>;
|
|
24
|
-
load(): Promise<void>;
|
|
25
|
-
getListVc(): import("@sprucelabs/heartwood-view-controllers").ListViewController;
|
|
26
|
-
getCardVc(): import("@sprucelabs/heartwood-view-controllers").CardViewController;
|
|
27
|
-
render(): SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
28
|
-
}
|
|
29
|
-
export {};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
|
|
4
|
-
class OrgListCardViewController extends heartwood_view_controllers_1.AbstractViewController {
|
|
5
|
-
constructor(options) {
|
|
6
|
-
super(options);
|
|
7
|
-
this.onDelete = options.onDelete;
|
|
8
|
-
this.onEdit = options.onEdit;
|
|
9
|
-
this.selectedOrgId = options.selectedOrgId;
|
|
10
|
-
this.activeRecordCardVc = this.ActiveRecordCardVc(options);
|
|
11
|
-
}
|
|
12
|
-
ActiveRecordCardVc(options) {
|
|
13
|
-
return this.Controller('activeRecordCard', (0, heartwood_view_controllers_1.buildActiveRecordCard)({
|
|
14
|
-
eventName: 'list-organizations::v2020_12_25',
|
|
15
|
-
responseKey: 'organizations',
|
|
16
|
-
columnWidths: ['fill'],
|
|
17
|
-
shouldRenderRowDividers: true,
|
|
18
|
-
rowTransformer: this.buildRow.bind(this),
|
|
19
|
-
payload: {
|
|
20
|
-
shouldOnlyShowMine: true,
|
|
21
|
-
},
|
|
22
|
-
header: {
|
|
23
|
-
title: 'Your organizations',
|
|
24
|
-
subtitle: 'Each of your brands, companies, or teams are here! 👇',
|
|
25
|
-
},
|
|
26
|
-
footer: {
|
|
27
|
-
buttons: options.footerButtons,
|
|
28
|
-
},
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
31
|
-
async handleClickDeleteOrg(org) {
|
|
32
|
-
const shouldDelete = await this.confirm({
|
|
33
|
-
title: `Delete ${org.name}`,
|
|
34
|
-
isDestructive: true,
|
|
35
|
-
});
|
|
36
|
-
if (!shouldDelete) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
await this.handleDeletOrg(org);
|
|
40
|
-
}
|
|
41
|
-
buildRow(org) {
|
|
42
|
-
return {
|
|
43
|
-
id: org.id,
|
|
44
|
-
isSelected: this.selectedOrgId === org.id,
|
|
45
|
-
onClick: async () => {
|
|
46
|
-
var _a;
|
|
47
|
-
await ((_a = this.onEdit) === null || _a === void 0 ? void 0 : _a.call(this, org));
|
|
48
|
-
},
|
|
49
|
-
//@ts-ignore
|
|
50
|
-
cells: [
|
|
51
|
-
{
|
|
52
|
-
text: {
|
|
53
|
-
content: org.name,
|
|
54
|
-
},
|
|
55
|
-
subText: {
|
|
56
|
-
content: `${org.address
|
|
57
|
-
? `${org.address.street1}${org.address.street2 ? ` ${org.address.street2}` : ``} ${org.address.city} ${org.address.zip}`
|
|
58
|
-
: ``}`,
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
button: {
|
|
63
|
-
type: 'destructive',
|
|
64
|
-
lineIcon: 'delete',
|
|
65
|
-
onClick: async () => {
|
|
66
|
-
await this.handleClickDeleteOrg(org);
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
].filter((b) => !!b),
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
async handleDeletOrg(org) {
|
|
74
|
-
var _a;
|
|
75
|
-
await ((_a = this.onDelete) === null || _a === void 0 ? void 0 : _a.call(this, org));
|
|
76
|
-
this.activeRecordCardVc.deleteRow(org.id);
|
|
77
|
-
this.activeRecordCardVc.setIsBusy(true);
|
|
78
|
-
const client = await this.connectToApi();
|
|
79
|
-
await client.emit('delete-organization::v2020_12_25', {
|
|
80
|
-
target: {
|
|
81
|
-
organizationId: org.id,
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
this.activeRecordCardVc.setIsBusy(false);
|
|
85
|
-
}
|
|
86
|
-
async load() {
|
|
87
|
-
await this.activeRecordCardVc.load();
|
|
88
|
-
}
|
|
89
|
-
getListVc() {
|
|
90
|
-
return this.activeRecordCardVc.getListVc();
|
|
91
|
-
}
|
|
92
|
-
getCardVc() {
|
|
93
|
-
return this.activeRecordCardVc.getCardVc();
|
|
94
|
-
}
|
|
95
|
-
render() {
|
|
96
|
-
return this.activeRecordCardVc.render();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.default = OrgListCardViewController;
|
|
100
|
-
OrgListCardViewController.id = 'org-list-card';
|