@esri/hub-common 14.60.0 → 14.61.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/dist/esm/core/index.js +1 -0
- package/dist/esm/core/index.js.map +1 -1
- package/dist/esm/core/processActionLinks.js +62 -0
- package/dist/esm/core/processActionLinks.js.map +1 -0
- package/dist/esm/core/schemas/internal/metrics/setMetricAndDisplay.js +8 -5
- package/dist/esm/core/schemas/internal/metrics/setMetricAndDisplay.js.map +1 -1
- package/dist/esm/core/types/Metrics.js +1 -1
- package/dist/node/core/index.js +1 -0
- package/dist/node/core/index.js.map +1 -1
- package/dist/node/core/processActionLinks.js +67 -0
- package/dist/node/core/processActionLinks.js.map +1 -0
- package/dist/node/core/schemas/internal/metrics/setMetricAndDisplay.js +8 -5
- package/dist/node/core/schemas/internal/metrics/setMetricAndDisplay.js.map +1 -1
- package/dist/node/core/types/Metrics.js +1 -1
- package/dist/types/core/index.d.ts +1 -0
- package/dist/types/core/processActionLinks.d.ts +30 -0
- package/dist/types/core/types/Metrics.d.ts +1 -1
- package/package.json +1 -1
package/dist/esm/core/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export * from "./fetchHubEntity";
|
|
|
6
6
|
export * from "./getTypeFromEntity";
|
|
7
7
|
export * from "./getRelativeWorkspaceUrl";
|
|
8
8
|
export * from "./isValidEntityType";
|
|
9
|
+
export * from "./processActionLinks";
|
|
9
10
|
// For sme reason, if updateHubEntity is exported here,
|
|
10
11
|
// it is not actually exported in the final package.
|
|
11
12
|
// export * from "./updateHubEntity";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAErC,uDAAuD;AACvD,oDAAoD;AACpD,qCAAqC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { hubSearch } from "../search";
|
|
2
|
+
/**
|
|
3
|
+
* Given an array of IHubActionLinks, the following util will
|
|
4
|
+
* "pre-process" the action links. This includes:
|
|
5
|
+
*
|
|
6
|
+
* 1. For kind = "content": Fetching the content item, grabbing
|
|
7
|
+
* its site relative href, and transforming the link into an
|
|
8
|
+
* external action link that can be consumed in the UI
|
|
9
|
+
*
|
|
10
|
+
* Note: we can add other pre-processing as necessary
|
|
11
|
+
*
|
|
12
|
+
* @param links hub action links
|
|
13
|
+
* @param requestOptions hub request options
|
|
14
|
+
*/
|
|
15
|
+
export async function processActionLinks(links, requestOptions) {
|
|
16
|
+
const processedActionLinks = await Promise.all(links.map(async (link) => {
|
|
17
|
+
return processActionLink(link, requestOptions);
|
|
18
|
+
}));
|
|
19
|
+
return processedActionLinks;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Given a single IHubActionLink, the following util will
|
|
23
|
+
* "pre-process" the action link. This includes:
|
|
24
|
+
*
|
|
25
|
+
* 1. For kind = "content": Fetching the content item, grabbing
|
|
26
|
+
* its site relative href, and transforming the link into an
|
|
27
|
+
* external action link that can be consumed in the UI
|
|
28
|
+
*
|
|
29
|
+
* Note: we can add other pre-processing as necessary
|
|
30
|
+
*
|
|
31
|
+
* @param link hub action link
|
|
32
|
+
* @param requestOptions hub request options
|
|
33
|
+
*/
|
|
34
|
+
export async function processActionLink(link, requestOptions) {
|
|
35
|
+
// recursively process nested links
|
|
36
|
+
if (link.kind === "section") {
|
|
37
|
+
link.children = await processActionLinks(link.children, requestOptions);
|
|
38
|
+
}
|
|
39
|
+
if (link.kind === "content") {
|
|
40
|
+
try {
|
|
41
|
+
// 1. query for the content item so we can grab its
|
|
42
|
+
// siteRelative href
|
|
43
|
+
const query = {
|
|
44
|
+
targetEntity: "item",
|
|
45
|
+
filters: [{ predicates: [{ id: link.contentId }] }],
|
|
46
|
+
};
|
|
47
|
+
const { results } = await hubSearch(query, { requestOptions });
|
|
48
|
+
// 2. construct a new "external" action link
|
|
49
|
+
// with the content item's site relative href
|
|
50
|
+
delete link.contentId;
|
|
51
|
+
const processedLink = Object.assign(Object.assign({}, link), { kind: "external", href: results[0].links.siteRelative });
|
|
52
|
+
return processedLink;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
throw new Error(`Unable to fetch entity: ${link.contentId}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
return link;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=processActionLinks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processActionLinks.js","sourceRoot":"","sources":["../../../src/core/processActionLinks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,SAAS,EAAE,MAAM,WAAW,CAAC;AAQ9C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAAsB,EACtB,cAAkC;IAElC,MAAM,oBAAoB,GAAG,MAAM,OAAO,CAAC,GAAG,CAC5C,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAmB,EAAE,EAAE;QACtC,OAAO,iBAAiB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IACjD,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAmB,EACnB,cAAkC;IAElC,mCAAmC;IACnC,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;QAC3B,IAAI,CAAC,QAAQ,GAAG,MAAM,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;KACzE;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;QAC3B,IAAI;YACF,mDAAmD;YACnD,oBAAoB;YACpB,MAAM,KAAK,GAAW;gBACpB,YAAY,EAAE,MAAM;gBACpB,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC;aACpD,CAAC;YACF,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,SAAS,CAAC,KAAK,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;YAE/D,4CAA4C;YAC5C,6CAA6C;YAC7C,OAAO,IAAI,CAAC,SAAS,CAAC;YACtB,MAAM,aAAa,mCACd,IAAI,KACP,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,GACpC,CAAC;YAEF,OAAO,aAAa,CAAC;SACtB;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;SAC9D;KACF;SAAM;QACL,OAAO,IAAI,CAAC;KACb;AACH,CAAC"}
|
|
@@ -13,16 +13,18 @@ import { cloneObject } from "../../../../util";
|
|
|
13
13
|
export function setMetricAndDisplay(entity, metric, displayConfig) {
|
|
14
14
|
const entityCopy = cloneObject(entity);
|
|
15
15
|
const metricId = metric.id;
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
// get with default in case we have an undefined metrics array
|
|
17
|
+
const metrics = getWithDefault(entityCopy, "metrics", []);
|
|
18
|
+
const mIndex = metrics.findIndex((m) => m.id === metricId);
|
|
19
|
+
// get array in case of undefined displays array
|
|
18
20
|
const displays = getWithDefault(entityCopy, "view.metricDisplays", []);
|
|
19
21
|
const dIndex = displays.findIndex((d) => d.metricId === metricId);
|
|
20
22
|
// existing vs new metric
|
|
21
23
|
if (mIndex > -1) {
|
|
22
|
-
|
|
24
|
+
metrics[mIndex] = metric;
|
|
23
25
|
}
|
|
24
26
|
else {
|
|
25
|
-
|
|
27
|
+
metrics.push(metric);
|
|
26
28
|
}
|
|
27
29
|
// existing vs new display
|
|
28
30
|
if (dIndex > -1) {
|
|
@@ -31,8 +33,9 @@ export function setMetricAndDisplay(entity, metric, displayConfig) {
|
|
|
31
33
|
else {
|
|
32
34
|
displays.push(displayConfig);
|
|
33
35
|
}
|
|
34
|
-
// reset the
|
|
36
|
+
// reset the arrays
|
|
35
37
|
entityCopy.view.metricDisplays = displays;
|
|
38
|
+
entityCopy.metrics = metrics;
|
|
36
39
|
return entityCopy;
|
|
37
40
|
}
|
|
38
41
|
//# sourceMappingURL=setMetricAndDisplay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setMetricAndDisplay.js","sourceRoot":"","sources":["../../../../../../src/core/schemas/internal/metrics/setMetricAndDisplay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAI/C;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAmB,EACnB,MAAe,EACf,aAAmC;IAEnC,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"setMetricAndDisplay.js","sourceRoot":"","sources":["../../../../../../src/core/schemas/internal/metrics/setMetricAndDisplay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAI/C;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAmB,EACnB,MAAe,EACf,aAAmC;IAEnC,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC;IAE3B,8DAA8D;IAC9D,MAAM,OAAO,GAAG,cAAc,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IAC1D,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAU,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC;IAEpE,gDAAgD;IAChD,MAAM,QAAQ,GAAG,cAAc,CAAC,UAAU,EAAE,qBAAqB,EAAE,EAAE,CAAC,CAAC;IACvE,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,CAC/B,CAAC,CAAuB,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CACrD,CAAC;IAEF,yBAAyB;IACzB,IAAI,MAAM,GAAG,CAAC,CAAC,EAAE;QACf,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;KAC1B;SAAM;QACL,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KACtB;IAED,0BAA0B;IAC1B,IAAI,MAAM,GAAG,CAAC,CAAC,EAAE;QACf,QAAQ,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC;KAClC;SAAM;QACL,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;KAC9B;IAED,mBAAmB;IACnB,UAAU,CAAC,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC;IAC1C,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;IAE7B,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -21,5 +21,5 @@ export var MetricVisibility;
|
|
|
21
21
|
MetricVisibility["featured"] = "featured";
|
|
22
22
|
})(MetricVisibility || (MetricVisibility = {}));
|
|
23
23
|
/** Maxmium number of metrics allowed on any given entity. */
|
|
24
|
-
export const MAX_ENTITY_METRICS_ALLOWED =
|
|
24
|
+
export const MAX_ENTITY_METRICS_ALLOWED = 24;
|
|
25
25
|
//# sourceMappingURL=Metrics.js.map
|
package/dist/node/core/index.js
CHANGED
|
@@ -9,6 +9,7 @@ tslib_1.__exportStar(require("./fetchHubEntity"), exports);
|
|
|
9
9
|
tslib_1.__exportStar(require("./getTypeFromEntity"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./getRelativeWorkspaceUrl"), exports);
|
|
11
11
|
tslib_1.__exportStar(require("./isValidEntityType"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./processActionLinks"), exports);
|
|
12
13
|
// For sme reason, if updateHubEntity is exported here,
|
|
13
14
|
// it is not actually exported in the final package.
|
|
14
15
|
// export * from "./updateHubEntity";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,kDAAwB;AACxB,sDAA4B;AAC5B,oDAA0B;AAC1B,2DAAiC;AACjC,8DAAoC;AACpC,oEAA0C;AAC1C,8DAAoC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,kDAAwB;AACxB,sDAA4B;AAC5B,oDAA0B;AAC1B,2DAAiC;AACjC,8DAAoC;AACpC,oEAA0C;AAC1C,8DAAoC;AACpC,+DAAqC;AAErC,uDAAuD;AACvD,oDAAoD;AACpD,qCAAqC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processActionLink = exports.processActionLinks = void 0;
|
|
4
|
+
const search_1 = require("../search");
|
|
5
|
+
/**
|
|
6
|
+
* Given an array of IHubActionLinks, the following util will
|
|
7
|
+
* "pre-process" the action links. This includes:
|
|
8
|
+
*
|
|
9
|
+
* 1. For kind = "content": Fetching the content item, grabbing
|
|
10
|
+
* its site relative href, and transforming the link into an
|
|
11
|
+
* external action link that can be consumed in the UI
|
|
12
|
+
*
|
|
13
|
+
* Note: we can add other pre-processing as necessary
|
|
14
|
+
*
|
|
15
|
+
* @param links hub action links
|
|
16
|
+
* @param requestOptions hub request options
|
|
17
|
+
*/
|
|
18
|
+
async function processActionLinks(links, requestOptions) {
|
|
19
|
+
const processedActionLinks = await Promise.all(links.map(async (link) => {
|
|
20
|
+
return processActionLink(link, requestOptions);
|
|
21
|
+
}));
|
|
22
|
+
return processedActionLinks;
|
|
23
|
+
}
|
|
24
|
+
exports.processActionLinks = processActionLinks;
|
|
25
|
+
/**
|
|
26
|
+
* Given a single IHubActionLink, the following util will
|
|
27
|
+
* "pre-process" the action link. This includes:
|
|
28
|
+
*
|
|
29
|
+
* 1. For kind = "content": Fetching the content item, grabbing
|
|
30
|
+
* its site relative href, and transforming the link into an
|
|
31
|
+
* external action link that can be consumed in the UI
|
|
32
|
+
*
|
|
33
|
+
* Note: we can add other pre-processing as necessary
|
|
34
|
+
*
|
|
35
|
+
* @param link hub action link
|
|
36
|
+
* @param requestOptions hub request options
|
|
37
|
+
*/
|
|
38
|
+
async function processActionLink(link, requestOptions) {
|
|
39
|
+
// recursively process nested links
|
|
40
|
+
if (link.kind === "section") {
|
|
41
|
+
link.children = await processActionLinks(link.children, requestOptions);
|
|
42
|
+
}
|
|
43
|
+
if (link.kind === "content") {
|
|
44
|
+
try {
|
|
45
|
+
// 1. query for the content item so we can grab its
|
|
46
|
+
// siteRelative href
|
|
47
|
+
const query = {
|
|
48
|
+
targetEntity: "item",
|
|
49
|
+
filters: [{ predicates: [{ id: link.contentId }] }],
|
|
50
|
+
};
|
|
51
|
+
const { results } = await search_1.hubSearch(query, { requestOptions });
|
|
52
|
+
// 2. construct a new "external" action link
|
|
53
|
+
// with the content item's site relative href
|
|
54
|
+
delete link.contentId;
|
|
55
|
+
const processedLink = Object.assign(Object.assign({}, link), { kind: "external", href: results[0].links.siteRelative });
|
|
56
|
+
return processedLink;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
throw new Error(`Unable to fetch entity: ${link.contentId}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return link;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.processActionLink = processActionLink;
|
|
67
|
+
//# sourceMappingURL=processActionLinks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processActionLinks.js","sourceRoot":"","sources":["../../../src/core/processActionLinks.ts"],"names":[],"mappings":";;;AAAA,sCAA8C;AAQ9C;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,kBAAkB,CACtC,KAAsB,EACtB,cAAkC;IAElC,MAAM,oBAAoB,GAAG,MAAM,OAAO,CAAC,GAAG,CAC5C,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAmB,EAAE,EAAE;QACtC,OAAO,iBAAiB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IACjD,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAXD,gDAWC;AAED;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,iBAAiB,CACrC,IAAmB,EACnB,cAAkC;IAElC,mCAAmC;IACnC,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;QAC3B,IAAI,CAAC,QAAQ,GAAG,MAAM,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;KACzE;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;QAC3B,IAAI;YACF,mDAAmD;YACnD,oBAAoB;YACpB,MAAM,KAAK,GAAW;gBACpB,YAAY,EAAE,MAAM;gBACpB,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC;aACpD,CAAC;YACF,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,kBAAS,CAAC,KAAK,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;YAE/D,4CAA4C;YAC5C,6CAA6C;YAC7C,OAAO,IAAI,CAAC,SAAS,CAAC;YACtB,MAAM,aAAa,mCACd,IAAI,KACP,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,GACpC,CAAC;YAEF,OAAO,aAAa,CAAC;SACtB;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;SAC9D;KACF;SAAM;QACL,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAlCD,8CAkCC"}
|
|
@@ -16,16 +16,18 @@ const util_1 = require("../../../../util");
|
|
|
16
16
|
function setMetricAndDisplay(entity, metric, displayConfig) {
|
|
17
17
|
const entityCopy = util_1.cloneObject(entity);
|
|
18
18
|
const metricId = metric.id;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
// get with default in case we have an undefined metrics array
|
|
20
|
+
const metrics = objects_1.getWithDefault(entityCopy, "metrics", []);
|
|
21
|
+
const mIndex = metrics.findIndex((m) => m.id === metricId);
|
|
22
|
+
// get array in case of undefined displays array
|
|
21
23
|
const displays = objects_1.getWithDefault(entityCopy, "view.metricDisplays", []);
|
|
22
24
|
const dIndex = displays.findIndex((d) => d.metricId === metricId);
|
|
23
25
|
// existing vs new metric
|
|
24
26
|
if (mIndex > -1) {
|
|
25
|
-
|
|
27
|
+
metrics[mIndex] = metric;
|
|
26
28
|
}
|
|
27
29
|
else {
|
|
28
|
-
|
|
30
|
+
metrics.push(metric);
|
|
29
31
|
}
|
|
30
32
|
// existing vs new display
|
|
31
33
|
if (dIndex > -1) {
|
|
@@ -34,8 +36,9 @@ function setMetricAndDisplay(entity, metric, displayConfig) {
|
|
|
34
36
|
else {
|
|
35
37
|
displays.push(displayConfig);
|
|
36
38
|
}
|
|
37
|
-
// reset the
|
|
39
|
+
// reset the arrays
|
|
38
40
|
entityCopy.view.metricDisplays = displays;
|
|
41
|
+
entityCopy.metrics = metrics;
|
|
39
42
|
return entityCopy;
|
|
40
43
|
}
|
|
41
44
|
exports.setMetricAndDisplay = setMetricAndDisplay;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setMetricAndDisplay.js","sourceRoot":"","sources":["../../../../../../src/core/schemas/internal/metrics/setMetricAndDisplay.ts"],"names":[],"mappings":";;;AAAA,iDAAqD;AACrD,2CAA+C;AAI/C;;;;;;;;;GASG;AACH,SAAgB,mBAAmB,CACjC,MAAmB,EACnB,MAAe,EACf,aAAmC;IAEnC,MAAM,UAAU,GAAG,kBAAW,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"setMetricAndDisplay.js","sourceRoot":"","sources":["../../../../../../src/core/schemas/internal/metrics/setMetricAndDisplay.ts"],"names":[],"mappings":";;;AAAA,iDAAqD;AACrD,2CAA+C;AAI/C;;;;;;;;;GASG;AACH,SAAgB,mBAAmB,CACjC,MAAmB,EACnB,MAAe,EACf,aAAmC;IAEnC,MAAM,UAAU,GAAG,kBAAW,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC;IAE3B,8DAA8D;IAC9D,MAAM,OAAO,GAAG,wBAAc,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IAC1D,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAU,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC;IAEpE,gDAAgD;IAChD,MAAM,QAAQ,GAAG,wBAAc,CAAC,UAAU,EAAE,qBAAqB,EAAE,EAAE,CAAC,CAAC;IACvE,MAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,CAC/B,CAAC,CAAuB,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CACrD,CAAC;IAEF,yBAAyB;IACzB,IAAI,MAAM,GAAG,CAAC,CAAC,EAAE;QACf,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;KAC1B;SAAM;QACL,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KACtB;IAED,0BAA0B;IAC1B,IAAI,MAAM,GAAG,CAAC,CAAC,EAAE;QACf,QAAQ,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC;KAClC;SAAM;QACL,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;KAC9B;IAED,mBAAmB;IACnB,UAAU,CAAC,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC;IAC1C,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;IAE7B,OAAO,UAAU,CAAC;AACpB,CAAC;AArCD,kDAqCC"}
|
|
@@ -24,5 +24,5 @@ var MetricVisibility;
|
|
|
24
24
|
MetricVisibility["featured"] = "featured";
|
|
25
25
|
})(MetricVisibility = exports.MetricVisibility || (exports.MetricVisibility = {}));
|
|
26
26
|
/** Maxmium number of metrics allowed on any given entity. */
|
|
27
|
-
exports.MAX_ENTITY_METRICS_ALLOWED =
|
|
27
|
+
exports.MAX_ENTITY_METRICS_ALLOWED = 24;
|
|
28
28
|
//# sourceMappingURL=Metrics.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IHubRequestOptions } from "../types";
|
|
2
|
+
import { HubActionLink, IHubContentActionLink } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Given an array of IHubActionLinks, the following util will
|
|
5
|
+
* "pre-process" the action links. This includes:
|
|
6
|
+
*
|
|
7
|
+
* 1. For kind = "content": Fetching the content item, grabbing
|
|
8
|
+
* its site relative href, and transforming the link into an
|
|
9
|
+
* external action link that can be consumed in the UI
|
|
10
|
+
*
|
|
11
|
+
* Note: we can add other pre-processing as necessary
|
|
12
|
+
*
|
|
13
|
+
* @param links hub action links
|
|
14
|
+
* @param requestOptions hub request options
|
|
15
|
+
*/
|
|
16
|
+
export declare function processActionLinks(links: HubActionLink[], requestOptions: IHubRequestOptions): Promise<Array<Exclude<HubActionLink, IHubContentActionLink>>>;
|
|
17
|
+
/**
|
|
18
|
+
* Given a single IHubActionLink, the following util will
|
|
19
|
+
* "pre-process" the action link. This includes:
|
|
20
|
+
*
|
|
21
|
+
* 1. For kind = "content": Fetching the content item, grabbing
|
|
22
|
+
* its site relative href, and transforming the link into an
|
|
23
|
+
* external action link that can be consumed in the UI
|
|
24
|
+
*
|
|
25
|
+
* Note: we can add other pre-processing as necessary
|
|
26
|
+
*
|
|
27
|
+
* @param link hub action link
|
|
28
|
+
* @param requestOptions hub request options
|
|
29
|
+
*/
|
|
30
|
+
export declare function processActionLink(link: HubActionLink, requestOptions: IHubRequestOptions): Promise<Exclude<HubActionLink, IHubContentActionLink>>;
|