@esri/hub-common 14.46.2 → 14.48.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/EntityEditor.js +2 -2
- package/dist/esm/core/EntityEditor.js.map +1 -1
- package/dist/esm/core/schemas/internal/getCardEditorSchemas.js +2 -2
- package/dist/esm/core/schemas/internal/getCardEditorSchemas.js.map +1 -1
- package/dist/esm/core/schemas/internal/getEditorSchemas.js +1 -0
- package/dist/esm/core/schemas/internal/getEditorSchemas.js.map +1 -1
- package/dist/esm/core/schemas/internal/metrics/MetricSchema.js +1 -1
- package/dist/esm/core/schemas/internal/metrics/MetricSchema.js.map +1 -1
- package/dist/esm/core/schemas/internal/metrics/ProjectUiSchemaMetrics.js +31 -0
- package/dist/esm/core/schemas/internal/metrics/ProjectUiSchemaMetrics.js.map +1 -0
- package/dist/esm/core/schemas/internal/metrics/editorToMetric.js +121 -0
- package/dist/esm/core/schemas/internal/metrics/editorToMetric.js.map +1 -0
- package/dist/esm/core/schemas/internal/metrics/metricToEditor.js +22 -0
- package/dist/esm/core/schemas/internal/metrics/metricToEditor.js.map +1 -0
- package/dist/esm/core/schemas/internal/metrics/setMetricAndDisplay.js +29 -0
- package/dist/esm/core/schemas/internal/metrics/setMetricAndDisplay.js.map +1 -0
- package/dist/esm/core/schemas/shared/enums.js +34 -0
- package/dist/esm/core/schemas/shared/enums.js.map +1 -0
- package/dist/esm/core/schemas/types.js +0 -18
- package/dist/esm/core/schemas/types.js.map +1 -1
- package/dist/esm/core/types/Metrics.js +12 -0
- package/dist/esm/core/types/Metrics.js.map +1 -1
- package/dist/esm/objects/deepFilter.js +85 -0
- package/dist/esm/objects/deepFilter.js.map +1 -0
- package/dist/esm/objects/deepFind.js +1 -12
- package/dist/esm/objects/deepFind.js.map +1 -1
- package/dist/esm/objects/index.js +1 -0
- package/dist/esm/objects/index.js.map +1 -1
- package/dist/esm/objects/internal/isFindable.js +13 -0
- package/dist/esm/objects/internal/isFindable.js.map +1 -0
- package/dist/esm/projects/HubProject.js +24 -2
- package/dist/esm/projects/HubProject.js.map +1 -1
- package/dist/esm/projects/_internal/ProjectSchema.js +3 -1
- package/dist/esm/projects/_internal/ProjectSchema.js.map +1 -1
- package/dist/node/core/EntityEditor.js +2 -2
- package/dist/node/core/EntityEditor.js.map +1 -1
- package/dist/node/core/schemas/internal/getCardEditorSchemas.js +2 -2
- package/dist/node/core/schemas/internal/getCardEditorSchemas.js.map +1 -1
- package/dist/node/core/schemas/internal/getEditorSchemas.js +1 -0
- package/dist/node/core/schemas/internal/getEditorSchemas.js.map +1 -1
- package/dist/node/core/schemas/internal/metrics/MetricSchema.js +4 -4
- package/dist/node/core/schemas/internal/metrics/MetricSchema.js.map +1 -1
- package/dist/node/core/schemas/internal/metrics/ProjectUiSchemaMetrics.js +34 -0
- package/dist/node/core/schemas/internal/metrics/ProjectUiSchemaMetrics.js.map +1 -0
- package/dist/node/core/schemas/internal/metrics/editorToMetric.js +126 -0
- package/dist/node/core/schemas/internal/metrics/editorToMetric.js.map +1 -0
- package/dist/node/core/schemas/internal/metrics/metricToEditor.js +26 -0
- package/dist/node/core/schemas/internal/metrics/metricToEditor.js.map +1 -0
- package/dist/node/core/schemas/internal/metrics/setMetricAndDisplay.js +33 -0
- package/dist/node/core/schemas/internal/metrics/setMetricAndDisplay.js.map +1 -0
- package/dist/node/core/schemas/shared/enums.js +37 -0
- package/dist/node/core/schemas/shared/enums.js.map +1 -0
- package/dist/node/core/schemas/types.js +1 -19
- package/dist/node/core/schemas/types.js.map +1 -1
- package/dist/node/core/types/Metrics.js +13 -0
- package/dist/node/core/types/Metrics.js.map +1 -1
- package/dist/node/objects/deepFilter.js +89 -0
- package/dist/node/objects/deepFilter.js.map +1 -0
- package/dist/node/objects/deepFind.js +4 -15
- package/dist/node/objects/deepFind.js.map +1 -1
- package/dist/node/objects/index.js +1 -0
- package/dist/node/objects/index.js.map +1 -1
- package/dist/node/objects/internal/isFindable.js +17 -0
- package/dist/node/objects/internal/isFindable.js.map +1 -0
- package/dist/node/projects/HubProject.js +23 -1
- package/dist/node/projects/HubProject.js.map +1 -1
- package/dist/node/projects/_internal/ProjectSchema.js +3 -1
- package/dist/node/projects/_internal/ProjectSchema.js.map +1 -1
- package/dist/types/core/EntityEditor.d.ts +1 -1
- package/dist/types/core/behaviors/IWithEditorBehavior.d.ts +3 -2
- package/dist/types/core/schemas/internal/metrics/ProjectUiSchemaMetrics.d.ts +12 -0
- package/dist/types/core/schemas/internal/metrics/editorToMetric.d.ts +26 -0
- package/dist/types/core/schemas/internal/metrics/metricToEditor.d.ts +8 -0
- package/dist/types/core/schemas/internal/metrics/setMetricAndDisplay.d.ts +13 -0
- package/dist/types/core/schemas/shared/enums.d.ts +30 -0
- package/dist/types/core/schemas/types.d.ts +2 -17
- package/dist/types/core/types/HubEntityEditor.d.ts +1 -0
- package/dist/types/core/types/IHubItemEntity.d.ts +2 -0
- package/dist/types/core/types/Metrics.d.ts +55 -2
- package/dist/types/objects/deepFilter.d.ts +51 -0
- package/dist/types/objects/index.d.ts +1 -0
- package/dist/types/objects/internal/isFindable.d.ts +1 -0
- package/dist/types/projects/HubProject.d.ts +1 -1
- package/dist/types/projects/_internal/ProjectSchema.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deepFilter = void 0;
|
|
4
|
+
const isFindable_1 = require("./internal/isFindable");
|
|
5
|
+
/**
|
|
6
|
+
* Traverse a graph filtering out entries that do
|
|
7
|
+
* not pass the predicate
|
|
8
|
+
*
|
|
9
|
+
* Note: this util uses cloning behind the scenes
|
|
10
|
+
* so will only work for POJOs and not class instances
|
|
11
|
+
*
|
|
12
|
+
* example:
|
|
13
|
+
* const predicate = (link: any) => link.key !== "00a"
|
|
14
|
+
* const obj = [
|
|
15
|
+
* {
|
|
16
|
+
* key: "001",
|
|
17
|
+
* label: "Stop the Spotted Lanternfly",
|
|
18
|
+
* },
|
|
19
|
+
* {
|
|
20
|
+
* key: "002",
|
|
21
|
+
* label: "Create a Map",
|
|
22
|
+
* children: [
|
|
23
|
+
* {
|
|
24
|
+
* key: "00a",
|
|
25
|
+
* label: "ArcGIS Map Viewer",
|
|
26
|
+
* },
|
|
27
|
+
* {
|
|
28
|
+
* key: "00b",
|
|
29
|
+
* label: "ArcGIS Map Viewer Classic",
|
|
30
|
+
* },
|
|
31
|
+
* ],
|
|
32
|
+
* },
|
|
33
|
+
* ];
|
|
34
|
+
* const res = deepFilter(obj, predicate)
|
|
35
|
+
* res = [
|
|
36
|
+
* {
|
|
37
|
+
* key: "001",
|
|
38
|
+
* label: "Stop the Spotted Lanternfly",
|
|
39
|
+
* },
|
|
40
|
+
* {
|
|
41
|
+
* key: "002",
|
|
42
|
+
* label: "Create a Map",
|
|
43
|
+
* children: [
|
|
44
|
+
* {
|
|
45
|
+
* key: "00b",
|
|
46
|
+
* label: "ArcGIS Map Viewer Classic",
|
|
47
|
+
* },
|
|
48
|
+
* ],
|
|
49
|
+
* },
|
|
50
|
+
* ];
|
|
51
|
+
*
|
|
52
|
+
* @param object
|
|
53
|
+
* @param predicate
|
|
54
|
+
*/
|
|
55
|
+
function deepFilter(object, predicate) {
|
|
56
|
+
if (Array.isArray(object)) {
|
|
57
|
+
return object.reduce((acc, entry) => {
|
|
58
|
+
if (predicate(entry)) {
|
|
59
|
+
if (isFindable_1.isFindable(entry)) {
|
|
60
|
+
const filteredEntry = deepFilter(entry, predicate);
|
|
61
|
+
acc = [...acc, filteredEntry];
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
acc = [...acc, entry];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return acc;
|
|
68
|
+
}, []);
|
|
69
|
+
}
|
|
70
|
+
else if (isFindable_1.isFindable(object)) {
|
|
71
|
+
return Object.keys(object).reduce((acc, entry) => {
|
|
72
|
+
if (predicate(object[entry])) {
|
|
73
|
+
if (isFindable_1.isFindable(object[entry])) {
|
|
74
|
+
const filteredEntry = deepFilter(object[entry], predicate);
|
|
75
|
+
acc[entry] = filteredEntry;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
acc[entry] = object[entry];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return acc;
|
|
82
|
+
}, {});
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.deepFilter = deepFilter;
|
|
89
|
+
//# sourceMappingURL=deepFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepFilter.js","sourceRoot":"","sources":["../../../src/objects/deepFilter.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,SAAgB,UAAU,CACxB,MAAW,EACX,SAAmC;IAEnC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACzB,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YAClC,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE;gBACpB,IAAI,uBAAU,CAAC,KAAK,CAAC,EAAE;oBACrB,MAAM,aAAa,GAAG,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;oBACnD,GAAG,GAAG,CAAC,GAAG,GAAG,EAAE,aAAa,CAAC,CAAC;iBAC/B;qBAAM;oBACL,GAAG,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC;iBACvB;aACF;YACD,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;KACR;SAAM,IAAI,uBAAU,CAAC,MAAM,CAAC,EAAE;QAC7B,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YAC/C,IAAI,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;gBAC5B,IAAI,uBAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;oBAC7B,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC;oBAC1D,GAAW,CAAC,KAAK,CAAC,GAAG,aAAa,CAAC;iBACrC;qBAAM;oBACJ,GAAW,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;iBACrC;aACF;YACD,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;KACR;SAAM;QACL,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AA/BD,gCA+BC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deepFind = exports.deepFindById = void 0;
|
|
4
|
-
const
|
|
4
|
+
const isFindable_1 = require("./internal/isFindable");
|
|
5
5
|
/**
|
|
6
6
|
* Traverse a graph, locating the first entry with an `id` property that
|
|
7
7
|
* has a specific string or number value
|
|
@@ -55,7 +55,7 @@ function deepFind(object, predicate) {
|
|
|
55
55
|
acc = entry;
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
|
-
if (isFindable(entry)) {
|
|
58
|
+
if (isFindable_1.isFindable(entry)) {
|
|
59
59
|
const maybe = deepFind(entry, predicate);
|
|
60
60
|
if (maybe) {
|
|
61
61
|
acc = maybe;
|
|
@@ -65,13 +65,13 @@ function deepFind(object, predicate) {
|
|
|
65
65
|
return acc;
|
|
66
66
|
}, undefined);
|
|
67
67
|
}
|
|
68
|
-
else if (isFindable(object)) {
|
|
68
|
+
else if (isFindable_1.isFindable(object)) {
|
|
69
69
|
if (predicate(object)) {
|
|
70
70
|
return object;
|
|
71
71
|
}
|
|
72
72
|
else {
|
|
73
73
|
return Object.keys(object).reduce((acc, entry) => {
|
|
74
|
-
if (isFindable(object[entry])) {
|
|
74
|
+
if (isFindable_1.isFindable(object[entry])) {
|
|
75
75
|
const maybe = deepFind(object[entry], predicate);
|
|
76
76
|
if (maybe) {
|
|
77
77
|
acc = maybe;
|
|
@@ -86,15 +86,4 @@ function deepFind(object, predicate) {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
exports.deepFind = deepFind;
|
|
89
|
-
function isFindable(object) {
|
|
90
|
-
let result = false;
|
|
91
|
-
if (object &&
|
|
92
|
-
_deep_map_values_1._isObject(object) &&
|
|
93
|
-
!_deep_map_values_1._isDate(object) &&
|
|
94
|
-
!_deep_map_values_1._isRegExp(object) &&
|
|
95
|
-
!_deep_map_values_1._isFunction(object)) {
|
|
96
|
-
result = true;
|
|
97
|
-
}
|
|
98
|
-
return result;
|
|
99
|
-
}
|
|
100
89
|
//# sourceMappingURL=deepFind.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepFind.js","sourceRoot":"","sources":["../../../src/objects/deepFind.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"deepFind.js","sourceRoot":"","sources":["../../../src/objects/deepFind.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,SAAgB,YAAY,CAAC,MAAW,EAAE,KAAsB;IAC9D,MAAM,CAAC,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,CAAC;IACzC,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAC7B,CAAC;AAHD,oCAGC;AAED;;;;;;GAMG;AACH,SAAgB,QAAQ,CACtB,MAAW,EACX,SAAmC;IAEnC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACzB,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YAClC,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE;gBACpB,GAAG,GAAG,KAAK,CAAC;aACb;iBAAM;gBACL,IAAI,uBAAU,CAAC,KAAK,CAAC,EAAE;oBACrB,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;oBACzC,IAAI,KAAK,EAAE;wBACT,GAAG,GAAG,KAAK,CAAC;qBACb;iBACF;aACF;YACD,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,SAAS,CAAC,CAAC;KACf;SAAM,IAAI,uBAAU,CAAC,MAAM,CAAC,EAAE;QAC7B,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE;YACrB,OAAO,MAAM,CAAC;SACf;aAAM;YACL,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;gBAC/C,IAAI,uBAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;oBAC7B,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC;oBACjD,IAAI,KAAK,EAAE;wBACT,GAAG,GAAG,KAAK,CAAC;qBACb;iBACF;gBACD,OAAO,GAAG,CAAC;YACb,CAAC,EAAE,SAAS,CAAC,CAAC;SACf;KACF;SAAM;QACL,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAnCD,4BAmCC"}
|
|
@@ -12,6 +12,7 @@ tslib_1.__exportStar(require("./remove-empty-props"), exports);
|
|
|
12
12
|
tslib_1.__exportStar(require("./deep-string-replace"), exports);
|
|
13
13
|
tslib_1.__exportStar(require("./merge-objects"), exports);
|
|
14
14
|
tslib_1.__exportStar(require("./set-prop"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./deepFilter"), exports);
|
|
15
16
|
tslib_1.__exportStar(require("./deepFind"), exports);
|
|
16
17
|
tslib_1.__exportStar(require("./resolveReferences"), exports);
|
|
17
18
|
tslib_1.__exportStar(require("./pickProps"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/objects/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC;AACnC,wDAA8B;AAC9B,qDAA2B;AAC3B,wDAA8B;AAC9B,qDAA2B;AAC3B,sDAA4B;AAC5B,6DAAmC;AACnC,+DAAqC;AACrC,gEAAsC;AACtC,0DAAgC;AAChC,qDAA2B;AAC3B,qDAA2B;AAC3B,8DAAoC;AACpC,sDAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/objects/index.ts"],"names":[],"mappings":";;;AAAA,6DAAmC;AACnC,wDAA8B;AAC9B,qDAA2B;AAC3B,wDAA8B;AAC9B,qDAA2B;AAC3B,sDAA4B;AAC5B,6DAAmC;AACnC,+DAAqC;AACrC,gEAAsC;AACtC,0DAAgC;AAChC,qDAA2B;AAC3B,uDAA6B;AAC7B,qDAA2B;AAC3B,8DAAoC;AACpC,sDAA4B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFindable = void 0;
|
|
4
|
+
const _deep_map_values_1 = require("../_deep-map-values");
|
|
5
|
+
function isFindable(object) {
|
|
6
|
+
let result = false;
|
|
7
|
+
if (object &&
|
|
8
|
+
_deep_map_values_1._isObject(object) &&
|
|
9
|
+
!_deep_map_values_1._isDate(object) &&
|
|
10
|
+
!_deep_map_values_1._isRegExp(object) &&
|
|
11
|
+
!_deep_map_values_1._isFunction(object)) {
|
|
12
|
+
result = true;
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
exports.isFindable = isFindable;
|
|
17
|
+
//# sourceMappingURL=isFindable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isFindable.js","sourceRoot":"","sources":["../../../../src/objects/internal/isFindable.ts"],"names":[],"mappings":";;;AAAA,0DAM6B;AAE7B,SAAgB,UAAU,CAAC,MAAW;IACpC,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IACE,MAAM;QACN,4BAAS,CAAC,MAAM,CAAC;QACjB,CAAC,0BAAO,CAAC,MAAM,CAAC;QAChB,CAAC,4BAAS,CAAC,MAAM,CAAC;QAClB,CAAC,8BAAW,CAAC,MAAM,CAAC,EACpB;QACA,MAAM,GAAG,IAAI,CAAC;KACf;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAZD,gCAYC"}
|
|
@@ -14,6 +14,9 @@ const util_1 = require("../util");
|
|
|
14
14
|
const edit_1 = require("./edit");
|
|
15
15
|
const enrichEntity_1 = require("../core/enrichEntity");
|
|
16
16
|
const objects_1 = require("../objects");
|
|
17
|
+
const metricToEditor_1 = require("../core/schemas/internal/metrics/metricToEditor");
|
|
18
|
+
const editorToMetric_1 = require("../core/schemas/internal/metrics/editorToMetric");
|
|
19
|
+
const setMetricAndDisplay_1 = require("../core/schemas/internal/metrics/setMetricAndDisplay");
|
|
17
20
|
/**
|
|
18
21
|
* Hub Project Class
|
|
19
22
|
*/
|
|
@@ -156,6 +159,11 @@ class HubProject extends HubItemEntity_1.HubItemEntity {
|
|
|
156
159
|
}, []);
|
|
157
160
|
editor._groups = [...editor._groups, ...defaultShareWithGroups];
|
|
158
161
|
}
|
|
162
|
+
// handle metrics
|
|
163
|
+
const metrics = getEntityMetrics_1.getEntityMetrics(this.entity);
|
|
164
|
+
const metric = metrics.find((m) => m.id === editorContext.metricId);
|
|
165
|
+
const displayConfig = this.entity.view.metricDisplays.find((display) => display.metricId === editorContext.metricId);
|
|
166
|
+
editor._metric = metricToEditor_1.metricToEditor(metric, displayConfig);
|
|
159
167
|
return editor;
|
|
160
168
|
}
|
|
161
169
|
/**
|
|
@@ -163,7 +171,7 @@ class HubProject extends HubItemEntity_1.HubItemEntity {
|
|
|
163
171
|
* @param editor
|
|
164
172
|
* @returns
|
|
165
173
|
*/
|
|
166
|
-
async fromEditor(editor) {
|
|
174
|
+
async fromEditor(editor, editorContext) {
|
|
167
175
|
const autoShareGroups = editor._groups || [];
|
|
168
176
|
const isCreate = !editor.id;
|
|
169
177
|
// Setting the thumbnailCache will ensure that
|
|
@@ -208,6 +216,20 @@ class HubProject extends HubItemEntity_1.HubItemEntity {
|
|
|
208
216
|
await this.clearFeaturedImage();
|
|
209
217
|
}
|
|
210
218
|
}
|
|
219
|
+
// handle metrics
|
|
220
|
+
const _metric = editor._metric;
|
|
221
|
+
// if we have a current metric and it's beyond the default empty from toEditor
|
|
222
|
+
if (_metric && Object.keys(_metric).length) {
|
|
223
|
+
let metricId = editorContext === null || editorContext === void 0 ? void 0 : editorContext.metricId;
|
|
224
|
+
// creating a new metric
|
|
225
|
+
if (!metricId) {
|
|
226
|
+
metricId = util_1.createId(util_1.camelize(editor._metric.cardTitle));
|
|
227
|
+
}
|
|
228
|
+
// transform editor values into metric and displayConfig
|
|
229
|
+
const { metric, displayConfig } = editorToMetric_1.editorToMetric(editor._metric, metricId);
|
|
230
|
+
// put metric and display config onto entity
|
|
231
|
+
this.entity = setMetricAndDisplay_1.setMetricAndDisplay(this.entity, metric, displayConfig);
|
|
232
|
+
}
|
|
211
233
|
/**
|
|
212
234
|
* operations that are only relevant to the project create workflow.
|
|
213
235
|
* if these ever become part of the edit experience, we can remove
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HubProject.js","sourceRoot":"","sources":["../../../src/projects/HubProject.ts"],"names":[],"mappings":";;;AAAA,yCAA6C;AAa7C,+CAA4C;AAE5C,yDAAsD;AAItD,qEAAkE;AAElE,8DAA8D;AAC9D,mCAAuC;AAGvC,kEAA+D;AAC/D,4DAAyD;AAKzD,iCAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"HubProject.js","sourceRoot":"","sources":["../../../src/projects/HubProject.ts"],"names":[],"mappings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,CAAC,MAAM,GAAG,MAAM,oBAAa,CAC/B,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAChC,CAAC;SACH;QACD,yCAAyC;QACzC,MAAM,KAAK,CAAC,SAAS,EAAE,CAAC;QAExB,OAAO;IACT,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM;QACV,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACrD;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,MAAM,EAAE,aAAa,EAAE,GAAG,2CAAa,QAAQ,EAAC,CAAC;QACjD,wBAAwB;QACxB,MAAM,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACvE,CAAC;IAED;;;;OAIG;IACH,aAAa,CAAC,QAAgB;QAC5B,MAAM,OAAO,GAAG,mCAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9C,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC;QACtD,oBAAoB;QACpB,IAAI,MAAM,EAAE;YACV,OAAO,6BAAa,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;SAC5C;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,UAAU,QAAQ,aAAa,CAAC,CAAC;SAClD;IACH,CAAC;CACF;AA1XD,gCA0XC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProjectSchema = exports.ProjectEditorTypes = void 0;
|
|
4
|
+
const MetricSchema_1 = require("../../core/schemas/internal/metrics/MetricSchema");
|
|
4
5
|
const HubItemEntitySchema_1 = require("../../core/schemas/shared/HubItemEntitySchema");
|
|
5
6
|
const IHubProject_1 = require("../../core/types/IHubProject");
|
|
6
7
|
exports.ProjectEditorTypes = [
|
|
7
8
|
"hub:project:create",
|
|
8
9
|
"hub:project:edit",
|
|
10
|
+
"hub:project:metrics",
|
|
9
11
|
];
|
|
10
12
|
/**
|
|
11
13
|
* Defines the JSON schema for a Hub Project's editable fields
|
|
@@ -17,5 +19,5 @@ exports.ProjectSchema = Object.assign(Object.assign({}, HubItemEntitySchema_1.Hu
|
|
|
17
19
|
type: "string",
|
|
18
20
|
default: IHubProject_1.PROJECT_STATUSES.notStarted,
|
|
19
21
|
enum: Object.keys(IHubProject_1.PROJECT_STATUSES),
|
|
20
|
-
} }) });
|
|
22
|
+
}, _metrics: MetricSchema_1.MetricSchema }) });
|
|
21
23
|
//# sourceMappingURL=ProjectSchema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectSchema.js","sourceRoot":"","sources":["../../../../src/projects/_internal/ProjectSchema.ts"],"names":[],"mappings":";;;AAAA,uFAAoF;AAEpF,8DAAgE;AAGnD,QAAA,kBAAkB,GAAG;IAChC,oBAAoB;IACpB,kBAAkB;
|
|
1
|
+
{"version":3,"file":"ProjectSchema.js","sourceRoot":"","sources":["../../../../src/projects/_internal/ProjectSchema.ts"],"names":[],"mappings":";;;AAAA,mFAAgF;AAChF,uFAAoF;AAEpF,8DAAgE;AAGnD,QAAA,kBAAkB,GAAG;IAChC,oBAAoB;IACpB,kBAAkB;IAClB,qBAAqB;CACb,CAAC;AAEX;;GAEG;AACU,QAAA,aAAa,GAAyB,gCAC9C,yCAAmB,KACtB,UAAU,kCACL,yCAAmB,CAAC,UAAU,KACjC,OAAO,EAAE;YACP,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC1B,EACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,8BAAgB,CAAC,UAAU;YACpC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,8BAAgB,CAAC;SACpC,EACD,QAAQ,EAAE,2BAAY,MAED,CAAC"}
|
|
@@ -9,5 +9,5 @@ export declare class EntityEditor {
|
|
|
9
9
|
static fromEntity(entity: HubEntity, context: IArcGISContext): EntityEditor;
|
|
10
10
|
getConfig(i18nScope: string, type: EntityEditorType): Promise<IEditorConfig>;
|
|
11
11
|
toEditor(editorContext?: IEntityEditorContext, include?: string[]): HubEntityEditor;
|
|
12
|
-
save(editor: HubEntityEditor): Promise<HubEntity>;
|
|
12
|
+
save(editor: HubEntityEditor, editorContext?: IEntityEditorContext): Promise<HubEntity>;
|
|
13
13
|
}
|
|
@@ -21,7 +21,8 @@ export interface IWithEditorBehavior {
|
|
|
21
21
|
* Update the internal Entity from the "Editor" structure.
|
|
22
22
|
* This should only be used by the arcgis-hub-entity-editor component.
|
|
23
23
|
* For general use, see the `update(Partial<T>)` method
|
|
24
|
-
* @param
|
|
24
|
+
* @param editor
|
|
25
|
+
* @param editorContext
|
|
25
26
|
*/
|
|
26
|
-
fromEditor(editor: HubEntityEditor): Promise<HubEntity>;
|
|
27
|
+
fromEditor(editor: HubEntityEditor, editorContext?: IEntityEditorContext): Promise<HubEntity>;
|
|
27
28
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IArcGISContext } from "../../../../ArcGISContext";
|
|
2
|
+
import { IUiSchema } from "../../types";
|
|
3
|
+
import { EntityEditorOptions } from "../EditorOptions";
|
|
4
|
+
/**
|
|
5
|
+
* @private
|
|
6
|
+
* Exports the uiSchema of metrics for projects
|
|
7
|
+
* @param i18nScope
|
|
8
|
+
* @param config
|
|
9
|
+
* @param context
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export declare const buildUiSchema: (i18nScope: string, config: EntityEditorOptions, context: IArcGISContext) => IUiSchema;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IMetric, IMetricDisplayConfig, IEntityInfo, IExpression, IMetricEditorValues } from "../../../types/Metrics";
|
|
2
|
+
/**
|
|
3
|
+
* Transforms the IConfigurationValues into an object with IMetric and IMetricDisplayConfig to be saved on an entity or rendered in the ui.
|
|
4
|
+
* @param values IConfigurationValues for the arcgis-hub-metric-card to use
|
|
5
|
+
* @param metricId what should be the id of the transformed metric
|
|
6
|
+
* @param entityInfo what should be the entityInfo of the transformed metric
|
|
7
|
+
* @returns IMetricCardParams
|
|
8
|
+
*/
|
|
9
|
+
export declare function editorToMetric(values: IMetricEditorValues, metricId: string, opts?: {
|
|
10
|
+
metricName?: string;
|
|
11
|
+
entityInfo?: IEntityInfo;
|
|
12
|
+
}): {
|
|
13
|
+
metric: IMetric;
|
|
14
|
+
displayConfig: IMetricDisplayConfig;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Constructs a where clause from a given expression set.
|
|
18
|
+
*
|
|
19
|
+
* @param {Array} fields the available fields for a given dataset
|
|
20
|
+
* @param {Object} values the selected values
|
|
21
|
+
*
|
|
22
|
+
* @returns {string} returns a string for the where clause query
|
|
23
|
+
*
|
|
24
|
+
* NOTE: currently returns string as a MATCH and everything else as BETWEEN
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildWhereClause(expressionSet?: IExpression[]): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IMetric, IMetricDisplayConfig, IMetricEditorValues } from "../../../types/Metrics";
|
|
2
|
+
/**
|
|
3
|
+
* Util to convert a metric into editor values consumable by the configuration editor
|
|
4
|
+
* @param metric - IMetric metric
|
|
5
|
+
* @param displayConfig - display configuration for the metric
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function metricToEditor(metric: IMetric, displayConfig: IMetricDisplayConfig): IMetricEditorValues;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IHubProject } from "../../../types/IHubProject";
|
|
2
|
+
import { IMetric, IMetricDisplayConfig } from "../../../types/Metrics";
|
|
3
|
+
/**
|
|
4
|
+
* Sets a given metric and metricDisplayConfig on an entity's metric and view.metricDisplays props.
|
|
5
|
+
*
|
|
6
|
+
* @param entity - should have metric and metricDisplays implemented
|
|
7
|
+
* @param metric - IMetric
|
|
8
|
+
* @param displayConfig - IMetricDisplayConfig configuration to display the metric in the ui
|
|
9
|
+
*
|
|
10
|
+
* Right now, this just accepts a HubProject; in the future as more entities support metrics,
|
|
11
|
+
* other entities can be allowed.
|
|
12
|
+
*/
|
|
13
|
+
export declare function setMetricAndDisplay(entity: IHubProject, metric: IMetric, displayConfig: IMetricDisplayConfig): IHubProject;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alignment values allowed for a display
|
|
3
|
+
*
|
|
4
|
+
* values = start | center | end
|
|
5
|
+
*/
|
|
6
|
+
export declare enum ALIGNMENTS {
|
|
7
|
+
start = "start",
|
|
8
|
+
center = "center",
|
|
9
|
+
end = "end"
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Corner values allowed for a display
|
|
13
|
+
*
|
|
14
|
+
* values = square | round
|
|
15
|
+
*/
|
|
16
|
+
export declare enum CORNERS {
|
|
17
|
+
square = "square",
|
|
18
|
+
round = "round"
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Drop shadow values allowed for a display
|
|
22
|
+
*
|
|
23
|
+
* values = none | low | medium | heavy
|
|
24
|
+
*/
|
|
25
|
+
export declare enum DROP_SHADOWS {
|
|
26
|
+
none = "none",
|
|
27
|
+
low = "low",
|
|
28
|
+
medium = "medium",
|
|
29
|
+
heavy = "heavy"
|
|
30
|
+
}
|
|
@@ -9,7 +9,7 @@ export interface IEditorConfig {
|
|
|
9
9
|
* to the supported/defined uiSchema configurations
|
|
10
10
|
*/
|
|
11
11
|
export declare type EntityEditorType = (typeof validEntityEditorTypes)[number];
|
|
12
|
-
export declare const validEntityEditorTypes: readonly ["hub:project:create", "hub:project:edit", "hub:content:edit", "hub:content:settings", "hub:content:discussions", "hub:initiative:edit", "hub:initiative:create", "hub:site:edit", "hub:site:create", "hub:site:followers", "hub:site:discussions", "hub:site:settings", "hub:discussion:edit", "hub:discussion:create", "hub:discussion:settings", "hub:page:edit", "hub:template:edit", "hub:group:edit", "hub:group:settings", "hub:group:discussions", "hub:initiativeTemplate:edit"];
|
|
12
|
+
export declare const validEntityEditorTypes: readonly ["hub:project:create", "hub:project:edit", "hub:project:metrics", "hub:content:edit", "hub:content:settings", "hub:content:discussions", "hub:initiative:edit", "hub:initiative:create", "hub:site:edit", "hub:site:create", "hub:site:followers", "hub:site:discussions", "hub:site:settings", "hub:discussion:edit", "hub:discussion:create", "hub:discussion:settings", "hub:page:edit", "hub:template:edit", "hub:group:edit", "hub:group:settings", "hub:group:discussions", "hub:initiativeTemplate:edit"];
|
|
13
13
|
/** Defines the possible editor type values for a stat card. These
|
|
14
14
|
* correspond to the supported/defined uiSchema configurations. This should
|
|
15
15
|
* have its own signature in the getEditorConfig function.
|
|
@@ -27,7 +27,7 @@ export declare const validCardEditorTypes: readonly ["hub:card:stat"];
|
|
|
27
27
|
* to defined schema/uiSchema configurations
|
|
28
28
|
*/
|
|
29
29
|
export declare type EditorType = (typeof validEditorTypes)[number];
|
|
30
|
-
export declare const validEditorTypes: readonly ["hub:project:create", "hub:project:edit", "hub:content:edit", "hub:content:settings", "hub:content:discussions", "hub:initiative:edit", "hub:initiative:create", "hub:site:edit", "hub:site:create", "hub:site:followers", "hub:site:discussions", "hub:site:settings", "hub:discussion:edit", "hub:discussion:create", "hub:discussion:settings", "hub:page:edit", "hub:template:edit", "hub:group:edit", "hub:group:settings", "hub:group:discussions", "hub:initiativeTemplate:edit", "hub:card:stat"];
|
|
30
|
+
export declare const validEditorTypes: readonly ["hub:project:create", "hub:project:edit", "hub:project:metrics", "hub:content:edit", "hub:content:settings", "hub:content:discussions", "hub:initiative:edit", "hub:initiative:create", "hub:site:edit", "hub:site:create", "hub:site:followers", "hub:site:discussions", "hub:site:settings", "hub:discussion:edit", "hub:discussion:create", "hub:discussion:settings", "hub:page:edit", "hub:template:edit", "hub:group:edit", "hub:group:settings", "hub:group:discussions", "hub:initiativeTemplate:edit", "hub:card:stat"];
|
|
31
31
|
export declare enum UiSchemaRuleEffects {
|
|
32
32
|
SHOW = "SHOW",
|
|
33
33
|
HIDE = "HIDE",
|
|
@@ -131,18 +131,3 @@ export interface IUiSchemaCondition {
|
|
|
131
131
|
scope?: string;
|
|
132
132
|
schema: IConfigurationSchema;
|
|
133
133
|
}
|
|
134
|
-
export declare enum ALIGNMENTS {
|
|
135
|
-
start = "start",
|
|
136
|
-
center = "center",
|
|
137
|
-
end = "end"
|
|
138
|
-
}
|
|
139
|
-
export declare enum CORNERS {
|
|
140
|
-
square = "square",
|
|
141
|
-
round = "round"
|
|
142
|
-
}
|
|
143
|
-
export declare enum DROP_SHADOWS {
|
|
144
|
-
none = "none",
|
|
145
|
-
low = "low",
|
|
146
|
-
medium = "medium",
|
|
147
|
-
heavy = "heavy"
|
|
148
|
-
}
|
|
@@ -5,6 +5,7 @@ import { IWithPermissions, IWithViewSettings, IWithDiscussions } from "../traits
|
|
|
5
5
|
import { IHubLocation } from "./IHubLocation";
|
|
6
6
|
import { IWithFollowers } from "../traits/IWithFollowers";
|
|
7
7
|
import { IWithAssociations } from "../traits/IWithAssociations";
|
|
8
|
+
import { IMetricEditorValues } from "./Metrics";
|
|
8
9
|
/**
|
|
9
10
|
* Properties exposed by Entities that are backed by Items
|
|
10
11
|
*/
|
|
@@ -122,4 +123,5 @@ export declare type IHubItemEntityEditor<T> = Omit<T, "extent"> & {
|
|
|
122
123
|
showFollowAction?: boolean;
|
|
123
124
|
isDiscussable?: boolean;
|
|
124
125
|
};
|
|
126
|
+
_metric?: IMetricEditorValues;
|
|
125
127
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="arcgis-js-api" />
|
|
2
2
|
import { IQuery } from "../../search/types/IHubCatalog";
|
|
3
|
-
import { IField } from "@esri/arcgis-rest-types";
|
|
4
|
-
import { ServiceAggregation } from "./DynamicValues";
|
|
3
|
+
import { FieldType, IField } from "@esri/arcgis-rest-types";
|
|
5
4
|
import { IReference } from "./IReference";
|
|
5
|
+
import { ServiceAggregation } from "../../core/types/DynamicValues";
|
|
6
6
|
/**
|
|
7
7
|
* Defines the information required from a Metric
|
|
8
8
|
*/
|
|
@@ -182,6 +182,20 @@ export interface IExpression {
|
|
|
182
182
|
* A special identifier given to the expression when it is created
|
|
183
183
|
*/
|
|
184
184
|
key?: string;
|
|
185
|
+
/**
|
|
186
|
+
* Relation between the values in an expression
|
|
187
|
+
*/
|
|
188
|
+
relationship?: ExpressionRelationships;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Possible relationships for an expression
|
|
192
|
+
* BETWEEN -- used to show between two values, i.e. 7 < x < 10
|
|
193
|
+
* IS_EXACTLY -- for exact matching, i.e. two same strings
|
|
194
|
+
*/
|
|
195
|
+
export declare enum ExpressionRelationships {
|
|
196
|
+
BETWEEN = "between",
|
|
197
|
+
IS_EXACTLY = "isExactly",
|
|
198
|
+
LIKE = "like"
|
|
185
199
|
}
|
|
186
200
|
/**
|
|
187
201
|
* Configuration for how to show a metric in the ui
|
|
@@ -191,3 +205,42 @@ export interface IMetricDisplayConfig {
|
|
|
191
205
|
displayType: string;
|
|
192
206
|
[key: string]: any;
|
|
193
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Editor values expected when editing a metric
|
|
210
|
+
*/
|
|
211
|
+
export interface IMetricEditorValues extends IMetricDisplayConfig {
|
|
212
|
+
/** the main value of the metric */
|
|
213
|
+
value?: string | number;
|
|
214
|
+
/** all values related to constructing a service-query metric */
|
|
215
|
+
dynamicMetric?: IDynamicMetricValues;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Editor values associated with editing a dynamic metric
|
|
219
|
+
*/
|
|
220
|
+
export interface IDynamicMetricValues {
|
|
221
|
+
/** id of the item being queried */
|
|
222
|
+
itemId?: string;
|
|
223
|
+
/** id of the layer of the item being queried */
|
|
224
|
+
layerId?: number;
|
|
225
|
+
/** field of the layer of the item being queried to run the aggregation on */
|
|
226
|
+
field?: string;
|
|
227
|
+
/** the method of service aggregation -- count, min, max, etc. */
|
|
228
|
+
statistic?: string;
|
|
229
|
+
/** the feature service url of the item being queried */
|
|
230
|
+
serviceUrl?: string;
|
|
231
|
+
/** the esri-dictated field type of the field being queried */
|
|
232
|
+
fieldType?: FieldType;
|
|
233
|
+
/** a clause to filter the query by -- ex: field BETWEEN 0 AND 2 */
|
|
234
|
+
where?: string;
|
|
235
|
+
/** the ui navigational link to the item source */
|
|
236
|
+
sourceLink?: string;
|
|
237
|
+
/** the text displayed in the ui for the sourceLink */
|
|
238
|
+
sourceTitle?: string;
|
|
239
|
+
/** whether attribute filtering should be enabled */
|
|
240
|
+
allowExpressionSet?: boolean;
|
|
241
|
+
/** a list of expressions with which to construct a where clause */
|
|
242
|
+
expressionSet?: IExpression[];
|
|
243
|
+
/** the old where clause, utilized during the migration of the old summary stat card */
|
|
244
|
+
legacyWhere?: string;
|
|
245
|
+
[key: string]: any;
|
|
246
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Traverse a graph filtering out entries that do
|
|
3
|
+
* not pass the predicate
|
|
4
|
+
*
|
|
5
|
+
* Note: this util uses cloning behind the scenes
|
|
6
|
+
* so will only work for POJOs and not class instances
|
|
7
|
+
*
|
|
8
|
+
* example:
|
|
9
|
+
* const predicate = (link: any) => link.key !== "00a"
|
|
10
|
+
* const obj = [
|
|
11
|
+
* {
|
|
12
|
+
* key: "001",
|
|
13
|
+
* label: "Stop the Spotted Lanternfly",
|
|
14
|
+
* },
|
|
15
|
+
* {
|
|
16
|
+
* key: "002",
|
|
17
|
+
* label: "Create a Map",
|
|
18
|
+
* children: [
|
|
19
|
+
* {
|
|
20
|
+
* key: "00a",
|
|
21
|
+
* label: "ArcGIS Map Viewer",
|
|
22
|
+
* },
|
|
23
|
+
* {
|
|
24
|
+
* key: "00b",
|
|
25
|
+
* label: "ArcGIS Map Viewer Classic",
|
|
26
|
+
* },
|
|
27
|
+
* ],
|
|
28
|
+
* },
|
|
29
|
+
* ];
|
|
30
|
+
* const res = deepFilter(obj, predicate)
|
|
31
|
+
* res = [
|
|
32
|
+
* {
|
|
33
|
+
* key: "001",
|
|
34
|
+
* label: "Stop the Spotted Lanternfly",
|
|
35
|
+
* },
|
|
36
|
+
* {
|
|
37
|
+
* key: "002",
|
|
38
|
+
* label: "Create a Map",
|
|
39
|
+
* children: [
|
|
40
|
+
* {
|
|
41
|
+
* key: "00b",
|
|
42
|
+
* label: "ArcGIS Map Viewer Classic",
|
|
43
|
+
* },
|
|
44
|
+
* ],
|
|
45
|
+
* },
|
|
46
|
+
* ];
|
|
47
|
+
*
|
|
48
|
+
* @param object
|
|
49
|
+
* @param predicate
|
|
50
|
+
*/
|
|
51
|
+
export declare function deepFilter(object: any, predicate: (object: any) => boolean): any;
|
|
@@ -9,6 +9,7 @@ export * from "./remove-empty-props";
|
|
|
9
9
|
export * from "./deep-string-replace";
|
|
10
10
|
export * from "./merge-objects";
|
|
11
11
|
export * from "./set-prop";
|
|
12
|
+
export * from "./deepFilter";
|
|
12
13
|
export * from "./deepFind";
|
|
13
14
|
export * from "./resolveReferences";
|
|
14
15
|
export * from "./pickProps";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isFindable(object: any): boolean;
|
|
@@ -71,7 +71,7 @@ export declare class HubProject extends HubItemEntity<IHubProject> implements IW
|
|
|
71
71
|
* @param editor
|
|
72
72
|
* @returns
|
|
73
73
|
*/
|
|
74
|
-
fromEditor(editor: IHubProjectEditor): Promise<IHubProject>;
|
|
74
|
+
fromEditor(editor: IHubProjectEditor, editorContext?: IEntityEditorContext): Promise<IHubProject>;
|
|
75
75
|
/**
|
|
76
76
|
* Apply a new state to the instance
|
|
77
77
|
* @param changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IConfigurationSchema } from "../../core/schemas/types";
|
|
2
2
|
export declare type ProjectEditorType = (typeof ProjectEditorTypes)[number];
|
|
3
|
-
export declare const ProjectEditorTypes: readonly ["hub:project:create", "hub:project:edit"];
|
|
3
|
+
export declare const ProjectEditorTypes: readonly ["hub:project:create", "hub:project:edit", "hub:project:metrics"];
|
|
4
4
|
/**
|
|
5
5
|
* Defines the JSON schema for a Hub Project's editable fields
|
|
6
6
|
*/
|