@arcgis/common-components 4.29.0-beta.47 → 4.29.0-beta.49
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/arcgis-common-components/arcgis-common-components.esm.js +1 -1
- package/dist/arcgis-common-components/p-6c7d2684.js +1 -0
- package/dist/arcgis-common-components/p-7318a1d1.entry.js +1 -0
- package/dist/arcgis-common-components/p-a91ab432.js +2 -0
- package/dist/arcgis-common-components/p-d3d1695f.entry.js +1 -0
- package/dist/cjs/arcgis-common-components.cjs.js +3 -3
- package/dist/cjs/arcgis-field-info.cjs.entry.js +903 -899
- package/dist/cjs/arcgis-field-pick-list.cjs.entry.js +216 -229
- package/dist/cjs/{index-2e4fbd31.js → index-5ec7f592.js} +5 -20
- package/dist/cjs/{index-ab5f2576.js → index-e0422bc8.js} +72 -77
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/components/arcgis-field-info.d.ts +2 -2
- package/dist/components/arcgis-field-pick-list.d.ts +2 -2
- package/dist/components/arcgis-field-pick-list.js +259 -272
- package/dist/components/field-info.js +961 -901
- package/dist/esm/arcgis-common-components.js +4 -4
- package/dist/esm/arcgis-field-info.entry.js +907 -903
- package/dist/esm/arcgis-field-pick-list.entry.js +216 -229
- package/dist/esm/{index-74897166.js → index-0c129ec4.js} +73 -78
- package/dist/esm/index-ba4fe890.js +59 -0
- package/dist/esm/loader.js +3 -3
- package/dist/types/components/field-info/field-info.d.ts +61 -61
- package/dist/types/components/field-info/t9n-types.d.ts +72 -72
- package/dist/types/components/field-info/utils/basic.d.ts +24 -24
- package/dist/types/components/field-info/utils/field.d.ts +1 -1
- package/dist/types/components/field-pick-list/field-pick-list.d.ts +115 -115
- package/dist/types/components/field-pick-list/t9n-types.d.ts +15 -15
- package/dist/types/components/field-pick-list/utils/types.d.ts +14 -14
- package/dist/types/components.d.ts +0 -86
- package/dist/types/stencil-public-runtime.d.ts +8 -0
- package/package.json +7 -7
- package/dist/arcgis-common-components/p-0be8fd4c.entry.js +0 -1
- package/dist/arcgis-common-components/p-164eb24e.entry.js +0 -1
- package/dist/arcgis-common-components/p-5ecf6396.js +0 -1
- package/dist/arcgis-common-components/p-97c7ac8d.entry.js +0 -1
- package/dist/arcgis-common-components/p-b23318c8.js +0 -1
- package/dist/arcgis-common-components/p-d66b011b.entry.js +0 -1
- package/dist/arcgis-common-components/p-f27af39c.js +0 -2
- package/dist/cjs/arcgis-api-key.cjs.entry.js +0 -51
- package/dist/cjs/arcgis-identity.cjs.entry.js +0 -139
- package/dist/cjs/index-f8bf4df6.js +0 -7
- package/dist/components/arcgis-api-key.d.ts +0 -11
- package/dist/components/arcgis-api-key.js +0 -69
- package/dist/components/arcgis-identity.d.ts +0 -11
- package/dist/components/arcgis-identity.js +0 -167
- package/dist/components/index2.js +0 -75
- package/dist/esm/arcgis-api-key.entry.js +0 -47
- package/dist/esm/arcgis-identity.entry.js +0 -135
- package/dist/esm/index-3d9bb67e.js +0 -75
- package/dist/esm/index-e7244815.js +0 -3
- package/dist/types/components/api-key/api-key.d.ts +0 -9
- package/dist/types/components/identity/identity.d.ts +0 -31
- package/dist/types/components/types.d.ts +0 -10
|
@@ -1,32 +1,31 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent,
|
|
2
|
-
import {
|
|
3
|
-
import { F, U } from './index-e7244815.js';
|
|
1
|
+
import { r as registerInstance, c as createEvent, g as getAssetPath, h, H as Host, a as getElement, F as Fragment } from './index-0c129ec4.js';
|
|
2
|
+
import { F, a as importCoreLang, b as importConfig, i as importIntl, c as importRestSupportQuery, d as importSmartMappingStatisticsSummaryStatistics, e as importSmartMappingStatisticsUniqueValues, f as importCoreReactiveUtils, U } from './index-ba4fe890.js';
|
|
4
3
|
|
|
5
4
|
var Status;
|
|
6
5
|
(function (Status) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
Status["MISSING"] = "missing";
|
|
7
|
+
Status["IN_PROGRESS"] = "inProgress";
|
|
8
|
+
Status["SUCCESS"] = "success";
|
|
9
|
+
Status["FAILED"] = "failed";
|
|
11
10
|
})(Status || (Status = {}));
|
|
12
11
|
var SimpleFieldTypes;
|
|
13
12
|
(function (SimpleFieldTypes) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
SimpleFieldTypes["NUMBER"] = "number";
|
|
14
|
+
SimpleFieldTypes["STRING"] = "string";
|
|
15
|
+
SimpleFieldTypes["DATE"] = "date";
|
|
16
|
+
SimpleFieldTypes["DATE_ONLY"] = "date-only";
|
|
17
|
+
SimpleFieldTypes["TIME_ONLY"] = "time-only";
|
|
18
|
+
SimpleFieldTypes["TIMESTAMP_OFFSET"] = "timestamp-offset";
|
|
19
|
+
SimpleFieldTypes["OID"] = "oid";
|
|
20
|
+
SimpleFieldTypes["GUID"] = "guid";
|
|
21
|
+
SimpleFieldTypes["UNKNOWN"] = "unknown";
|
|
23
22
|
})(SimpleFieldTypes || (SimpleFieldTypes = {}));
|
|
24
23
|
/**
|
|
25
24
|
* Returns true if the value is defined
|
|
26
25
|
* @param value - value to check
|
|
27
26
|
*/
|
|
28
27
|
function isDefined(value) {
|
|
29
|
-
|
|
28
|
+
return value !== undefined && value !== null;
|
|
30
29
|
}
|
|
31
30
|
/**
|
|
32
31
|
* Returns the URL used for queries.
|
|
@@ -34,10 +33,10 @@ function isDefined(value) {
|
|
|
34
33
|
* @param value - value to check
|
|
35
34
|
*/
|
|
36
35
|
function getQueryURL(layer) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
if (layer.type === "scene") {
|
|
37
|
+
return layer.associatedLayer?.url;
|
|
38
|
+
}
|
|
39
|
+
return layer.url;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
/**
|
|
@@ -45,231 +44,230 @@ function getQueryURL(layer) {
|
|
|
45
44
|
* @param props - properties containing layer and fieldName
|
|
46
45
|
*/
|
|
47
46
|
function getFieldInfo(props) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
47
|
+
const { layer, fieldName } = props;
|
|
48
|
+
let fieldInfo = undefined;
|
|
49
|
+
const { popupTemplate } = layer;
|
|
50
|
+
const popupFieldInfos = popupTemplate ? popupTemplate.fieldInfos : [];
|
|
51
|
+
(layer.type === "imagery-tile"
|
|
52
|
+
? layer.rasterFields
|
|
53
|
+
: layer.type === "imagery" && layer.rasterFields?.length
|
|
54
|
+
? layer.rasterFields
|
|
55
|
+
: layer.fields)
|
|
56
|
+
.filter((layerField) => layerField.name === fieldName)
|
|
57
|
+
.forEach((layerField) => {
|
|
58
|
+
const list = popupFieldInfos
|
|
59
|
+
? popupFieldInfos.filter((fInfo) => fInfo.fieldName === layerField.name)
|
|
60
|
+
: null;
|
|
61
|
+
const label = list?.length ? list[0].label : null;
|
|
62
|
+
if (/^raster.(item|service)pixelvalue/iu.test(fieldName)) {
|
|
63
|
+
// e.g. "Raster.ServicePixelValue" | "Raster.ItemPixelValue" | "Raster.ServicePixelValue.Raw"
|
|
64
|
+
// layer.rasterFields reports them as type "string"
|
|
65
|
+
layerField.type = "double";
|
|
66
|
+
}
|
|
67
|
+
const featureFilterField = {
|
|
68
|
+
layerField,
|
|
69
|
+
label: label || layerField.alias || layerField.name
|
|
70
|
+
};
|
|
71
|
+
featureFilterField.codedValues = getCodedValues(fieldName, props);
|
|
72
|
+
_getSimpleFieldType(featureFilterField);
|
|
73
|
+
if (featureFilterField.simpleFieldType) {
|
|
74
|
+
fieldInfo = featureFilterField;
|
|
75
|
+
} // else can't use field
|
|
76
|
+
});
|
|
77
|
+
return fieldInfo;
|
|
79
78
|
}
|
|
80
79
|
/**
|
|
81
80
|
* Returns feature count in layer
|
|
82
81
|
* @param props - properties containing layer and fieldName
|
|
83
82
|
*/
|
|
84
83
|
async function getFeatureCount(props) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
84
|
+
props.statisticsStatus = Status.IN_PROGRESS;
|
|
85
|
+
const { layer, view } = props;
|
|
86
|
+
if (layer.type === "imagery" || layer.type === "imagery-tile" || layer.type === "stream") {
|
|
87
|
+
throw new Error("could not get feature count");
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
return await getFeatureCountCommon(layer, view);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
96
95
|
}
|
|
97
96
|
/**
|
|
98
97
|
* Returns summary statistics
|
|
99
98
|
* @param props - properties containing layer and fieldName
|
|
100
99
|
*/
|
|
101
100
|
async function getStatistics(props) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
101
|
+
const { layer, view, fieldName, fieldInfo, modules } = props;
|
|
102
|
+
if (layer.type === "imagery" || layer.type === "imagery-tile") {
|
|
103
|
+
throw new Error("could not get statistics for ImageryLayer/ImageryTileLayer");
|
|
104
|
+
}
|
|
105
|
+
if (!fieldInfo ||
|
|
106
|
+
fieldInfo.layerField.type === "oid" ||
|
|
107
|
+
fieldInfo.layerField.type === "guid" ||
|
|
108
|
+
fieldInfo.layerField.type === "global-id") {
|
|
109
|
+
const count = await getFeatureCount(props);
|
|
110
|
+
return Promise.resolve({ totalCount: count, nullcount: 0 } /*StatisticsResult*/);
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
const result = await modules.summaryStatistics({
|
|
114
|
+
layer,
|
|
115
|
+
view,
|
|
116
|
+
field: fieldName
|
|
117
|
+
});
|
|
118
|
+
if (!isDefined(result.count)) {
|
|
119
|
+
// statistics is unusable
|
|
120
|
+
throw new Error("could not get statistics");
|
|
121
|
+
}
|
|
122
|
+
// if we hit maxRecordCount other stats values are probably not correct either
|
|
123
|
+
const hitMaxRecordCount = "sourceJSON" in layer && layer.sourceJSON.maxRecordCount === result.count;
|
|
124
|
+
// count only contains features with a value (!= null)
|
|
125
|
+
if (isDefined(result.nullcount) && !hitMaxRecordCount) {
|
|
126
|
+
// we can add the feature count without null and the count of nulls
|
|
127
|
+
const stats /*StatisticsResult*/ = { ...result, totalCount: result.count + result.nullcount };
|
|
128
|
+
return stats;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
// we want the total feature count
|
|
132
|
+
// happens e.g. for SceneLayers with older stats cache
|
|
133
|
+
const count = await getFeatureCount(props);
|
|
134
|
+
const stats = { ...result, totalCount: count };
|
|
135
|
+
return stats;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
throw new Error("could not get statistics");
|
|
130
140
|
}
|
|
131
|
-
else {
|
|
132
|
-
// we want the total feature count
|
|
133
|
-
// happens e.g. for SceneLayers with older stats cache
|
|
134
|
-
const count = await getFeatureCount(props);
|
|
135
|
-
const stats = { ...result, totalCount: count };
|
|
136
|
-
return stats;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
throw new Error("could not get statistics");
|
|
141
|
-
}
|
|
142
141
|
}
|
|
143
142
|
/**
|
|
144
143
|
* Returns unique values
|
|
145
144
|
* @param props - properties containing layer and fieldName
|
|
146
145
|
*/
|
|
147
146
|
async function getUniqueValues(props) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
147
|
+
const { layer, view, fieldName, modules } = props;
|
|
148
|
+
if (layer.type === "imagery" || layer.type === "imagery-tile") {
|
|
149
|
+
throw new Error("could not get unique values for ImageryLayer/ImageryTileLayer");
|
|
150
|
+
}
|
|
151
|
+
if (layer.type === "feature" && !layer.url) {
|
|
152
|
+
layer.outFields = ["*"];
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
const result = await modules.uniqueValues({
|
|
156
|
+
layer,
|
|
157
|
+
view,
|
|
158
|
+
field: fieldName
|
|
159
|
+
});
|
|
160
|
+
return result;
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
throw new Error("could not get unique values");
|
|
164
|
+
}
|
|
166
165
|
}
|
|
167
166
|
function _getSimpleFieldType(featureFilterField) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
167
|
+
switch (featureFilterField.layerField.type) {
|
|
168
|
+
case "string":
|
|
169
|
+
featureFilterField.simpleFieldType = SimpleFieldTypes.STRING;
|
|
170
|
+
break;
|
|
171
|
+
case "date":
|
|
172
|
+
featureFilterField.simpleFieldType = SimpleFieldTypes.DATE;
|
|
173
|
+
break;
|
|
174
|
+
case "timestamp-offset":
|
|
175
|
+
featureFilterField.simpleFieldType = SimpleFieldTypes.TIMESTAMP_OFFSET;
|
|
176
|
+
break;
|
|
177
|
+
case "date-only":
|
|
178
|
+
featureFilterField.simpleFieldType = SimpleFieldTypes.DATE_ONLY;
|
|
179
|
+
break;
|
|
180
|
+
case "time-only":
|
|
181
|
+
featureFilterField.simpleFieldType = SimpleFieldTypes.TIME_ONLY;
|
|
182
|
+
break;
|
|
183
|
+
case "oid":
|
|
184
|
+
featureFilterField.simpleFieldType = SimpleFieldTypes.OID;
|
|
185
|
+
break;
|
|
186
|
+
case "guid":
|
|
187
|
+
case "global-id":
|
|
188
|
+
featureFilterField.simpleFieldType = SimpleFieldTypes.GUID;
|
|
189
|
+
break;
|
|
190
|
+
case "small-integer":
|
|
191
|
+
case "big-integer":
|
|
192
|
+
case "integer":
|
|
193
|
+
case "single":
|
|
194
|
+
case "double":
|
|
195
|
+
case "long":
|
|
196
|
+
featureFilterField.simpleFieldType = SimpleFieldTypes.NUMBER;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
200
199
|
}
|
|
201
200
|
function getCodedValues(fieldName, props) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
201
|
+
const { layer, modules } = props;
|
|
202
|
+
if (layer.type !== "feature") {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const typeIdField = layer.typeIdField;
|
|
206
|
+
const types = layer.types;
|
|
207
|
+
let fieldDomains = undefined;
|
|
208
|
+
const field = layer.fields.find((field) => field.name === fieldName);
|
|
209
|
+
const fieldDomain = field.domain;
|
|
210
|
+
if (typeIdField && types) {
|
|
211
|
+
// layer has types
|
|
212
|
+
if (typeIdField === fieldName) {
|
|
213
|
+
// this is the field with the types
|
|
214
|
+
fieldDomains = types.map((type) =>
|
|
215
|
+
// fake coded Values
|
|
216
|
+
({
|
|
217
|
+
code: type.id,
|
|
218
|
+
name: type.name
|
|
219
|
+
}));
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
// field does not have types; look farther inside the types
|
|
223
|
+
fieldDomains = [];
|
|
224
|
+
types.forEach((type) => {
|
|
225
|
+
if (!type.domains || !type.domains[fieldName] || type.domains[fieldName].type === "inherited") {
|
|
226
|
+
const domain = fieldDomain;
|
|
227
|
+
if (domain?.codedValues) {
|
|
228
|
+
domain.codedValues.forEach(async (codedValue) => {
|
|
229
|
+
let found = false;
|
|
230
|
+
fieldDomains.forEach((codedVal) => {
|
|
231
|
+
if (codedVal.code === codedValue.code) {
|
|
232
|
+
found = true;
|
|
233
|
+
if (`, ${codedVal.name},`.indexOf(`, ${codedValue.name},`) === -1) {
|
|
234
|
+
codedVal.name += `, ${codedValue.name}`;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
if (!found) {
|
|
239
|
+
fieldDomains.push(modules.esriLang.clone(codedValue));
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}
|
|
238
243
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
244
|
+
else if (type.domains?.[fieldName]?.codedValues) {
|
|
245
|
+
type.domains[fieldName].codedValues.forEach(async (codedValue) => {
|
|
246
|
+
let found = false;
|
|
247
|
+
fieldDomains.forEach((codedVal) => {
|
|
248
|
+
if (codedVal.code === codedValue.code) {
|
|
249
|
+
found = true;
|
|
250
|
+
if (`, ${codedVal.name},`.indexOf(`, ${codedValue.name},`) === -1) {
|
|
251
|
+
codedVal.name += `, ${codedValue.name}`;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
if (!found) {
|
|
256
|
+
fieldDomains.push(modules.esriLang.clone(codedValue));
|
|
257
|
+
}
|
|
258
|
+
});
|
|
254
259
|
}
|
|
255
|
-
}
|
|
256
260
|
});
|
|
257
|
-
if (!found) {
|
|
258
|
-
fieldDomains.push(modules.esriLang.clone(codedValue));
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
261
|
}
|
|
262
|
-
|
|
262
|
+
if (!fieldDomains?.length && fieldDomain?.codedValues) {
|
|
263
|
+
fieldDomains = modules.esriLang.clone(fieldDomain.codedValues);
|
|
264
|
+
}
|
|
263
265
|
}
|
|
264
|
-
if (
|
|
265
|
-
|
|
266
|
+
else if (fieldDomain?.codedValues) {
|
|
267
|
+
// domains directly on the layer field
|
|
268
|
+
fieldDomains = field.domain.codedValues;
|
|
266
269
|
}
|
|
267
|
-
|
|
268
|
-
else if (fieldDomain?.codedValues) {
|
|
269
|
-
// domains directly on the layer field
|
|
270
|
-
fieldDomains = field.domain.codedValues;
|
|
271
|
-
}
|
|
272
|
-
return fieldDomains?.length ? fieldDomains : null;
|
|
270
|
+
return fieldDomains?.length ? fieldDomains : null;
|
|
273
271
|
}
|
|
274
272
|
|
|
275
273
|
/**
|
|
@@ -277,66 +275,66 @@ function getCodedValues(fieldName, props) {
|
|
|
277
275
|
* @param props - properties containing layer and view
|
|
278
276
|
*/
|
|
279
277
|
async function getOneFeature(props) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
else {
|
|
299
|
-
// service
|
|
300
|
-
if (!view) {
|
|
301
|
-
// get feature from service directly
|
|
302
|
-
return _queryOneFeature(props);
|
|
303
|
-
}
|
|
304
|
-
const layerView = (await view.whenLayerView(layer));
|
|
305
|
-
const hasAllFields = layerView.availableFields.length === layer.fields.length;
|
|
306
|
-
if (hasAllFields || (["stream", "ogc-feature"].indexOf(layer.type) > -1 && layerView.availableFields.length > 0)) {
|
|
307
|
-
// features on client have all fields
|
|
308
|
-
// or we can't make a server query, so we take what we can get
|
|
309
|
-
const query = layer.createQuery();
|
|
310
|
-
query.start = 0;
|
|
311
|
-
query.num = 5;
|
|
312
|
-
query.outFields = ["*"];
|
|
313
|
-
const result = await layerView.queryFeatures(query);
|
|
314
|
-
if (result.features?.length) {
|
|
315
|
-
// client side features
|
|
316
|
-
return result;
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
// get feature from service
|
|
320
|
-
return _queryOneFeature(props);
|
|
321
|
-
}
|
|
278
|
+
const { view, layer } = props;
|
|
279
|
+
if (layer.type === "imagery" || layer.type === "imagery-tile") {
|
|
280
|
+
throw new Error("could not get feature");
|
|
281
|
+
}
|
|
282
|
+
if ((layer.type === "feature" && !layer.url) || layer.type === "wfs") {
|
|
283
|
+
// feature collection or wfs
|
|
284
|
+
const query = layer.createQuery();
|
|
285
|
+
query.start = 0;
|
|
286
|
+
query.num = 5;
|
|
287
|
+
query.outFields = ["*"];
|
|
288
|
+
const result = await layer.queryFeatures(query);
|
|
289
|
+
if (result.features?.length) {
|
|
290
|
+
return result;
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
throw new Error("could not get feature");
|
|
294
|
+
}
|
|
322
295
|
}
|
|
323
296
|
else {
|
|
324
|
-
|
|
325
|
-
|
|
297
|
+
// service
|
|
298
|
+
if (!view) {
|
|
299
|
+
// get feature from service directly
|
|
300
|
+
return _queryOneFeature(props);
|
|
301
|
+
}
|
|
302
|
+
const layerView = (await view.whenLayerView(layer));
|
|
303
|
+
const hasAllFields = layerView.availableFields.length === layer.fields.length;
|
|
304
|
+
if (hasAllFields || (["stream", "ogc-feature"].indexOf(layer.type) > -1 && layerView.availableFields.length > 0)) {
|
|
305
|
+
// features on client have all fields
|
|
306
|
+
// or we can't make a server query, so we take what we can get
|
|
307
|
+
const query = layer.createQuery();
|
|
308
|
+
query.start = 0;
|
|
309
|
+
query.num = 5;
|
|
310
|
+
query.outFields = ["*"];
|
|
311
|
+
const result = await layerView.queryFeatures(query);
|
|
312
|
+
if (result.features?.length) {
|
|
313
|
+
// client side features
|
|
314
|
+
return result;
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
// get feature from service
|
|
318
|
+
return _queryOneFeature(props);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
// get feature from service
|
|
323
|
+
return _queryOneFeature(props);
|
|
324
|
+
}
|
|
326
325
|
}
|
|
327
|
-
}
|
|
328
326
|
}
|
|
329
327
|
async function _queryOneFeature(props) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
328
|
+
const { layer, modules } = props;
|
|
329
|
+
if (["imagery", "imagery-tile", "stream", "ogc-feature"].indexOf(layer.type) > -1) {
|
|
330
|
+
throw new Error("cannot get feature from service");
|
|
331
|
+
}
|
|
332
|
+
const query = new modules.Query({
|
|
333
|
+
where: "1=1",
|
|
334
|
+
outFields: ["*"],
|
|
335
|
+
returnGeometry: false
|
|
336
|
+
});
|
|
337
|
+
return layer.queryFeatures(query);
|
|
340
338
|
}
|
|
341
339
|
/**
|
|
342
340
|
* Returns feature count of layer
|
|
@@ -344,673 +342,679 @@ async function _queryOneFeature(props) {
|
|
|
344
342
|
* @param mapView - View
|
|
345
343
|
*/
|
|
346
344
|
async function getFeatureCountCommon(layer, view) {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
345
|
+
if (layer.type === "feature" && !layer.url) {
|
|
346
|
+
return getFeatureCountForCollection(layer);
|
|
347
|
+
}
|
|
348
|
+
else if (layer.type === "feature" ||
|
|
349
|
+
layer.type === "csv" ||
|
|
350
|
+
layer.type === "scene" ||
|
|
351
|
+
layer.type === "wfs" ||
|
|
352
|
+
layer.type === "geojson") {
|
|
353
|
+
return await layer.queryFeatureCount();
|
|
354
|
+
}
|
|
355
|
+
else if (view && (layer.type === "stream" || layer.type === "ogc-feature")) {
|
|
356
|
+
return getFeatureCountFromView(layer, view);
|
|
357
|
+
}
|
|
358
|
+
return undefined;
|
|
361
359
|
}
|
|
362
360
|
/**
|
|
363
361
|
* Returns feature count of feature collection layer
|
|
364
362
|
* @param layer - FeatureLayer
|
|
365
363
|
*/
|
|
366
364
|
async function getFeatureCountForCollection(layer) {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
365
|
+
const query = layer.createQuery();
|
|
366
|
+
query.outFields = ["*"];
|
|
367
|
+
const result = await layer.queryFeatures(query);
|
|
368
|
+
if (result.features?.length) {
|
|
369
|
+
return result.features.length;
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
throw new Error("could not get feature count");
|
|
373
|
+
}
|
|
376
374
|
}
|
|
377
375
|
/**
|
|
378
376
|
* Returns feature count of feature collection layer
|
|
379
377
|
* @param layer - StreamLayer | OGCFeatureLayer
|
|
380
378
|
*/
|
|
381
379
|
async function getFeatureCountFromView(layer, view) {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
380
|
+
// we can only get the features from the map
|
|
381
|
+
const layerView = (await view.whenLayerView(layer));
|
|
382
|
+
return layerView.queryFeatureCount();
|
|
385
383
|
}
|
|
386
384
|
|
|
387
385
|
const fieldInfoScss = ":host{height:100%}.container{padding:6px;background-color:white}.title{font-weight:bold;padding:5px 0}.missing{color:#a9a9a9}.data{color:#a9a9a9}.count{white-space:nowrap}.section{padding:6px 0}.statistics-row{border-top:1px solid #e0e0e0;padding:6px 0;display:flex;justify-content:space-between}.statistics-row-top-values{border-top:1px solid #e0e0e0;padding:20px 0 6px 0;display:flex;justify-content:space-between}";
|
|
388
386
|
|
|
389
387
|
const ArcgisFieldInfo = class {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
388
|
+
constructor(hostRef) {
|
|
389
|
+
registerInstance(this, hostRef);
|
|
390
|
+
this.arcgisFieldInfoComplete = createEvent(this, "arcgisFieldInfoComplete", 7);
|
|
391
|
+
this.view = undefined;
|
|
392
|
+
this.layer = undefined;
|
|
393
|
+
this.fieldName = undefined;
|
|
394
|
+
this.hideStatistics = false;
|
|
395
|
+
this.oneFeatureResponse = undefined;
|
|
396
|
+
this.oneFeatureResponseStatus = Status.MISSING;
|
|
397
|
+
this.statistics = undefined;
|
|
398
|
+
this.statisticsStatus = Status.MISSING;
|
|
399
|
+
this.uniqueValues = undefined;
|
|
400
|
+
this.uniqueValuesStatus = Status.MISSING;
|
|
401
|
+
this._lang = "";
|
|
402
|
+
this._t9nLocale = "";
|
|
403
|
+
this._t9nStrings = undefined;
|
|
404
|
+
}
|
|
405
|
+
//--------------------------------------------------------------------------
|
|
406
|
+
//
|
|
407
|
+
// Lifecycle
|
|
408
|
+
//
|
|
409
|
+
//--------------------------------------------------------------------------
|
|
410
|
+
async componentWillLoad() {
|
|
411
|
+
await F(this, getAssetPath("./assets"));
|
|
412
|
+
const esriLang = await importCoreLang();
|
|
413
|
+
const esriConfig = await importConfig();
|
|
414
|
+
const intl = await importIntl();
|
|
415
|
+
const Query = await importRestSupportQuery();
|
|
416
|
+
const summaryStatistics = await importSmartMappingStatisticsSummaryStatistics();
|
|
417
|
+
const uniqueValues = await importSmartMappingStatisticsUniqueValues();
|
|
418
|
+
const { view, layer, fieldName, hideStatistics } = this;
|
|
419
|
+
let sublayerFL;
|
|
420
|
+
if (layer.declaredClass === "esri.layers.support.Sublayer") {
|
|
421
|
+
// need to create a FeatureLayer
|
|
422
|
+
const sublayer = layer;
|
|
423
|
+
const { whenOnce } = await importCoreReactiveUtils();
|
|
424
|
+
if (view)
|
|
425
|
+
await whenOnce(() => !view.updating);
|
|
426
|
+
sublayerFL = await sublayer.createFeatureLayer();
|
|
427
|
+
await sublayerFL.load();
|
|
428
|
+
}
|
|
429
|
+
this.props = {
|
|
430
|
+
view,
|
|
431
|
+
layer: sublayerFL || layer,
|
|
432
|
+
fieldName,
|
|
433
|
+
hideStatistics,
|
|
434
|
+
modules: { esriLang, esriConfig, intl, Query, summaryStatistics, uniqueValues }
|
|
435
|
+
};
|
|
436
|
+
// required for initial load
|
|
437
|
+
this.props.fieldInfo = getFieldInfo(this.props);
|
|
438
|
+
// we don't know if the SceneLayer has an associated FL
|
|
439
|
+
// don't prompt for a login if it's not accessible
|
|
440
|
+
if (layer.type === "scene") {
|
|
441
|
+
esriConfig.request.interceptors?.push({
|
|
442
|
+
urls: `${getQueryURL(layer)}/${layer.layerId}`,
|
|
443
|
+
before(params) {
|
|
444
|
+
params.requestOptions.authMode = "no-prompt";
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
this.oneFeatureResponseStatus = Status.IN_PROGRESS;
|
|
449
|
+
try {
|
|
450
|
+
const result = await getOneFeature(this.props);
|
|
451
|
+
this.oneFeatureResponse = result;
|
|
452
|
+
this.oneFeatureResponseStatus = Status.SUCCESS;
|
|
453
|
+
}
|
|
454
|
+
catch (error) {
|
|
455
|
+
this.oneFeatureResponseStatus = Status.FAILED;
|
|
456
|
+
}
|
|
457
|
+
if (layer.type === "stream") {
|
|
458
|
+
this.uniqueValuesStatus = Status.FAILED;
|
|
459
|
+
this.statisticsStatus = Status.FAILED;
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
if (hideStatistics) {
|
|
463
|
+
this.uniqueValuesStatus = Status.FAILED;
|
|
464
|
+
}
|
|
465
|
+
else {
|
|
466
|
+
this.uniqueValuesStatus = Status.IN_PROGRESS;
|
|
467
|
+
try {
|
|
468
|
+
const uniqueValues = await getUniqueValues(this.props);
|
|
469
|
+
this.uniqueValues = uniqueValues;
|
|
470
|
+
if (uniqueValues?.uniqueValueInfos?.length) {
|
|
471
|
+
this.uniqueValuesStatus = Status.SUCCESS;
|
|
472
|
+
}
|
|
473
|
+
else {
|
|
474
|
+
this.uniqueValuesStatus = Status.FAILED;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
catch (error) {
|
|
478
|
+
this.uniqueValuesStatus = Status.FAILED;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if (hideStatistics) {
|
|
482
|
+
this.statisticsStatus = Status.FAILED;
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
this.statisticsStatus = Status.IN_PROGRESS;
|
|
486
|
+
try {
|
|
487
|
+
const statistics = await getStatistics(this.props);
|
|
488
|
+
if (!isDefined(statistics.totalCount) &&
|
|
489
|
+
isDefined(statistics.count) &&
|
|
490
|
+
this.uniqueValuesStatus === Status.SUCCESS) {
|
|
491
|
+
// take null values count from unique values and add with non-null count from statistics
|
|
492
|
+
const infos = this.uniqueValues.uniqueValueInfos;
|
|
493
|
+
for (let i = 0; i < infos.length; i += 1) {
|
|
494
|
+
const info = infos[i];
|
|
495
|
+
if (info.value === null) {
|
|
496
|
+
statistics.totalCount = info.count + statistics.count;
|
|
497
|
+
break;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
if (!isDefined(statistics.totalCount)) {
|
|
501
|
+
// no null values
|
|
502
|
+
statistics.totalCount = statistics.count;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
this.statistics = statistics;
|
|
506
|
+
this.statisticsStatus = Status.SUCCESS;
|
|
507
|
+
}
|
|
508
|
+
catch (error) {
|
|
509
|
+
this.statisticsStatus = Status.FAILED;
|
|
510
|
+
}
|
|
446
511
|
}
|
|
447
|
-
});
|
|
448
512
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
513
|
+
async componentDidLoad() {
|
|
514
|
+
// once component is visible make other calls
|
|
515
|
+
const { props } = this;
|
|
516
|
+
const { modules } = props;
|
|
517
|
+
modules.intl.setLocale(this._lang);
|
|
518
|
+
// modules.intl.setLocale(this.locale) not returning the correct formatting for e.g. it-ch
|
|
519
|
+
}
|
|
520
|
+
disconnectedCallback() {
|
|
521
|
+
U(this);
|
|
522
|
+
}
|
|
523
|
+
// --------------------------------------------------------------------------
|
|
524
|
+
//
|
|
525
|
+
// Render Methods
|
|
526
|
+
//
|
|
527
|
+
//--------------------------------------------------------------------------
|
|
528
|
+
render() {
|
|
529
|
+
const { props } = this;
|
|
530
|
+
const { fieldInfo } = props;
|
|
531
|
+
if (!fieldInfo) {
|
|
532
|
+
return h(Fragment, null);
|
|
533
|
+
}
|
|
534
|
+
return (h(Host, null, h("div", { class: "container" }, this.renderFieldType(), this.renderFieldAlias(), this.renderFieldDescription(), this.renderFieldValueType(), this.renderFieldSampleValue(), this.renderFieldFormat(), this.renderFieldStatistics())));
|
|
535
|
+
}
|
|
536
|
+
renderFieldType() {
|
|
537
|
+
const { _t9nStrings, props } = this;
|
|
538
|
+
const { fieldInfo } = props;
|
|
539
|
+
const fieldType = this._getFieldTypeLabel(fieldInfo.layerField.type);
|
|
540
|
+
return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldType), h("div", null, fieldType)));
|
|
541
|
+
}
|
|
542
|
+
renderFieldAlias() {
|
|
543
|
+
const { _t9nStrings, props } = this;
|
|
544
|
+
const { fieldInfo } = props;
|
|
545
|
+
return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldAlias), h("div", null, fieldInfo.label)));
|
|
546
|
+
}
|
|
547
|
+
renderFieldDescription() {
|
|
548
|
+
const { _t9nStrings, props } = this;
|
|
549
|
+
const { layer } = props;
|
|
550
|
+
if (layer.type !== "feature") {
|
|
551
|
+
return h(Fragment, null);
|
|
552
|
+
}
|
|
553
|
+
const { fieldInfo } = props;
|
|
554
|
+
const description = fieldInfo.layerField.description;
|
|
555
|
+
return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldDescription), h("div", { class: {
|
|
556
|
+
missing: !description
|
|
557
|
+
} }, description || _t9nStrings.fieldDescriptionNotSet)));
|
|
558
|
+
}
|
|
559
|
+
renderFieldValueType() {
|
|
560
|
+
const { _t9nStrings, props } = this;
|
|
561
|
+
const { layer } = props;
|
|
562
|
+
if (layer.type !== "feature") {
|
|
563
|
+
return h(Fragment, null);
|
|
564
|
+
}
|
|
565
|
+
const { fieldInfo } = props;
|
|
566
|
+
const fieldValueType = this._getFieldValueTypeCamelCase(fieldInfo);
|
|
567
|
+
return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldValueType), h("div", { class: !fieldValueType ? "missing" : "" }, fieldValueType
|
|
568
|
+
? _t9nStrings.fieldValueTypes[fieldValueType]
|
|
569
|
+
: _t9nStrings.fieldValueTypeNotSet)));
|
|
570
|
+
}
|
|
571
|
+
renderFieldSampleValue() {
|
|
572
|
+
const { oneFeatureResponse, oneFeatureResponseStatus, statisticsStatus, statistics, uniqueValuesStatus, uniqueValues, _t9nStrings, props } = this;
|
|
573
|
+
const { layer, fieldName, fieldInfo } = props;
|
|
574
|
+
const { statistics: statStrings } = _t9nStrings;
|
|
575
|
+
let value;
|
|
576
|
+
if (["imagery", "imagery-tile"].indexOf(layer.type) > -1) {
|
|
577
|
+
return h(Fragment, null);
|
|
578
|
+
}
|
|
579
|
+
if (layer.type !== "stream" &&
|
|
580
|
+
[SimpleFieldTypes.STRING, SimpleFieldTypes.OID, SimpleFieldTypes.GUID].indexOf(this._getStatisticsType(fieldInfo)) > -1 &&
|
|
581
|
+
uniqueValuesStatus !== Status.FAILED) {
|
|
582
|
+
// we show top values
|
|
583
|
+
return h(Fragment, null);
|
|
584
|
+
}
|
|
585
|
+
if (oneFeatureResponseStatus === Status.SUCCESS) {
|
|
586
|
+
// find first valid value entry
|
|
587
|
+
oneFeatureResponse.features.forEach((feature) => {
|
|
588
|
+
if (value === undefined || (value === null && feature.attributes[fieldName] !== null)) {
|
|
589
|
+
value = feature.attributes[fieldName];
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
else if (statisticsStatus === Status.SUCCESS) {
|
|
594
|
+
// use statistics min value
|
|
595
|
+
value = statistics.min;
|
|
596
|
+
}
|
|
597
|
+
else if (uniqueValuesStatus === Status.SUCCESS) {
|
|
598
|
+
// use a non-null value
|
|
599
|
+
value = uniqueValues.uniqueValueInfos?.[0]?.value || uniqueValues.uniqueValueInfos?.[1]?.value;
|
|
600
|
+
}
|
|
601
|
+
const codedValues = fieldInfo.codedValues;
|
|
602
|
+
if (isDefined(value)) {
|
|
603
|
+
if (codedValues) {
|
|
604
|
+
value = codedValues.find((codedValue) => value === codedValue.code)?.name || value;
|
|
605
|
+
}
|
|
606
|
+
else {
|
|
607
|
+
value = this._getDisplayString(value);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldSampleValue), h("div", { class: (oneFeatureResponseStatus === Status.FAILED &&
|
|
611
|
+
statisticsStatus === Status.FAILED &&
|
|
612
|
+
uniqueValuesStatus === Status.FAILED) ||
|
|
613
|
+
!isDefined(value)
|
|
614
|
+
? "missing"
|
|
615
|
+
: "" }, oneFeatureResponseStatus === Status.SUCCESS ||
|
|
616
|
+
statisticsStatus === Status.SUCCESS ||
|
|
617
|
+
uniqueValuesStatus === Status.SUCCESS
|
|
618
|
+
? !isDefined(value)
|
|
619
|
+
? statStrings.allNulls
|
|
620
|
+
: `${value}`
|
|
621
|
+
: oneFeatureResponseStatus === Status.FAILED &&
|
|
622
|
+
statisticsStatus === Status.FAILED &&
|
|
623
|
+
uniqueValuesStatus === Status.FAILED
|
|
624
|
+
? _t9nStrings.fieldSampleNotAvailable
|
|
625
|
+
: _t9nStrings.fieldSampleRetrieving)));
|
|
626
|
+
}
|
|
627
|
+
renderFieldFormat() {
|
|
628
|
+
const { _t9nStrings, props } = this;
|
|
629
|
+
const { fieldName, fieldInfo, layer } = props;
|
|
630
|
+
if (["single", "double", "long"].indexOf(fieldInfo.layerField.type) === -1) {
|
|
631
|
+
return h(Fragment, null);
|
|
632
|
+
}
|
|
633
|
+
const popupTemplate = layer.popupTemplate;
|
|
634
|
+
if (popupTemplate?.fieldInfos) {
|
|
635
|
+
const popFieldInfos = popupTemplate.fieldInfos?.filter((fieldInfo) => fieldInfo.fieldName === fieldName);
|
|
636
|
+
if (popFieldInfos?.length) {
|
|
637
|
+
const popFieldInfo = popFieldInfos[0];
|
|
638
|
+
if (isDefined(popFieldInfo?.format?.places)) {
|
|
639
|
+
const num = popFieldInfo.format.places;
|
|
640
|
+
return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldDecimalPlaces), h("div", null,
|
|
641
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
642
|
+
_t9nStrings.fieldNumDecimalPlaces.replace("${number}", num.toString()))));
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldDecimalPlaces), h("div", { class: "missing" }, _t9nStrings.fieldDecimalPlacesNotAvailable)));
|
|
647
|
+
}
|
|
648
|
+
renderFieldStatistics() {
|
|
649
|
+
const { statisticsStatus, uniqueValuesStatus, hideStatistics, _t9nStrings, props } = this;
|
|
650
|
+
const { layer, fieldInfo } = props;
|
|
651
|
+
if (hideStatistics) {
|
|
652
|
+
this.arcgisFieldInfoComplete.emit();
|
|
653
|
+
return h(Fragment, null);
|
|
654
|
+
}
|
|
655
|
+
if (["stream", "imagery", "imagery-tile"].indexOf(layer.type) > -1 ||
|
|
656
|
+
["long"].indexOf(fieldInfo.layerField.type) > -1) {
|
|
657
|
+
// can't get statistics
|
|
658
|
+
this.arcgisFieldInfoComplete.emit();
|
|
659
|
+
return h(Fragment, null);
|
|
660
|
+
}
|
|
661
|
+
return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldStatistics), !statisticsStatus || statisticsStatus === Status.MISSING || statisticsStatus === Status.IN_PROGRESS ? (h("div", { key: "field-info-statistics-content", class: "missing" }, _t9nStrings.fieldStatisticsRetrieving)) : statisticsStatus === Status.FAILED && uniqueValuesStatus !== Status.SUCCESS ? (this.renderNoStatistics()) : (h("div", { key: "field-info-statistics-content", ref: () => this.arcgisFieldInfoComplete.emit() }, this.renderStatistics()))));
|
|
662
|
+
}
|
|
663
|
+
renderNoStatistics() {
|
|
664
|
+
const { _t9nStrings } = this;
|
|
665
|
+
return (h("div", { key: "field-info-statistics-content", ref: () => this.arcgisFieldInfoComplete.emit(), class: "missing" }, _t9nStrings.fieldStatisticsNotAvailable));
|
|
666
|
+
}
|
|
667
|
+
renderStatistics() {
|
|
668
|
+
const { props } = this;
|
|
669
|
+
const { fieldInfo } = props;
|
|
670
|
+
switch (this._getStatisticsType(fieldInfo)) {
|
|
671
|
+
case SimpleFieldTypes.NUMBER:
|
|
672
|
+
return this.renderNumberStatistics();
|
|
673
|
+
case SimpleFieldTypes.STRING:
|
|
674
|
+
case SimpleFieldTypes.OID:
|
|
675
|
+
case SimpleFieldTypes.GUID:
|
|
676
|
+
return this.renderStringStatistics();
|
|
677
|
+
case SimpleFieldTypes.DATE:
|
|
678
|
+
case SimpleFieldTypes.DATE_ONLY:
|
|
679
|
+
case SimpleFieldTypes.TIME_ONLY:
|
|
680
|
+
case SimpleFieldTypes.TIMESTAMP_OFFSET:
|
|
681
|
+
return this.renderDateStatistics();
|
|
682
|
+
default:
|
|
683
|
+
return h(Fragment, null);
|
|
684
|
+
}
|
|
454
685
|
}
|
|
455
|
-
|
|
456
|
-
|
|
686
|
+
renderNumberStatistics() {
|
|
687
|
+
const { statistics, _t9nStrings } = this;
|
|
688
|
+
if (!statistics) {
|
|
689
|
+
return this.renderNoStatistics();
|
|
690
|
+
}
|
|
691
|
+
const { statistics: statStrings } = _t9nStrings;
|
|
692
|
+
return (h("div", null, h("div", { class: "statistics-row" }, h("div", null, statStrings.numberOfValues), h("div", { class: "data" }, this._printNumValue(statistics.totalCount))), isDefined(statistics.sum) ? (h("div", { class: "statistics-row" }, h("div", null, statStrings.sumOfValues), h("div", { class: "data" }, this._printNumValue(statistics.sum)))) : null, isDefined(statistics.min) ? (h("div", { class: "statistics-row" }, h("div", null, statStrings.minimum), h("div", { class: "data" }, this._printNumValue(statistics.min)))) : null, isDefined(statistics.max) ? (h("div", { class: "statistics-row" }, h("div", null, statStrings.maximum), h("div", { class: "data" }, this._printNumValue(statistics.max)))) : null, isDefined(statistics.avg) ? (h("div", { class: "statistics-row" }, h("div", null, statStrings.average), h("div", { class: "data" }, this._printNumValue(statistics.avg)))) : null, isDefined(statistics.stddev) ? (h("div", { class: "statistics-row" }, h("div", null, statStrings.standardDeviation), h("div", { class: "data" }, this._printNumValue(statistics.stddev)))) : null, this.renderNullValues()));
|
|
693
|
+
}
|
|
694
|
+
renderStringStatistics() {
|
|
695
|
+
const { statistics, uniqueValuesStatus, _t9nStrings } = this;
|
|
696
|
+
const { statistics: statStrings } = _t9nStrings;
|
|
697
|
+
return (h("div", null, h("div", { class: "statistics-row" }, h("div", null, statStrings.numberOfValues), uniqueValuesStatus !== Status.SUCCESS ? (h("div", { class: "missing" }, "--")) : (h("div", { class: "data" }, this._printNumValue(statistics?.totalCount)))), this.renderNullValues(), this.renderTopValues()));
|
|
698
|
+
}
|
|
699
|
+
renderDateStatistics() {
|
|
700
|
+
// TODO UTC offset
|
|
701
|
+
const { statistics, view, props, _t9nStrings } = this;
|
|
702
|
+
const { fieldInfo } = props;
|
|
703
|
+
if (!statistics) {
|
|
704
|
+
return this.renderNoStatistics();
|
|
705
|
+
}
|
|
706
|
+
const { statistics: statStrings } = _t9nStrings;
|
|
707
|
+
const dateRange = statistics.max - statistics.min;
|
|
708
|
+
const years = Math.floor(dateRange / 31536000000);
|
|
709
|
+
let months = Math.floor((dateRange - years * 31536000000) / 2628000000);
|
|
710
|
+
let days = Math.ceil((dateRange - months * 2628000000) / 86400000);
|
|
711
|
+
if (days >= 30) {
|
|
712
|
+
months += 1;
|
|
713
|
+
days = 0;
|
|
714
|
+
}
|
|
715
|
+
let timeSpan = years === 1
|
|
716
|
+
? statStrings.timeSpanOptions.year
|
|
717
|
+
: years > 1
|
|
718
|
+
? // eslint-disable-next-line no-template-curly-in-string
|
|
719
|
+
statStrings.timeSpanOptions.years.replace("${years}", years.toString())
|
|
720
|
+
: "";
|
|
721
|
+
timeSpan += years > 0 && (months > 0 || days > 0) ? ", " : "";
|
|
722
|
+
timeSpan +=
|
|
723
|
+
months === 1
|
|
724
|
+
? statStrings.timeSpanOptions.month
|
|
725
|
+
: months > 1
|
|
726
|
+
? // eslint-disable-next-line no-template-curly-in-string
|
|
727
|
+
statStrings.timeSpanOptions.months.replace("${months}", months.toString())
|
|
728
|
+
: "";
|
|
729
|
+
timeSpan += months > 0 && days > 0 ? ", " : "";
|
|
730
|
+
timeSpan +=
|
|
731
|
+
days === 1
|
|
732
|
+
? statStrings.timeSpanOptions.day
|
|
733
|
+
: days > 1
|
|
734
|
+
? // eslint-disable-next-line no-template-curly-in-string
|
|
735
|
+
statStrings.timeSpanOptions.days.replace("${days}", days.toString())
|
|
736
|
+
: "";
|
|
737
|
+
const showStats = fieldInfo.simpleFieldType !== SimpleFieldTypes.TIMESTAMP_OFFSET ||
|
|
738
|
+
!view ||
|
|
739
|
+
view.timeZone !== "unknown";
|
|
740
|
+
const isTimeOnly = fieldInfo.simpleFieldType === SimpleFieldTypes.TIME_ONLY;
|
|
741
|
+
return (h("div", null, h("div", { class: "statistics-row" }, h("div", null, statStrings.numberOfValues), h("div", { class: "data" }, this._printNumValue(statistics?.totalCount))), showStats && isDefined(statistics.min) ? (h("div", { class: "statistics-row" }, h("div", null, isTimeOnly ? statStrings.minimumTime : statStrings.minimumDate), h("div", { class: "data" }, `${this._getDisplayString(statistics.min)}`))) : null, showStats && isDefined(statistics.max) ? (h("div", { class: "statistics-row" }, h("div", null, isTimeOnly ? statStrings.maximumTime : statStrings.maximumDate), h("div", { class: "data" }, `${this._getDisplayString(statistics.max)}`))) : null, showStats && isDefined(statistics.avg) ? (h("div", { class: "statistics-row" }, h("div", null, isTimeOnly ? statStrings.averageTime : statStrings.averageDate), h("div", { class: "data" }, `${this._getDisplayString(statistics.avg)}`))) : null, showStats && !isTimeOnly && isDefined(statistics.min) && isDefined(statistics.max) && dateRange > 0 ? (h("div", { class: "statistics-row" }, h("div", null, statStrings.timespan), h("div", { class: "data" }, timeSpan))) : null, this.renderNullValues()));
|
|
742
|
+
}
|
|
743
|
+
renderTopValues() {
|
|
744
|
+
const { uniqueValues, uniqueValuesStatus, _t9nStrings, props } = this;
|
|
745
|
+
const { fieldInfo } = props;
|
|
746
|
+
const { statistics: statStrings } = _t9nStrings;
|
|
747
|
+
if (uniqueValues?.uniqueValueInfos?.length) {
|
|
748
|
+
const infos = uniqueValues.uniqueValueInfos;
|
|
749
|
+
infos.sort((a, b) => (a.count < b.count ? 1 : a.count > b.count ? -1 : 0));
|
|
750
|
+
const codedValues = fieldInfo.codedValues;
|
|
751
|
+
const values = infos
|
|
752
|
+
.filter((info) => info.value !== null)
|
|
753
|
+
.filter((info, idx) => info && idx < 10)
|
|
754
|
+
.map((info) => {
|
|
755
|
+
let value = info.value;
|
|
756
|
+
if (codedValues) {
|
|
757
|
+
codedValues.forEach((codeValue) => {
|
|
758
|
+
if (value === codeValue.code) {
|
|
759
|
+
value = codeValue.name;
|
|
760
|
+
}
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
else {
|
|
764
|
+
value = this._getDisplayString(value);
|
|
765
|
+
}
|
|
766
|
+
return (h("div", { class: "statistics-row" }, h("div", { class: "data" }, `${value}`), h("div", { class: `$"data" $"count"` }, this._printNumValue(info.count))));
|
|
767
|
+
});
|
|
768
|
+
if (!values.length) {
|
|
769
|
+
return h(Fragment, null);
|
|
770
|
+
}
|
|
771
|
+
return (h("div", null, h("div", { class: "statistics-row-top-values" }, h("div", null, infos.length > 10 ? statStrings.topTenValues : statStrings.topValues), h("div", null, statStrings.count)), values));
|
|
772
|
+
}
|
|
773
|
+
else {
|
|
774
|
+
return (h("div", null, h("div", { class: "statistics-row-top-values" }, h("div", null, statStrings.topValues), h("div", null, statStrings.count)), h("div", { class: "statistics-row" }, h("div", { class: "missing" }, uniqueValuesStatus === Status.FAILED
|
|
775
|
+
? _t9nStrings.fieldUniqueValuesNotAvailable
|
|
776
|
+
: _t9nStrings.fieldSampleRetrieving))));
|
|
777
|
+
}
|
|
457
778
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
779
|
+
renderNullValues() {
|
|
780
|
+
const { statistics, uniqueValues, _t9nStrings } = this;
|
|
781
|
+
const { statistics: statStrings } = _t9nStrings;
|
|
782
|
+
let count = statistics?.nullcount;
|
|
783
|
+
if (!isDefined(count) && uniqueValues) {
|
|
784
|
+
const infos = uniqueValues.uniqueValueInfos;
|
|
785
|
+
for (let i = 0; i < infos.length; i += 1) {
|
|
786
|
+
const info = infos[i];
|
|
787
|
+
if (info.value === null) {
|
|
788
|
+
count = info.count;
|
|
789
|
+
break;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
return (h("div", { class: "statistics-row" }, h("div", null, statStrings.numberOfNulls), !isDefined(count) ? (h("div", { class: "missing" }, "--")) : (h("div", { class: "data" }, `${Number.parseInt(count).toLocaleString()}`))));
|
|
794
|
+
}
|
|
795
|
+
// --------------------------------------------------------------------------
|
|
796
|
+
//
|
|
797
|
+
// Private methods
|
|
798
|
+
//
|
|
799
|
+
// --------------------------------------------------------------------------
|
|
800
|
+
_getFieldTypeLabel(fieldType) {
|
|
801
|
+
const { _t9nStrings } = this;
|
|
802
|
+
const fieldTypes = _t9nStrings.fieldTypes;
|
|
803
|
+
switch (fieldType) {
|
|
804
|
+
case "small-integer":
|
|
805
|
+
return fieldTypes.smallInteger;
|
|
806
|
+
case "big-integer":
|
|
807
|
+
return fieldTypes.bigInteger;
|
|
808
|
+
case "integer":
|
|
809
|
+
return fieldTypes.integer;
|
|
810
|
+
case "single":
|
|
811
|
+
return fieldTypes.single;
|
|
812
|
+
case "double":
|
|
813
|
+
return fieldTypes.double;
|
|
814
|
+
case "long":
|
|
815
|
+
return fieldTypes.long;
|
|
816
|
+
case "string":
|
|
817
|
+
return fieldTypes.string;
|
|
818
|
+
case "date":
|
|
819
|
+
return fieldTypes.date;
|
|
820
|
+
case "date-only":
|
|
821
|
+
return fieldTypes.dateOnly;
|
|
822
|
+
case "time-only":
|
|
823
|
+
return fieldTypes.timeOnly;
|
|
824
|
+
case "timestamp-offset":
|
|
825
|
+
return fieldTypes.timestampOffset;
|
|
826
|
+
case "oid":
|
|
827
|
+
return fieldTypes.oid;
|
|
828
|
+
case "guid":
|
|
829
|
+
return fieldTypes.guid;
|
|
830
|
+
case "global-id":
|
|
831
|
+
return fieldTypes.globalId;
|
|
832
|
+
default:
|
|
833
|
+
return fieldTypes.string;
|
|
834
|
+
}
|
|
462
835
|
}
|
|
463
|
-
|
|
464
|
-
|
|
836
|
+
_getStatisticsType(fieldInfo) {
|
|
837
|
+
// "count-or-amount","percentage-or-ratio","measurement","unique-identifier","coordinate","binary"
|
|
838
|
+
// "name-or-title","type-or-category","description","location-or-place-name","ordered-or-ranked","date-and-time"
|
|
839
|
+
switch (fieldInfo.layerField.type) {
|
|
840
|
+
case "small-integer":
|
|
841
|
+
case "big-integer":
|
|
842
|
+
case "integer":
|
|
843
|
+
case "single":
|
|
844
|
+
case "double": {
|
|
845
|
+
if (fieldInfo.codedValues) {
|
|
846
|
+
return SimpleFieldTypes.STRING;
|
|
847
|
+
}
|
|
848
|
+
switch (fieldInfo.layerField.valueType) {
|
|
849
|
+
case "name-or-title":
|
|
850
|
+
case "type-or-category":
|
|
851
|
+
case "description":
|
|
852
|
+
case "location-or-place-name":
|
|
853
|
+
case "ordered-or-ranked":
|
|
854
|
+
case "binary":
|
|
855
|
+
//case "date-and-time":
|
|
856
|
+
return SimpleFieldTypes.STRING;
|
|
857
|
+
default:
|
|
858
|
+
return SimpleFieldTypes.NUMBER;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
case "string":
|
|
862
|
+
return SimpleFieldTypes.STRING;
|
|
863
|
+
case "date":
|
|
864
|
+
return SimpleFieldTypes.DATE;
|
|
865
|
+
case "timestamp-offset":
|
|
866
|
+
return SimpleFieldTypes.TIMESTAMP_OFFSET;
|
|
867
|
+
case "date-only":
|
|
868
|
+
return SimpleFieldTypes.DATE_ONLY;
|
|
869
|
+
case "time-only":
|
|
870
|
+
return SimpleFieldTypes.TIME_ONLY;
|
|
871
|
+
default:
|
|
872
|
+
return SimpleFieldTypes.STRING;
|
|
873
|
+
}
|
|
465
874
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
875
|
+
_getFieldValueTypeCamelCase(field) {
|
|
876
|
+
switch (field.layerField.valueType) {
|
|
877
|
+
case "count-or-amount":
|
|
878
|
+
return "countOrAmount";
|
|
879
|
+
case "percentage-or-ratio":
|
|
880
|
+
return "percentageOrRatio";
|
|
881
|
+
case "unique-identifier":
|
|
882
|
+
return "uniqueIdentifier";
|
|
883
|
+
case "name-or-title":
|
|
884
|
+
return "nameOrTitle";
|
|
885
|
+
case "type-or-category":
|
|
886
|
+
return "typeOrCategory";
|
|
887
|
+
case "location-or-place-name":
|
|
888
|
+
return "locationOrPlaceName";
|
|
889
|
+
case "ordered-or-ranked":
|
|
890
|
+
return "orderedOrRanked";
|
|
891
|
+
case "date-and-time":
|
|
892
|
+
return "dateAndTime";
|
|
893
|
+
default:
|
|
894
|
+
return field.layerField.valueType;
|
|
473
895
|
}
|
|
474
|
-
|
|
475
|
-
|
|
896
|
+
}
|
|
897
|
+
_getDisplayString(value) {
|
|
898
|
+
const { props } = this;
|
|
899
|
+
const { fieldInfo } = props;
|
|
900
|
+
switch (fieldInfo.simpleFieldType) {
|
|
901
|
+
case SimpleFieldTypes.DATE:
|
|
902
|
+
return this._getDateString(value);
|
|
903
|
+
case SimpleFieldTypes.TIMESTAMP_OFFSET:
|
|
904
|
+
return this._getTimestampOffsetString(value);
|
|
905
|
+
case SimpleFieldTypes.DATE_ONLY:
|
|
906
|
+
return this._getDateOnlyString(value);
|
|
907
|
+
case SimpleFieldTypes.TIME_ONLY:
|
|
908
|
+
return this._getTimeOnlyString(value);
|
|
909
|
+
case SimpleFieldTypes.NUMBER:
|
|
910
|
+
return this._getNumberString(value);
|
|
911
|
+
case SimpleFieldTypes.GUID:
|
|
912
|
+
return this._getGuidString(value);
|
|
913
|
+
default:
|
|
914
|
+
// string, oid, global-id
|
|
915
|
+
return `${value}`;
|
|
476
916
|
}
|
|
477
|
-
}
|
|
478
|
-
catch (error) {
|
|
479
|
-
this.uniqueValuesStatus = Status.FAILED;
|
|
480
|
-
}
|
|
481
917
|
}
|
|
482
|
-
|
|
483
|
-
|
|
918
|
+
_getDateString(value) {
|
|
919
|
+
const { modules, view } = this.props;
|
|
920
|
+
if (view && view.timeZone === "unknown") {
|
|
921
|
+
return modules.intl.formatDate(value, {
|
|
922
|
+
...modules.intl.convertDateFormatToIntlOptions("short-date-short-time"),
|
|
923
|
+
timeZone: "utc",
|
|
924
|
+
timeZoneName: "shortOffset"
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
else {
|
|
928
|
+
// known issues with formatting it-CH
|
|
929
|
+
return modules.intl.formatDate(value, {
|
|
930
|
+
...modules.intl.convertDateFormatToIntlOptions("short-date-short-time"),
|
|
931
|
+
timeZone: view?.timeZone || "system"
|
|
932
|
+
});
|
|
933
|
+
}
|
|
484
934
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
935
|
+
_getTimestampOffsetString(value) {
|
|
936
|
+
/*
|
|
937
|
+
const timestamp = "2023-03-19T16:00:00.123-01:00";
|
|
938
|
+
console.log("timestamp", timestamp);
|
|
939
|
+
console.log(
|
|
940
|
+
"local Time",
|
|
941
|
+
intl.formatTimestamp(timestamp, intl.convertDateFormatToIntlOptions("short-date-short-time"))
|
|
942
|
+
);
|
|
943
|
+
console.log(
|
|
944
|
+
"mapView Time (except unknown)",
|
|
945
|
+
intl.formatTimestamp(timestamp, {
|
|
946
|
+
...intl.convertDateFormatToIntlOptions("short-date-short-time"),
|
|
947
|
+
timeZone: view.timeZone,
|
|
948
|
+
})
|
|
949
|
+
);
|
|
950
|
+
console.log(
|
|
951
|
+
"UTC Time (mapView time unknown)",
|
|
952
|
+
intl.formatTimestamp(timestamp, {
|
|
953
|
+
...intl.convertDateFormatToIntlOptions("short-date-short-time"),
|
|
954
|
+
timeZone: "utc",
|
|
955
|
+
timeZoneName: "shortOffset"
|
|
956
|
+
})
|
|
957
|
+
);
|
|
958
|
+
console.log(
|
|
959
|
+
"Raw",
|
|
960
|
+
intl.formatTimestamp(timestamp, {
|
|
961
|
+
...intl.convertDateFormatToIntlOptions("short-date-short-time"),
|
|
962
|
+
timeZoneName: "shortOffset"
|
|
963
|
+
})
|
|
964
|
+
);
|
|
965
|
+
*/
|
|
966
|
+
const { modules, view } = this.props;
|
|
967
|
+
if (typeof value === "string") {
|
|
968
|
+
// raw value from layer
|
|
969
|
+
if (view && view.timeZone === "unknown") {
|
|
970
|
+
return modules.intl.formatTimestamp(value, {
|
|
971
|
+
...modules.intl.convertDateFormatToIntlOptions("short-date-short-time"),
|
|
972
|
+
timeZone: "utc",
|
|
973
|
+
timeZoneName: "shortOffset"
|
|
974
|
+
});
|
|
499
975
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
506
|
-
this.statistics = statistics;
|
|
507
|
-
this.statisticsStatus = Status.SUCCESS;
|
|
508
|
-
}
|
|
509
|
-
catch (error) {
|
|
510
|
-
this.statisticsStatus = Status.FAILED;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
async componentDidLoad() {
|
|
515
|
-
// once component is visible make other calls
|
|
516
|
-
const { props } = this;
|
|
517
|
-
const { modules } = props;
|
|
518
|
-
modules.intl.setLocale(this._lang);
|
|
519
|
-
// modules.intl.setLocale(this.locale) not returning the correct formatting for e.g. it-ch
|
|
520
|
-
}
|
|
521
|
-
disconnectedCallback() {
|
|
522
|
-
U(this);
|
|
523
|
-
}
|
|
524
|
-
// --------------------------------------------------------------------------
|
|
525
|
-
//
|
|
526
|
-
// Render Methods
|
|
527
|
-
//
|
|
528
|
-
//--------------------------------------------------------------------------
|
|
529
|
-
render() {
|
|
530
|
-
const { props } = this;
|
|
531
|
-
const { fieldInfo } = props;
|
|
532
|
-
if (!fieldInfo) {
|
|
533
|
-
return h(Fragment, null);
|
|
534
|
-
}
|
|
535
|
-
return (h(Host, null, h("div", { class: "container" }, this.renderFieldType(), this.renderFieldAlias(), this.renderFieldDescription(), this.renderFieldValueType(), this.renderFieldSampleValue(), this.renderFieldFormat(), this.renderFieldStatistics())));
|
|
536
|
-
}
|
|
537
|
-
renderFieldType() {
|
|
538
|
-
const { _t9nStrings, props } = this;
|
|
539
|
-
const { fieldInfo } = props;
|
|
540
|
-
const fieldType = this._getFieldTypeLabel(fieldInfo.layerField.type);
|
|
541
|
-
return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldType), h("div", null, fieldType)));
|
|
542
|
-
}
|
|
543
|
-
renderFieldAlias() {
|
|
544
|
-
const { _t9nStrings, props } = this;
|
|
545
|
-
const { fieldInfo } = props;
|
|
546
|
-
return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldAlias), h("div", null, fieldInfo.label)));
|
|
547
|
-
}
|
|
548
|
-
renderFieldDescription() {
|
|
549
|
-
const { _t9nStrings, props } = this;
|
|
550
|
-
const { layer } = props;
|
|
551
|
-
if (layer.type !== "feature") {
|
|
552
|
-
return h(Fragment, null);
|
|
553
|
-
}
|
|
554
|
-
const { fieldInfo } = props;
|
|
555
|
-
const description = fieldInfo.layerField.description;
|
|
556
|
-
return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldDescription), h("div", { class: {
|
|
557
|
-
missing: !description
|
|
558
|
-
} }, description || _t9nStrings.fieldDescriptionNotSet)));
|
|
559
|
-
}
|
|
560
|
-
renderFieldValueType() {
|
|
561
|
-
const { _t9nStrings, props } = this;
|
|
562
|
-
const { layer } = props;
|
|
563
|
-
if (layer.type !== "feature") {
|
|
564
|
-
return h(Fragment, null);
|
|
565
|
-
}
|
|
566
|
-
const { fieldInfo } = props;
|
|
567
|
-
const fieldValueType = this._getFieldValueTypeCamelCase(fieldInfo);
|
|
568
|
-
return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldValueType), h("div", { class: !fieldValueType ? "missing" : "" }, fieldValueType
|
|
569
|
-
? _t9nStrings.fieldValueTypes[fieldValueType]
|
|
570
|
-
: _t9nStrings.fieldValueTypeNotSet)));
|
|
571
|
-
}
|
|
572
|
-
renderFieldSampleValue() {
|
|
573
|
-
const { oneFeatureResponse, oneFeatureResponseStatus, statisticsStatus, statistics, uniqueValuesStatus, uniqueValues, _t9nStrings, props } = this;
|
|
574
|
-
const { layer, fieldName, fieldInfo } = props;
|
|
575
|
-
const { statistics: statStrings } = _t9nStrings;
|
|
576
|
-
let value;
|
|
577
|
-
if (["imagery", "imagery-tile"].indexOf(layer.type) > -1) {
|
|
578
|
-
return h(Fragment, null);
|
|
579
|
-
}
|
|
580
|
-
if (layer.type !== "stream" &&
|
|
581
|
-
[SimpleFieldTypes.STRING, SimpleFieldTypes.OID, SimpleFieldTypes.GUID].indexOf(this._getStatisticsType(fieldInfo)) > -1 &&
|
|
582
|
-
uniqueValuesStatus !== Status.FAILED) {
|
|
583
|
-
// we show top values
|
|
584
|
-
return h(Fragment, null);
|
|
585
|
-
}
|
|
586
|
-
if (oneFeatureResponseStatus === Status.SUCCESS) {
|
|
587
|
-
// find first valid value entry
|
|
588
|
-
oneFeatureResponse.features.forEach((feature) => {
|
|
589
|
-
if (value === undefined || (value === null && feature.attributes[fieldName] !== null)) {
|
|
590
|
-
value = feature.attributes[fieldName];
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
else if (statisticsStatus === Status.SUCCESS) {
|
|
595
|
-
// use statistics min value
|
|
596
|
-
value = statistics.min;
|
|
597
|
-
}
|
|
598
|
-
else if (uniqueValuesStatus === Status.SUCCESS) {
|
|
599
|
-
// use a non-null value
|
|
600
|
-
value = uniqueValues.uniqueValueInfos?.[0]?.value || uniqueValues.uniqueValueInfos?.[1]?.value;
|
|
601
|
-
}
|
|
602
|
-
const codedValues = fieldInfo.codedValues;
|
|
603
|
-
if (isDefined(value)) {
|
|
604
|
-
if (codedValues) {
|
|
605
|
-
value = codedValues.find((codedValue) => value === codedValue.code)?.name || value;
|
|
606
|
-
}
|
|
607
|
-
else {
|
|
608
|
-
value = this._getDisplayString(value);
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldSampleValue), h("div", { class: (oneFeatureResponseStatus === Status.FAILED &&
|
|
612
|
-
statisticsStatus === Status.FAILED &&
|
|
613
|
-
uniqueValuesStatus === Status.FAILED) ||
|
|
614
|
-
!isDefined(value)
|
|
615
|
-
? "missing"
|
|
616
|
-
: "" }, oneFeatureResponseStatus === Status.SUCCESS ||
|
|
617
|
-
statisticsStatus === Status.SUCCESS ||
|
|
618
|
-
uniqueValuesStatus === Status.SUCCESS
|
|
619
|
-
? !isDefined(value)
|
|
620
|
-
? statStrings.allNulls
|
|
621
|
-
: `${value}`
|
|
622
|
-
: oneFeatureResponseStatus === Status.FAILED &&
|
|
623
|
-
statisticsStatus === Status.FAILED &&
|
|
624
|
-
uniqueValuesStatus === Status.FAILED
|
|
625
|
-
? _t9nStrings.fieldSampleNotAvailable
|
|
626
|
-
: _t9nStrings.fieldSampleRetrieving)));
|
|
627
|
-
}
|
|
628
|
-
renderFieldFormat() {
|
|
629
|
-
const { _t9nStrings, props } = this;
|
|
630
|
-
const { fieldName, fieldInfo, layer } = props;
|
|
631
|
-
if (["single", "double", "long"].indexOf(fieldInfo.layerField.type) === -1) {
|
|
632
|
-
return h(Fragment, null);
|
|
633
|
-
}
|
|
634
|
-
const popupTemplate = layer.popupTemplate;
|
|
635
|
-
if (popupTemplate?.fieldInfos) {
|
|
636
|
-
const popFieldInfos = popupTemplate.fieldInfos?.filter((fieldInfo) => fieldInfo.fieldName === fieldName);
|
|
637
|
-
if (popFieldInfos?.length) {
|
|
638
|
-
const popFieldInfo = popFieldInfos[0];
|
|
639
|
-
if (isDefined(popFieldInfo?.format?.places)) {
|
|
640
|
-
const num = popFieldInfo.format.places;
|
|
641
|
-
return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldDecimalPlaces), h("div", null, _t9nStrings.fieldNumDecimalPlaces.replace("${number}", num.toString()))));
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldDecimalPlaces), h("div", { class: "missing" }, _t9nStrings.fieldDecimalPlacesNotAvailable)));
|
|
646
|
-
}
|
|
647
|
-
renderFieldStatistics() {
|
|
648
|
-
const { statisticsStatus, uniqueValuesStatus, hideStatistics, _t9nStrings, props } = this;
|
|
649
|
-
const { layer, fieldInfo } = props;
|
|
650
|
-
if (hideStatistics) {
|
|
651
|
-
this.arcgisFieldInfoComplete.emit();
|
|
652
|
-
return h(Fragment, null);
|
|
653
|
-
}
|
|
654
|
-
if (["stream", "imagery", "imagery-tile"].indexOf(layer.type) > -1 ||
|
|
655
|
-
["long"].indexOf(fieldInfo.layerField.type) > -1) {
|
|
656
|
-
// can't get statistics
|
|
657
|
-
this.arcgisFieldInfoComplete.emit();
|
|
658
|
-
return h(Fragment, null);
|
|
659
|
-
}
|
|
660
|
-
return (h("div", { class: "section" }, h("div", { class: "title" }, _t9nStrings.fieldStatistics), !statisticsStatus || statisticsStatus === Status.MISSING || statisticsStatus === Status.IN_PROGRESS ? (h("div", { key: "field-info-statistics-content", class: "missing" }, _t9nStrings.fieldStatisticsRetrieving)) : statisticsStatus === Status.FAILED && uniqueValuesStatus !== Status.SUCCESS ? (this.renderNoStatistics()) : (h("div", { key: "field-info-statistics-content", ref: () => this.arcgisFieldInfoComplete.emit() }, this.renderStatistics()))));
|
|
661
|
-
}
|
|
662
|
-
renderNoStatistics() {
|
|
663
|
-
const { _t9nStrings } = this;
|
|
664
|
-
return (h("div", { key: "field-info-statistics-content", ref: () => this.arcgisFieldInfoComplete.emit(), class: "missing" }, _t9nStrings.fieldStatisticsNotAvailable));
|
|
665
|
-
}
|
|
666
|
-
renderStatistics() {
|
|
667
|
-
const { props } = this;
|
|
668
|
-
const { fieldInfo } = props;
|
|
669
|
-
switch (this._getStatisticsType(fieldInfo)) {
|
|
670
|
-
case SimpleFieldTypes.NUMBER:
|
|
671
|
-
return this.renderNumberStatistics();
|
|
672
|
-
case SimpleFieldTypes.STRING:
|
|
673
|
-
case SimpleFieldTypes.OID:
|
|
674
|
-
case SimpleFieldTypes.GUID:
|
|
675
|
-
return this.renderStringStatistics();
|
|
676
|
-
case SimpleFieldTypes.DATE:
|
|
677
|
-
case SimpleFieldTypes.DATE_ONLY:
|
|
678
|
-
case SimpleFieldTypes.TIME_ONLY:
|
|
679
|
-
case SimpleFieldTypes.TIMESTAMP_OFFSET:
|
|
680
|
-
return this.renderDateStatistics();
|
|
681
|
-
default:
|
|
682
|
-
return h(Fragment, null);
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
renderNumberStatistics() {
|
|
686
|
-
const { statistics, _t9nStrings } = this;
|
|
687
|
-
if (!statistics) {
|
|
688
|
-
return this.renderNoStatistics();
|
|
689
|
-
}
|
|
690
|
-
const { statistics: statStrings } = _t9nStrings;
|
|
691
|
-
return (h("div", null, h("div", { class: "statistics-row" }, h("div", null, statStrings.numberOfValues), h("div", { class: "data" }, this._printNumValue(statistics.totalCount))), isDefined(statistics.sum) ? (h("div", { class: "statistics-row" }, h("div", null, statStrings.sumOfValues), h("div", { class: "data" }, this._printNumValue(statistics.sum)))) : null, isDefined(statistics.min) ? (h("div", { class: "statistics-row" }, h("div", null, statStrings.minimum), h("div", { class: "data" }, this._printNumValue(statistics.min)))) : null, isDefined(statistics.max) ? (h("div", { class: "statistics-row" }, h("div", null, statStrings.maximum), h("div", { class: "data" }, this._printNumValue(statistics.max)))) : null, isDefined(statistics.avg) ? (h("div", { class: "statistics-row" }, h("div", null, statStrings.average), h("div", { class: "data" }, this._printNumValue(statistics.avg)))) : null, isDefined(statistics.stddev) ? (h("div", { class: "statistics-row" }, h("div", null, statStrings.standardDeviation), h("div", { class: "data" }, this._printNumValue(statistics.stddev)))) : null, this.renderNullValues()));
|
|
692
|
-
}
|
|
693
|
-
renderStringStatistics() {
|
|
694
|
-
const { statistics, uniqueValuesStatus, _t9nStrings } = this;
|
|
695
|
-
const { statistics: statStrings } = _t9nStrings;
|
|
696
|
-
return (h("div", null, h("div", { class: "statistics-row" }, h("div", null, statStrings.numberOfValues), uniqueValuesStatus !== Status.SUCCESS ? (h("div", { class: "missing" }, "--")) : (h("div", { class: "data" }, this._printNumValue(statistics?.totalCount)))), this.renderNullValues(), this.renderTopValues()));
|
|
697
|
-
}
|
|
698
|
-
renderDateStatistics() {
|
|
699
|
-
// TODO UTC offset
|
|
700
|
-
const { statistics, view, props, _t9nStrings } = this;
|
|
701
|
-
const { fieldInfo } = props;
|
|
702
|
-
if (!statistics) {
|
|
703
|
-
return this.renderNoStatistics();
|
|
704
|
-
}
|
|
705
|
-
const { statistics: statStrings } = _t9nStrings;
|
|
706
|
-
const dateRange = statistics.max - statistics.min;
|
|
707
|
-
const years = Math.floor(dateRange / 31536000000);
|
|
708
|
-
let months = Math.floor((dateRange - years * 31536000000) / 2628000000);
|
|
709
|
-
let days = Math.ceil((dateRange - months * 2628000000) / 86400000);
|
|
710
|
-
if (days >= 30) {
|
|
711
|
-
months += 1;
|
|
712
|
-
days = 0;
|
|
713
|
-
}
|
|
714
|
-
let timeSpan = years === 1
|
|
715
|
-
? statStrings.timeSpanOptions.year
|
|
716
|
-
: years > 1
|
|
717
|
-
? statStrings.timeSpanOptions.years.replace("${years}", years.toString())
|
|
718
|
-
: "";
|
|
719
|
-
timeSpan += years > 0 && (months > 0 || days > 0) ? ", " : "";
|
|
720
|
-
timeSpan +=
|
|
721
|
-
months === 1
|
|
722
|
-
? statStrings.timeSpanOptions.month
|
|
723
|
-
: months > 1
|
|
724
|
-
? statStrings.timeSpanOptions.months.replace("${months}", months.toString())
|
|
725
|
-
: "";
|
|
726
|
-
timeSpan += months > 0 && days > 0 ? ", " : "";
|
|
727
|
-
timeSpan +=
|
|
728
|
-
days === 1
|
|
729
|
-
? statStrings.timeSpanOptions.day
|
|
730
|
-
: days > 1
|
|
731
|
-
? statStrings.timeSpanOptions.days.replace("${days}", days.toString())
|
|
732
|
-
: "";
|
|
733
|
-
const showStats = fieldInfo.simpleFieldType !== SimpleFieldTypes.TIMESTAMP_OFFSET ||
|
|
734
|
-
!view ||
|
|
735
|
-
view.timeZone !== "unknown";
|
|
736
|
-
const isTimeOnly = fieldInfo.simpleFieldType === SimpleFieldTypes.TIME_ONLY;
|
|
737
|
-
return (h("div", null, h("div", { class: "statistics-row" }, h("div", null, statStrings.numberOfValues), h("div", { class: "data" }, this._printNumValue(statistics?.totalCount))), showStats && isDefined(statistics.min) ? (h("div", { class: "statistics-row" }, h("div", null, isTimeOnly ? statStrings.minimumTime : statStrings.minimumDate), h("div", { class: "data" }, `${this._getDisplayString(statistics.min)}`))) : null, showStats && isDefined(statistics.max) ? (h("div", { class: "statistics-row" }, h("div", null, isTimeOnly ? statStrings.maximumTime : statStrings.maximumDate), h("div", { class: "data" }, `${this._getDisplayString(statistics.max)}`))) : null, showStats && isDefined(statistics.avg) ? (h("div", { class: "statistics-row" }, h("div", null, isTimeOnly ? statStrings.averageTime : statStrings.averageDate), h("div", { class: "data" }, `${this._getDisplayString(statistics.avg)}`))) : null, showStats && !isTimeOnly && isDefined(statistics.min) && isDefined(statistics.max) && dateRange > 0 ? (h("div", { class: "statistics-row" }, h("div", null, statStrings.timespan), h("div", { class: "data" }, timeSpan))) : null, this.renderNullValues()));
|
|
738
|
-
}
|
|
739
|
-
renderTopValues() {
|
|
740
|
-
const { uniqueValues, uniqueValuesStatus, _t9nStrings, props } = this;
|
|
741
|
-
const { fieldInfo } = props;
|
|
742
|
-
const { statistics: statStrings } = _t9nStrings;
|
|
743
|
-
if (uniqueValues?.uniqueValueInfos?.length) {
|
|
744
|
-
const infos = uniqueValues.uniqueValueInfos;
|
|
745
|
-
infos.sort((a, b) => (a.count < b.count ? 1 : a.count > b.count ? -1 : 0));
|
|
746
|
-
const codedValues = fieldInfo.codedValues;
|
|
747
|
-
const values = infos
|
|
748
|
-
.filter((info) => info.value !== null)
|
|
749
|
-
.filter((info, idx) => info && idx < 10)
|
|
750
|
-
.map((info) => {
|
|
751
|
-
let value = info.value;
|
|
752
|
-
if (codedValues) {
|
|
753
|
-
codedValues.forEach((codeValue) => {
|
|
754
|
-
if (value === codeValue.code) {
|
|
755
|
-
value = codeValue.name;
|
|
976
|
+
else {
|
|
977
|
+
return modules.intl.formatTimestamp(value, {
|
|
978
|
+
...modules.intl.convertDateFormatToIntlOptions("short-date-short-time"),
|
|
979
|
+
timeZone: view?.timeZone || "system"
|
|
980
|
+
});
|
|
756
981
|
}
|
|
757
|
-
});
|
|
758
982
|
}
|
|
759
983
|
else {
|
|
760
|
-
|
|
984
|
+
// e.g. UNIX timestamp from statistics call
|
|
985
|
+
return this._getDateString(value);
|
|
761
986
|
}
|
|
762
|
-
return (h("div", { class: "statistics-row" }, h("div", { class: "data" }, `${value}`), h("div", { class: `$"data" $"count"` }, this._printNumValue(info.count))));
|
|
763
|
-
});
|
|
764
|
-
if (!values.length) {
|
|
765
|
-
return h(Fragment, null);
|
|
766
|
-
}
|
|
767
|
-
return (h("div", null, h("div", { class: "statistics-row-top-values" }, h("div", null, infos.length > 10 ? statStrings.topTenValues : statStrings.topValues), h("div", null, statStrings.count)), values));
|
|
768
987
|
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
renderNullValues() {
|
|
776
|
-
const { statistics, uniqueValues, _t9nStrings } = this;
|
|
777
|
-
const { statistics: statStrings } = _t9nStrings;
|
|
778
|
-
let count = statistics?.nullcount;
|
|
779
|
-
if (!isDefined(count) && uniqueValues) {
|
|
780
|
-
const infos = uniqueValues.uniqueValueInfos;
|
|
781
|
-
for (let i = 0; i < infos.length; i++) {
|
|
782
|
-
const info = infos[i];
|
|
783
|
-
if (info.value === null) {
|
|
784
|
-
count = info.count;
|
|
785
|
-
break;
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
return (h("div", { class: "statistics-row" }, h("div", null, statStrings.numberOfNulls), !isDefined(count) ? (h("div", { class: "missing" }, "--")) : (h("div", { class: "data" }, `${new Number(count).toLocaleString()}`))));
|
|
790
|
-
}
|
|
791
|
-
// --------------------------------------------------------------------------
|
|
792
|
-
//
|
|
793
|
-
// Private methods
|
|
794
|
-
//
|
|
795
|
-
// --------------------------------------------------------------------------
|
|
796
|
-
_getFieldTypeLabel(fieldType) {
|
|
797
|
-
const { _t9nStrings } = this;
|
|
798
|
-
const fieldTypes = _t9nStrings.fieldTypes;
|
|
799
|
-
switch (fieldType) {
|
|
800
|
-
case "small-integer":
|
|
801
|
-
return fieldTypes.smallInteger;
|
|
802
|
-
case "big-integer":
|
|
803
|
-
return fieldTypes.bigInteger;
|
|
804
|
-
case "integer":
|
|
805
|
-
return fieldTypes.integer;
|
|
806
|
-
case "single":
|
|
807
|
-
return fieldTypes.single;
|
|
808
|
-
case "double":
|
|
809
|
-
return fieldTypes.double;
|
|
810
|
-
case "long":
|
|
811
|
-
return fieldTypes.long;
|
|
812
|
-
case "string":
|
|
813
|
-
return fieldTypes.string;
|
|
814
|
-
case "date":
|
|
815
|
-
return fieldTypes.date;
|
|
816
|
-
case "date-only":
|
|
817
|
-
return fieldTypes.dateOnly;
|
|
818
|
-
case "time-only":
|
|
819
|
-
return fieldTypes.timeOnly;
|
|
820
|
-
case "timestamp-offset":
|
|
821
|
-
return fieldTypes.timestampOffset;
|
|
822
|
-
case "oid":
|
|
823
|
-
return fieldTypes.oid;
|
|
824
|
-
case "guid":
|
|
825
|
-
return fieldTypes.guid;
|
|
826
|
-
case "global-id":
|
|
827
|
-
return fieldTypes.globalId;
|
|
828
|
-
default:
|
|
829
|
-
return fieldTypes.string;
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
_getStatisticsType(fieldInfo) {
|
|
833
|
-
// "count-or-amount","percentage-or-ratio","measurement","unique-identifier","coordinate","binary"
|
|
834
|
-
// "name-or-title","type-or-category","description","location-or-place-name","ordered-or-ranked","date-and-time"
|
|
835
|
-
switch (fieldInfo.layerField.type) {
|
|
836
|
-
case "small-integer":
|
|
837
|
-
case "big-integer":
|
|
838
|
-
case "integer":
|
|
839
|
-
case "single":
|
|
840
|
-
case "double": {
|
|
841
|
-
if (fieldInfo.codedValues) {
|
|
842
|
-
return SimpleFieldTypes.STRING;
|
|
843
|
-
}
|
|
844
|
-
switch (fieldInfo.layerField.valueType) {
|
|
845
|
-
case "name-or-title":
|
|
846
|
-
case "type-or-category":
|
|
847
|
-
case "description":
|
|
848
|
-
case "location-or-place-name":
|
|
849
|
-
case "ordered-or-ranked":
|
|
850
|
-
case "binary":
|
|
851
|
-
//case "date-and-time":
|
|
852
|
-
return SimpleFieldTypes.STRING;
|
|
853
|
-
default:
|
|
854
|
-
return SimpleFieldTypes.NUMBER;
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
case "string":
|
|
858
|
-
return SimpleFieldTypes.STRING;
|
|
859
|
-
case "date":
|
|
860
|
-
return SimpleFieldTypes.DATE;
|
|
861
|
-
case "timestamp-offset":
|
|
862
|
-
return SimpleFieldTypes.TIMESTAMP_OFFSET;
|
|
863
|
-
case "date-only":
|
|
864
|
-
return SimpleFieldTypes.DATE_ONLY;
|
|
865
|
-
case "time-only":
|
|
866
|
-
return SimpleFieldTypes.TIME_ONLY;
|
|
867
|
-
default:
|
|
868
|
-
return SimpleFieldTypes.STRING;
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
_getFieldValueTypeCamelCase(field) {
|
|
872
|
-
switch (field.layerField.valueType) {
|
|
873
|
-
case "count-or-amount":
|
|
874
|
-
return "countOrAmount";
|
|
875
|
-
case "percentage-or-ratio":
|
|
876
|
-
return "percentageOrRatio";
|
|
877
|
-
case "unique-identifier":
|
|
878
|
-
return "uniqueIdentifier";
|
|
879
|
-
case "name-or-title":
|
|
880
|
-
return "nameOrTitle";
|
|
881
|
-
case "type-or-category":
|
|
882
|
-
return "typeOrCategory";
|
|
883
|
-
case "location-or-place-name":
|
|
884
|
-
return "locationOrPlaceName";
|
|
885
|
-
case "ordered-or-ranked":
|
|
886
|
-
return "orderedOrRanked";
|
|
887
|
-
case "date-and-time":
|
|
888
|
-
return "dateAndTime";
|
|
889
|
-
default:
|
|
890
|
-
return field.layerField.valueType;
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
_getDisplayString(value) {
|
|
894
|
-
const { props } = this;
|
|
895
|
-
const { fieldInfo } = props;
|
|
896
|
-
switch (fieldInfo.simpleFieldType) {
|
|
897
|
-
case SimpleFieldTypes.DATE:
|
|
898
|
-
return this._getDateString(value);
|
|
899
|
-
case SimpleFieldTypes.TIMESTAMP_OFFSET:
|
|
900
|
-
return this._getTimestampOffsetString(value);
|
|
901
|
-
case SimpleFieldTypes.DATE_ONLY:
|
|
902
|
-
return this._getDateOnlyString(value);
|
|
903
|
-
case SimpleFieldTypes.TIME_ONLY:
|
|
904
|
-
return this._getTimeOnlyString(value);
|
|
905
|
-
case SimpleFieldTypes.NUMBER:
|
|
906
|
-
return this._getNumberString(value);
|
|
907
|
-
case SimpleFieldTypes.GUID:
|
|
908
|
-
return this._getGuidString(value);
|
|
909
|
-
default:
|
|
910
|
-
// string, oid, global-id
|
|
911
|
-
return `${value}`;
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
_getDateString(value) {
|
|
915
|
-
const { modules, view } = this.props;
|
|
916
|
-
if (view && view.timeZone === "unknown") {
|
|
917
|
-
return modules.intl.formatDate(value, {
|
|
918
|
-
...modules.intl.convertDateFormatToIntlOptions("short-date-short-time"),
|
|
919
|
-
timeZone: "utc",
|
|
920
|
-
timeZoneName: "shortOffset"
|
|
921
|
-
});
|
|
988
|
+
_getDateOnlyString(value) {
|
|
989
|
+
const { props } = this;
|
|
990
|
+
const { modules } = props;
|
|
991
|
+
return modules.intl.formatDateOnly(value, modules.intl.convertDateFormatToIntlOptions("short-date"));
|
|
922
992
|
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
"local Time",
|
|
937
|
-
intl.formatTimestamp(timestamp, intl.convertDateFormatToIntlOptions("short-date-short-time"))
|
|
938
|
-
);
|
|
939
|
-
console.log(
|
|
940
|
-
"mapView Time (except unknown)",
|
|
941
|
-
intl.formatTimestamp(timestamp, {
|
|
942
|
-
...intl.convertDateFormatToIntlOptions("short-date-short-time"),
|
|
943
|
-
timeZone: view.timeZone,
|
|
944
|
-
})
|
|
945
|
-
);
|
|
946
|
-
console.log(
|
|
947
|
-
"UTC Time (mapView time unknown)",
|
|
948
|
-
intl.formatTimestamp(timestamp, {
|
|
949
|
-
...intl.convertDateFormatToIntlOptions("short-date-short-time"),
|
|
950
|
-
timeZone: "utc",
|
|
951
|
-
timeZoneName: "shortOffset"
|
|
952
|
-
})
|
|
953
|
-
);
|
|
954
|
-
console.log(
|
|
955
|
-
"Raw",
|
|
956
|
-
intl.formatTimestamp(timestamp, {
|
|
957
|
-
...intl.convertDateFormatToIntlOptions("short-date-short-time"),
|
|
958
|
-
timeZoneName: "shortOffset"
|
|
959
|
-
})
|
|
960
|
-
);
|
|
961
|
-
*/
|
|
962
|
-
const { modules, view } = this.props;
|
|
963
|
-
if (typeof value === "string") {
|
|
964
|
-
// raw value from layer
|
|
965
|
-
if (view && view.timeZone === "unknown") {
|
|
966
|
-
return modules.intl.formatTimestamp(value, {
|
|
967
|
-
...modules.intl.convertDateFormatToIntlOptions("short-date-short-time"),
|
|
968
|
-
timeZone: "utc",
|
|
969
|
-
timeZoneName: "shortOffset"
|
|
970
|
-
});
|
|
971
|
-
}
|
|
972
|
-
else {
|
|
973
|
-
return modules.intl.formatTimestamp(value, {
|
|
974
|
-
...modules.intl.convertDateFormatToIntlOptions("short-date-short-time"),
|
|
975
|
-
timeZone: view?.timeZone || "system"
|
|
976
|
-
});
|
|
977
|
-
}
|
|
993
|
+
_getTimeOnlyString(value) {
|
|
994
|
+
const { props } = this;
|
|
995
|
+
const { modules } = props;
|
|
996
|
+
if (typeof value === "string") {
|
|
997
|
+
return modules.intl.formatTimeOnly(value, modules.intl.convertDateFormatToIntlOptions("short-date-long-time"));
|
|
998
|
+
}
|
|
999
|
+
else {
|
|
1000
|
+
// UNIX timestamp
|
|
1001
|
+
return modules.intl.formatDate(value, {
|
|
1002
|
+
...modules.intl.convertDateFormatToIntlOptions("long-time"),
|
|
1003
|
+
timeZone: "utc"
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
978
1006
|
}
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
return this._getDateString(value);
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
_getDateOnlyString(value) {
|
|
985
|
-
const { props } = this;
|
|
986
|
-
const { modules } = props;
|
|
987
|
-
return modules.intl.formatDateOnly(value, modules.intl.convertDateFormatToIntlOptions("short-date"));
|
|
988
|
-
}
|
|
989
|
-
_getTimeOnlyString(value) {
|
|
990
|
-
const { props } = this;
|
|
991
|
-
const { modules } = props;
|
|
992
|
-
if (typeof value === "string") {
|
|
993
|
-
return modules.intl.formatTimeOnly(value, modules.intl.convertDateFormatToIntlOptions("short-date-long-time"));
|
|
1007
|
+
_getGuidString(value) {
|
|
1008
|
+
return value.startsWith("{") ? value : `{${value}}`;
|
|
994
1009
|
}
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
_getGuidString(value) {
|
|
1004
|
-
return value.startsWith("{") ? value : `{${value}}`;
|
|
1005
|
-
}
|
|
1006
|
-
_getNumberString(value) {
|
|
1007
|
-
return this.props.modules.intl.formatNumber(value);
|
|
1008
|
-
}
|
|
1009
|
-
_printNumValue(value) {
|
|
1010
|
-
return isDefined(value) ? this._getNumberString(Math.round(value * 100) / 100) : `--`;
|
|
1011
|
-
}
|
|
1012
|
-
static get assetsDirs() { return ["assets"]; }
|
|
1013
|
-
get _hostElement() { return getElement(this); }
|
|
1010
|
+
_getNumberString(value) {
|
|
1011
|
+
return this.props.modules.intl.formatNumber(value);
|
|
1012
|
+
}
|
|
1013
|
+
_printNumValue(value) {
|
|
1014
|
+
return isDefined(value) ? this._getNumberString(Math.round(value * 100) / 100) : `--`;
|
|
1015
|
+
}
|
|
1016
|
+
static get assetsDirs() { return ["assets"]; }
|
|
1017
|
+
get _hostElement() { return getElement(this); }
|
|
1014
1018
|
};
|
|
1015
1019
|
ArcgisFieldInfo.style = fieldInfoScss;
|
|
1016
1020
|
|