@esri/solutions-components 0.5.7 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/calcite-input-text_5.cjs.entry.js +1 -1
- package/dist/cjs/{downloadUtils-06876768.js → downloadUtils-8d66f03e.js} +95 -21
- package/dist/cjs/{index.es-d07646b4.js → index.es-4f5dfcc6.js} +1 -1
- package/dist/cjs/layer-table_2.cjs.entry.js +1 -1
- package/dist/collection/components/refine-selection/refine-selection.css +85 -85
- package/dist/collection/utils/downloadUtils.js +94 -20
- package/dist/collection/utils/downloadUtils.ts +147 -27
- package/dist/components/downloadUtils.js +94 -20
- package/dist/esm/calcite-input-text_5.entry.js +1 -1
- package/dist/esm/{downloadUtils-046ce0aa.js → downloadUtils-b9785635.js} +95 -21
- package/dist/esm/{index.es-3fd0e8f6.js → index.es-70994c40.js} +1 -1
- package/dist/esm/layer-table_2.entry.js +1 -1
- package/dist/solutions-components/{p-1850a763.entry.js → p-10336554.entry.js} +1 -1
- package/dist/solutions-components/{p-99aec087.js → p-5d5e10d4.js} +1 -1
- package/dist/solutions-components/{p-2e0db581.js → p-be943993.js} +11 -11
- package/dist/solutions-components/{p-1b08d9d6.entry.js → p-c3e3d0bb.entry.js} +1 -1
- package/dist/solutions-components/solutions-components.esm.js +1 -1
- package/dist/solutions-components/utils/downloadUtils.ts +147 -27
- package/dist/solutions-components_commit.txt +8 -0
- package/dist/types/utils/downloadUtils.d.ts +21 -0
- package/package.json +1 -1
@@ -24,7 +24,7 @@ const mapViewUtils = require('./mapViewUtils-c45571b9.js');
|
|
24
24
|
const interfaces = require('./interfaces-842c84a1.js');
|
25
25
|
const publicNotificationStore = require('./publicNotificationStore-cd1a32c3.js');
|
26
26
|
const locale$1 = require('./locale-b113c6b2.js');
|
27
|
-
const downloadUtils = require('./downloadUtils-
|
27
|
+
const downloadUtils = require('./downloadUtils-8d66f03e.js');
|
28
28
|
require('./guid-c58d5ead.js');
|
29
29
|
require('./key-d55baa11.js');
|
30
30
|
require('./index-e1b1954f.js');
|
@@ -1507,7 +1507,7 @@ function(t){var e=function(t){for(var e=t.length,r=new Uint8Array(e),n=0;n<e;n++
|
|
1507
1507
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1508
1508
|
* ====================================================================
|
1509
1509
|
*/
|
1510
|
-
function(t){function e(){return (n.canvg?Promise.resolve(n.canvg):Promise.resolve().then(function () { return require('./index.es-
|
1510
|
+
function(t){function e(){return (n.canvg?Promise.resolve(n.canvg):Promise.resolve().then(function () { return require('./index.es-4f5dfcc6.js'); })).catch((function(t){return Promise.reject(new Error("Could not load canvg: "+t))})).then((function(t){return t.default?t.default:t}))}E.API.addSvgAsImage=function(t,r,n,i,o,s,c,u){if(isNaN(r)||isNaN(n))throw a.error("jsPDF.addSvgAsImage: Invalid coordinates",arguments),new Error("Invalid coordinates passed to jsPDF.addSvgAsImage");if(isNaN(i)||isNaN(o))throw a.error("jsPDF.addSvgAsImage: Invalid measurements",arguments),new Error("Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage");var h=document.createElement("canvas");h.width=i,h.height=o;var l=h.getContext("2d");l.fillStyle="#fff",l.fillRect(0,0,h.width,h.height);var f={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0},d=this;return e().then((function(e){return e.fromString(l,t,f)}),(function(){return Promise.reject(new Error("Could not load canvg."))})).then((function(t){return t.render(f)})).then((function(){d.addImage(h.toDataURL("image/jpeg",1),r,n,i,o,c,u);}))};}(),E.API.putTotalPages=function(t){var e,r=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(e=new RegExp(t,"g"),r=this.internal.getNumberOfPages()):(e=new RegExp(this.pdfEscape16(t,this.internal.getFont()),"g"),r=this.pdfEscape16(this.internal.getNumberOfPages()+"",this.internal.getFont()));for(var n=1;n<=this.internal.getNumberOfPages();n++)for(var i=0;i<this.internal.pages[n].length;i++)this.internal.pages[n][i]=this.internal.pages[n][i].replace(e,r);return this},E.API.viewerPreferences=function(e,r){var n;e=e||{},r=r||!1;var i,a,o,s={HideToolbar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideMenubar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideWindowUI:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},FitWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},CenterWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},DisplayDocTitle:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.4},NonFullScreenPageMode:{defaultValue:"UseNone",value:"UseNone",type:"name",explicitSet:!1,valueSet:["UseNone","UseOutlines","UseThumbs","UseOC"],pdfVersion:1.3},Direction:{defaultValue:"L2R",value:"L2R",type:"name",explicitSet:!1,valueSet:["L2R","R2L"],pdfVersion:1.3},ViewArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},ViewClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintScaling:{defaultValue:"AppDefault",value:"AppDefault",type:"name",explicitSet:!1,valueSet:["AppDefault","None"],pdfVersion:1.6},Duplex:{defaultValue:"",value:"none",type:"name",explicitSet:!1,valueSet:["Simplex","DuplexFlipShortEdge","DuplexFlipLongEdge","none"],pdfVersion:1.7},PickTrayByPDFSize:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.7},PrintPageRange:{defaultValue:"",value:"",type:"array",explicitSet:!1,valueSet:null,pdfVersion:1.7},NumCopies:{defaultValue:1,value:1,type:"integer",explicitSet:!1,valueSet:null,pdfVersion:1.7}},c=Object.keys(s),u=[],h=0,l=0,f=0;function d(t,e){var r,n=!1;for(r=0;r<t.length;r+=1)t[r]===e&&(n=!0);return n}if(void 0===this.internal.viewerpreferences&&(this.internal.viewerpreferences={},this.internal.viewerpreferences.configuration=JSON.parse(JSON.stringify(s)),this.internal.viewerpreferences.isSubscribed=!1),n=this.internal.viewerpreferences.configuration,"reset"===e||!0===r){var p=c.length;for(f=0;f<p;f+=1)n[c[f]].value=n[c[f]].defaultValue,n[c[f]].explicitSet=!1;}if("object"===t(e))for(a in e)if(o=e[a],d(c,a)&&void 0!==o){if("boolean"===n[a].type&&"boolean"==typeof o)n[a].value=o;else if("name"===n[a].type&&d(n[a].valueSet,o))n[a].value=o;else if("integer"===n[a].type&&Number.isInteger(o))n[a].value=o;else if("array"===n[a].type){for(h=0;h<o.length;h+=1)if(i=!0,1===o[h].length&&"number"==typeof o[h][0])u.push(String(o[h]-1));else if(o[h].length>1){for(l=0;l<o[h].length;l+=1)"number"!=typeof o[h][l]&&(i=!1);!0===i&&u.push([o[h][0]-1,o[h][1]-1].join(" "));}n[a].value="["+u.join(" ")+"]";}else n[a].value=n[a].defaultValue;n[a].explicitSet=!0;}return !1===this.internal.viewerpreferences.isSubscribed&&(this.internal.events.subscribe("putCatalog",(function(){var t,e=[];for(t in n)!0===n[t].explicitSet&&("name"===n[t].type?e.push("/"+t+" /"+n[t].value):e.push("/"+t+" "+n[t].value));0!==e.length&&this.internal.write("/ViewerPreferences\n<<\n"+e.join("\n")+"\n>>");})),this.internal.viewerpreferences.isSubscribed=!0),this.internal.viewerpreferences.configuration=n,this},
|
1511
1511
|
/** ====================================================================
|
1512
1512
|
* @license
|
1513
1513
|
* jsPDF XMP metadata plugin
|
@@ -2427,6 +2427,38 @@ function _createFilename(selectionSetNames) {
|
|
2427
2427
|
const title = selectionSetNames.length > 0 ? selectionSetNames.join(", ") : "download";
|
2428
2428
|
return title;
|
2429
2429
|
}
|
2430
|
+
/**
|
2431
|
+
* Creates relationship queries for each relationship flag in a popup.
|
2432
|
+
* @param layer Layer whose popup is to be examined
|
2433
|
+
* @return Hash of relationships by their id, or null if there are no relationship flags in the
|
2434
|
+
* popup; each relationship has the properties layer and relatedQuery for the related layer
|
2435
|
+
* and the query for that layer
|
2436
|
+
*/
|
2437
|
+
function _createRelationshipQueries(layer) {
|
2438
|
+
const relationships = {};
|
2439
|
+
const relationshipFieldPattern = /\{relationships\/\d+\//gm;
|
2440
|
+
const relationshipIdPattern = /\d+/;
|
2441
|
+
// Test if this popup has any relationship references
|
2442
|
+
const matches = layer.popupTemplate.content[0].text.match(relationshipFieldPattern);
|
2443
|
+
if (matches) {
|
2444
|
+
matches.forEach(match => {
|
2445
|
+
// Add a query to a found relationship if we don't already have one
|
2446
|
+
const id = match.match(relationshipIdPattern)[0];
|
2447
|
+
if (!relationships.hasOwnProperty(id)) {
|
2448
|
+
const relatedQuery = {
|
2449
|
+
outFields: ['*'],
|
2450
|
+
relationshipId: id,
|
2451
|
+
returnGeometry: false
|
2452
|
+
};
|
2453
|
+
relationships[id] = {
|
2454
|
+
layer,
|
2455
|
+
relatedQuery
|
2456
|
+
};
|
2457
|
+
}
|
2458
|
+
});
|
2459
|
+
}
|
2460
|
+
return relationships;
|
2461
|
+
}
|
2430
2462
|
/**
|
2431
2463
|
* Prepares an attribute's value by applying domain and type information.
|
2432
2464
|
*
|
@@ -2487,7 +2519,7 @@ function _prepareAttributeValue(attributeValue, attributeType, attributeDomain,
|
|
2487
2519
|
* @returns Promise resolving when function is done
|
2488
2520
|
*/
|
2489
2521
|
async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLayerPopup = true, includeHeaderNames = false) {
|
2490
|
-
var _a, _b, _c, _d;
|
2522
|
+
var _a, _b, _c, _d, _e, _f;
|
2491
2523
|
const [intl] = await loadModules.loadModules(["esri/intl"]);
|
2492
2524
|
// Get the features to export
|
2493
2525
|
const featureSet = await mapViewUtils.queryFeaturesByID(ids, layer);
|
@@ -2501,6 +2533,7 @@ async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLa
|
|
2501
2533
|
const attributeFormats = {};
|
2502
2534
|
// Get the label formatting, if any
|
2503
2535
|
let labelFormat;
|
2536
|
+
let relationshipQueries = {};
|
2504
2537
|
let arcadeExecutors = {};
|
2505
2538
|
if (layer.popupEnabled) {
|
2506
2539
|
layer.popupTemplate.fieldInfos.forEach(
|
@@ -2529,6 +2562,8 @@ async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLa
|
|
2529
2562
|
}
|
2530
2563
|
else if (formatUsingLayerPopup && ((_d = (_c = layer.popupTemplate) === null || _c === void 0 ? void 0 : _c.content[0]) === null || _d === void 0 ? void 0 : _d.type) === "text") {
|
2531
2564
|
labelFormat = _convertPopupTextToLabelSpec(layer.popupTemplate.content[0].text);
|
2565
|
+
// Do we need any relationship queries?
|
2566
|
+
relationshipQueries = _createRelationshipQueries(layer);
|
2532
2567
|
// Do we need any Arcade executors?
|
2533
2568
|
arcadeExecutors = await _createArcadeExecutors(labelFormat, layer);
|
2534
2569
|
}
|
@@ -2537,36 +2572,75 @@ async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLa
|
|
2537
2572
|
let labels;
|
2538
2573
|
// eslint-disable-next-line unicorn/prefer-ternary
|
2539
2574
|
if (labelFormat) {
|
2575
|
+
console.log("labelFormat", labelFormat); //???
|
2540
2576
|
const arcadeExpressionRegExp = /\{expression\/\w+\}/g;
|
2541
2577
|
const attributeRegExp = /\{\w+\}/g;
|
2542
2578
|
// Find the label fields that we need to replace with values
|
2543
|
-
const arcadeExpressionMatches = labelFormat.match(arcadeExpressionRegExp);
|
2544
|
-
const attributeMatches = labelFormat.match(attributeRegExp);
|
2579
|
+
const arcadeExpressionMatches = (_e = labelFormat.match(arcadeExpressionRegExp)) !== null && _e !== void 0 ? _e : [];
|
2580
|
+
const attributeMatches = (_f = labelFormat.match(attributeRegExp)) !== null && _f !== void 0 ? _f : [];
|
2545
2581
|
// Convert feature attributes into an array of labels
|
2546
|
-
|
2582
|
+
const relationshipKeys = Object.keys(relationshipQueries);
|
2583
|
+
labels = await Promise.all(featureSet.features.map(async (feature) => {
|
2547
2584
|
let labelPrep = labelFormat;
|
2548
|
-
// Replace Arcade expressions
|
2549
|
-
|
2550
|
-
|
2551
|
-
|
2552
|
-
|
2553
|
-
|
2554
|
-
|
2555
|
-
|
2556
|
-
|
2557
|
-
|
2558
|
-
|
2559
|
-
|
2560
|
-
|
2561
|
-
|
2585
|
+
// Replace Arcade expressions in this feature
|
2586
|
+
arcadeExpressionMatches.forEach((match) => {
|
2587
|
+
const expressionName = match.substring(match.indexOf("/") + 1, match.length - 1);
|
2588
|
+
const value = arcadeExecutors[expressionName].execute({ "$feature": feature });
|
2589
|
+
labelPrep = labelPrep.replace(match, value);
|
2590
|
+
});
|
2591
|
+
// Replace relationship expressions in this feature
|
2592
|
+
const relatedFeatureQueries = [];
|
2593
|
+
const relationshipIds = [];
|
2594
|
+
relationshipKeys.forEach((relationshipId) => {
|
2595
|
+
const relationship = relationshipQueries[relationshipId];
|
2596
|
+
const objectId = feature.attributes[relationship.layer.objectIdField];
|
2597
|
+
const relatedQuery = Object.assign(Object.assign({}, relationship.relatedQuery), { objectIds: [objectId] });
|
2598
|
+
relatedFeatureQueries.push(relationship.layer.queryRelatedFeatures(relatedQuery));
|
2599
|
+
relationshipIds.push(relationshipId);
|
2600
|
+
});
|
2601
|
+
// Wait for all of the queries for related records for this label
|
2602
|
+
const relatedFeatureQueryResults = await Promise.all(relatedFeatureQueries);
|
2603
|
+
console.log("relatedFeatureQueryResults", relatedFeatureQueryResults); //???
|
2604
|
+
relatedFeatureQueryResults.forEach((relatedFeatureQueryResult, i) => {
|
2605
|
+
// We have an object with FeatureSets grouped by source layer or table objectIds
|
2606
|
+
const relationshipId = relationshipIds[i];
|
2607
|
+
console.log("relationshipId", relationshipId); //???
|
2608
|
+
console.log("relatedFeatureQueryResult", relatedFeatureQueryResult); //???
|
2609
|
+
// Run through the source layer or table objectIds
|
2610
|
+
Object.keys(relatedFeatureQueryResult).forEach(relatedFeatureSetId => {
|
2611
|
+
console.log("relatedFeatureSetId", relatedFeatureSetId); //???
|
2612
|
+
// We have a feature set
|
2613
|
+
const relatedFeatures = relatedFeatureQueryResult[relatedFeatureSetId].features;
|
2614
|
+
console.log("relatedFeatures", relatedFeatures); //???
|
2615
|
+
// Get the values from each feature and replace them in the label
|
2616
|
+
relatedFeatures.forEach(feature => {
|
2617
|
+
// Merge the base and related feature attributes and create the label
|
2618
|
+
// Prefix related feature's attributes with "relationships/<id>/" to match popup
|
2619
|
+
const rePrefix = "\{relationships/" + relationshipId + "/";
|
2620
|
+
const reSuffix = "\}";
|
2621
|
+
console.log("/rePrefix + attributeName + reSuffix/g", rePrefix + "attributeName" + reSuffix); //???
|
2622
|
+
const attributes = feature.attributes;
|
2623
|
+
Object.keys(attributes).forEach(attributeName => {
|
2624
|
+
console.log("/rePrefix + attributeName + reSuffix/g", rePrefix + attributeName + reSuffix); //???
|
2625
|
+
// Replace the value using the attribute name as a relationship
|
2626
|
+
const attributeRelationshipRegExp = new RegExp(rePrefix + attributeName + reSuffix, "g");
|
2627
|
+
labelPrep = labelPrep.replaceAll(attributeRelationshipRegExp, attributes[attributeName]);
|
2628
|
+
});
|
2629
|
+
});
|
2562
2630
|
});
|
2563
|
-
}
|
2631
|
+
});
|
2632
|
+
// Replace non-Arcade fields in this feature
|
2633
|
+
attributeMatches.forEach((match) => {
|
2634
|
+
const attributeName = match.substring(1, match.length - 1);
|
2635
|
+
const value = _prepareAttributeValue(feature.attributes[attributeName], attributeTypes[attributeName], attributeDomains[attributeName], attributeFormats[attributeName], intl);
|
2636
|
+
labelPrep = labelPrep.replace(match, value);
|
2637
|
+
});
|
2564
2638
|
// Split label into lines
|
2565
2639
|
let label = labelPrep.split(lineSeparatorChar);
|
2566
2640
|
// Trim lines
|
2567
2641
|
label = label.map(line => line.trim());
|
2568
2642
|
return label;
|
2569
|
-
});
|
2643
|
+
}));
|
2570
2644
|
}
|
2571
2645
|
else {
|
2572
2646
|
// Export all attributes
|
@@ -6,7 +6,7 @@
|
|
6
6
|
'use strict';
|
7
7
|
|
8
8
|
const _commonjsHelpers = require('./_commonjsHelpers-384729db.js');
|
9
|
-
const downloadUtils = require('./downloadUtils-
|
9
|
+
const downloadUtils = require('./downloadUtils-8d66f03e.js');
|
10
10
|
require('./index-6654298b.js');
|
11
11
|
require('./loadModules-ae7715f2.js');
|
12
12
|
require('./locale-b113c6b2.js');
|
@@ -11,7 +11,7 @@ const index = require('./index-6654298b.js');
|
|
11
11
|
const loadModules = require('./loadModules-ae7715f2.js');
|
12
12
|
const locale = require('./locale-b113c6b2.js');
|
13
13
|
const mapViewUtils = require('./mapViewUtils-c45571b9.js');
|
14
|
-
const downloadUtils = require('./downloadUtils-
|
14
|
+
const downloadUtils = require('./downloadUtils-8d66f03e.js');
|
15
15
|
const interfaces = require('./interfaces-842c84a1.js');
|
16
16
|
require('./_commonjsHelpers-384729db.js');
|
17
17
|
|
@@ -1,86 +1,86 @@
|
|
1
|
-
/** @license
|
2
|
-
* Copyright 2022 Esri
|
3
|
-
*
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
* you may not use this file except in compliance with the License.
|
6
|
-
* You may obtain a copy of the License at
|
7
|
-
*
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
*
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
* See the License for the specific language governing permissions and
|
14
|
-
* limitations under the License.
|
15
|
-
*/
|
16
|
-
|
17
|
-
:host {
|
18
|
-
display: block;
|
19
|
-
}
|
20
|
-
|
21
|
-
.div-visible {
|
22
|
-
display: inherit;
|
23
|
-
}
|
24
|
-
|
25
|
-
.div-not-visible {
|
26
|
-
display: none !important;
|
27
|
-
}
|
28
|
-
|
29
|
-
.padding-top-1-2 {
|
30
|
-
padding-top: .5rem;
|
31
|
-
}
|
32
|
-
|
33
|
-
.main-label {
|
34
|
-
display: flex;
|
35
|
-
float: left;
|
36
|
-
}
|
37
|
-
|
38
|
-
html[dir="rtl"] .main-label {
|
39
|
-
display: flex;
|
40
|
-
float: right;
|
41
|
-
}
|
42
|
-
|
43
|
-
.border {
|
44
|
-
outline: 1px solid var(--calcite-ui-border-input);
|
45
|
-
}
|
46
|
-
|
47
|
-
.margin-top-1 {
|
48
|
-
margin-top: 1rem;
|
49
|
-
}
|
50
|
-
|
51
|
-
/* COPY FROM JS */
|
52
|
-
.esri-sketch {
|
53
|
-
display: flex;
|
54
|
-
flex-flow: column wrap;
|
55
|
-
}
|
56
|
-
|
57
|
-
.esri-widget {
|
58
|
-
box-sizing: border-box;
|
59
|
-
color: #323232;
|
60
|
-
font-size: 14px;
|
61
|
-
font-family: "Avenir Next","Helvetica Neue",Helvetica,Arial,sans-serif;
|
62
|
-
line-height: 1.3em;
|
63
|
-
background-color: var(--calcite-ui-foreground-1);
|
64
|
-
}
|
65
|
-
|
66
|
-
/* DIV CHILD */
|
67
|
-
.esri-sketch__panel {
|
68
|
-
align-items: center;
|
69
|
-
display: flex;
|
70
|
-
flex-flow: row nowrap;
|
71
|
-
padding: 0;
|
72
|
-
} */
|
73
|
-
|
74
|
-
/* DIV CHILD CHILD */
|
75
|
-
.esri-sketch__tool-section {
|
76
|
-
border-right: 1px solid rgba(110,110,110,.3);
|
77
|
-
}
|
78
|
-
|
79
|
-
.esri-sketch__section {
|
80
|
-
align-items: center;
|
81
|
-
display: flex;
|
82
|
-
flex-flow: row nowrap;
|
83
|
-
padding: 0 7px;
|
84
|
-
margin: 6px 0;
|
85
|
-
border-right: 1px solid rgba(110,110,110,.3);
|
1
|
+
/** @license
|
2
|
+
* Copyright 2022 Esri
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
:host {
|
18
|
+
display: block;
|
19
|
+
}
|
20
|
+
|
21
|
+
.div-visible {
|
22
|
+
display: inherit;
|
23
|
+
}
|
24
|
+
|
25
|
+
.div-not-visible {
|
26
|
+
display: none !important;
|
27
|
+
}
|
28
|
+
|
29
|
+
.padding-top-1-2 {
|
30
|
+
padding-top: .5rem;
|
31
|
+
}
|
32
|
+
|
33
|
+
.main-label {
|
34
|
+
display: flex;
|
35
|
+
float: left;
|
36
|
+
}
|
37
|
+
|
38
|
+
html[dir="rtl"] .main-label {
|
39
|
+
display: flex;
|
40
|
+
float: right;
|
41
|
+
}
|
42
|
+
|
43
|
+
.border {
|
44
|
+
outline: 1px solid var(--calcite-ui-border-input);
|
45
|
+
}
|
46
|
+
|
47
|
+
.margin-top-1 {
|
48
|
+
margin-top: 1rem;
|
49
|
+
}
|
50
|
+
|
51
|
+
/* COPY FROM JS */
|
52
|
+
.esri-sketch {
|
53
|
+
display: flex;
|
54
|
+
flex-flow: column wrap;
|
55
|
+
}
|
56
|
+
|
57
|
+
.esri-widget {
|
58
|
+
box-sizing: border-box;
|
59
|
+
color: #323232;
|
60
|
+
font-size: 14px;
|
61
|
+
font-family: "Avenir Next","Helvetica Neue",Helvetica,Arial,sans-serif;
|
62
|
+
line-height: 1.3em;
|
63
|
+
background-color: var(--calcite-ui-foreground-1);
|
64
|
+
}
|
65
|
+
|
66
|
+
/* DIV CHILD */
|
67
|
+
.esri-sketch__panel {
|
68
|
+
align-items: center;
|
69
|
+
display: flex;
|
70
|
+
flex-flow: row nowrap;
|
71
|
+
padding: 0;
|
72
|
+
} */
|
73
|
+
|
74
|
+
/* DIV CHILD CHILD */
|
75
|
+
.esri-sketch__tool-section {
|
76
|
+
border-right: 1px solid rgba(110,110,110,.3);
|
77
|
+
}
|
78
|
+
|
79
|
+
.esri-sketch__section {
|
80
|
+
align-items: center;
|
81
|
+
display: flex;
|
82
|
+
flex-flow: row nowrap;
|
83
|
+
padding: 0 7px;
|
84
|
+
margin: 6px 0;
|
85
|
+
border-right: 1px solid rgba(110,110,110,.3);
|
86
86
|
}
|
@@ -196,6 +196,38 @@ export function _createFilename(selectionSetNames) {
|
|
196
196
|
const title = selectionSetNames.length > 0 ? selectionSetNames.join(", ") : "download";
|
197
197
|
return title;
|
198
198
|
}
|
199
|
+
/**
|
200
|
+
* Creates relationship queries for each relationship flag in a popup.
|
201
|
+
* @param layer Layer whose popup is to be examined
|
202
|
+
* @return Hash of relationships by their id, or null if there are no relationship flags in the
|
203
|
+
* popup; each relationship has the properties layer and relatedQuery for the related layer
|
204
|
+
* and the query for that layer
|
205
|
+
*/
|
206
|
+
export function _createRelationshipQueries(layer) {
|
207
|
+
const relationships = {};
|
208
|
+
const relationshipFieldPattern = /\{relationships\/\d+\//gm;
|
209
|
+
const relationshipIdPattern = /\d+/;
|
210
|
+
// Test if this popup has any relationship references
|
211
|
+
const matches = layer.popupTemplate.content[0].text.match(relationshipFieldPattern);
|
212
|
+
if (matches) {
|
213
|
+
matches.forEach(match => {
|
214
|
+
// Add a query to a found relationship if we don't already have one
|
215
|
+
const id = match.match(relationshipIdPattern)[0];
|
216
|
+
if (!relationships.hasOwnProperty(id)) {
|
217
|
+
const relatedQuery = {
|
218
|
+
outFields: ['*'],
|
219
|
+
relationshipId: id,
|
220
|
+
returnGeometry: false
|
221
|
+
};
|
222
|
+
relationships[id] = {
|
223
|
+
layer,
|
224
|
+
relatedQuery
|
225
|
+
};
|
226
|
+
}
|
227
|
+
});
|
228
|
+
}
|
229
|
+
return relationships;
|
230
|
+
}
|
199
231
|
/**
|
200
232
|
* Prepares an attribute's value by applying domain and type information.
|
201
233
|
*
|
@@ -256,7 +288,7 @@ function _prepareAttributeValue(attributeValue, attributeType, attributeDomain,
|
|
256
288
|
* @returns Promise resolving when function is done
|
257
289
|
*/
|
258
290
|
async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLayerPopup = true, includeHeaderNames = false) {
|
259
|
-
var _a, _b, _c, _d;
|
291
|
+
var _a, _b, _c, _d, _e, _f;
|
260
292
|
const [intl] = await loadModules(["esri/intl"]);
|
261
293
|
// Get the features to export
|
262
294
|
const featureSet = await queryFeaturesByID(ids, layer);
|
@@ -270,6 +302,7 @@ async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLa
|
|
270
302
|
const attributeFormats = {};
|
271
303
|
// Get the label formatting, if any
|
272
304
|
let labelFormat;
|
305
|
+
let relationshipQueries = {};
|
273
306
|
let arcadeExecutors = {};
|
274
307
|
if (layer.popupEnabled) {
|
275
308
|
layer.popupTemplate.fieldInfos.forEach(
|
@@ -298,6 +331,8 @@ async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLa
|
|
298
331
|
}
|
299
332
|
else if (formatUsingLayerPopup && ((_d = (_c = layer.popupTemplate) === null || _c === void 0 ? void 0 : _c.content[0]) === null || _d === void 0 ? void 0 : _d.type) === "text") {
|
300
333
|
labelFormat = _convertPopupTextToLabelSpec(layer.popupTemplate.content[0].text);
|
334
|
+
// Do we need any relationship queries?
|
335
|
+
relationshipQueries = _createRelationshipQueries(layer);
|
301
336
|
// Do we need any Arcade executors?
|
302
337
|
arcadeExecutors = await _createArcadeExecutors(labelFormat, layer);
|
303
338
|
}
|
@@ -306,36 +341,75 @@ async function _prepareLabels(layer, ids, removeDuplicates = true, formatUsingLa
|
|
306
341
|
let labels;
|
307
342
|
// eslint-disable-next-line unicorn/prefer-ternary
|
308
343
|
if (labelFormat) {
|
344
|
+
console.log("labelFormat", labelFormat); //???
|
309
345
|
const arcadeExpressionRegExp = /\{expression\/\w+\}/g;
|
310
346
|
const attributeRegExp = /\{\w+\}/g;
|
311
347
|
// Find the label fields that we need to replace with values
|
312
|
-
const arcadeExpressionMatches = labelFormat.match(arcadeExpressionRegExp);
|
313
|
-
const attributeMatches = labelFormat.match(attributeRegExp);
|
348
|
+
const arcadeExpressionMatches = (_e = labelFormat.match(arcadeExpressionRegExp)) !== null && _e !== void 0 ? _e : [];
|
349
|
+
const attributeMatches = (_f = labelFormat.match(attributeRegExp)) !== null && _f !== void 0 ? _f : [];
|
314
350
|
// Convert feature attributes into an array of labels
|
315
|
-
|
351
|
+
const relationshipKeys = Object.keys(relationshipQueries);
|
352
|
+
labels = await Promise.all(featureSet.features.map(async (feature) => {
|
316
353
|
let labelPrep = labelFormat;
|
317
|
-
// Replace Arcade expressions
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
354
|
+
// Replace Arcade expressions in this feature
|
355
|
+
arcadeExpressionMatches.forEach((match) => {
|
356
|
+
const expressionName = match.substring(match.indexOf("/") + 1, match.length - 1);
|
357
|
+
const value = arcadeExecutors[expressionName].execute({ "$feature": feature });
|
358
|
+
labelPrep = labelPrep.replace(match, value);
|
359
|
+
});
|
360
|
+
// Replace relationship expressions in this feature
|
361
|
+
const relatedFeatureQueries = [];
|
362
|
+
const relationshipIds = [];
|
363
|
+
relationshipKeys.forEach((relationshipId) => {
|
364
|
+
const relationship = relationshipQueries[relationshipId];
|
365
|
+
const objectId = feature.attributes[relationship.layer.objectIdField];
|
366
|
+
const relatedQuery = Object.assign(Object.assign({}, relationship.relatedQuery), { objectIds: [objectId] });
|
367
|
+
relatedFeatureQueries.push(relationship.layer.queryRelatedFeatures(relatedQuery));
|
368
|
+
relationshipIds.push(relationshipId);
|
369
|
+
});
|
370
|
+
// Wait for all of the queries for related records for this label
|
371
|
+
const relatedFeatureQueryResults = await Promise.all(relatedFeatureQueries);
|
372
|
+
console.log("relatedFeatureQueryResults", relatedFeatureQueryResults); //???
|
373
|
+
relatedFeatureQueryResults.forEach((relatedFeatureQueryResult, i) => {
|
374
|
+
// We have an object with FeatureSets grouped by source layer or table objectIds
|
375
|
+
const relationshipId = relationshipIds[i];
|
376
|
+
console.log("relationshipId", relationshipId); //???
|
377
|
+
console.log("relatedFeatureQueryResult", relatedFeatureQueryResult); //???
|
378
|
+
// Run through the source layer or table objectIds
|
379
|
+
Object.keys(relatedFeatureQueryResult).forEach(relatedFeatureSetId => {
|
380
|
+
console.log("relatedFeatureSetId", relatedFeatureSetId); //???
|
381
|
+
// We have a feature set
|
382
|
+
const relatedFeatures = relatedFeatureQueryResult[relatedFeatureSetId].features;
|
383
|
+
console.log("relatedFeatures", relatedFeatures); //???
|
384
|
+
// Get the values from each feature and replace them in the label
|
385
|
+
relatedFeatures.forEach(feature => {
|
386
|
+
// Merge the base and related feature attributes and create the label
|
387
|
+
// Prefix related feature's attributes with "relationships/<id>/" to match popup
|
388
|
+
const rePrefix = "\{relationships/" + relationshipId + "/";
|
389
|
+
const reSuffix = "\}";
|
390
|
+
console.log("/rePrefix + attributeName + reSuffix/g", rePrefix + "attributeName" + reSuffix); //???
|
391
|
+
const attributes = feature.attributes;
|
392
|
+
Object.keys(attributes).forEach(attributeName => {
|
393
|
+
console.log("/rePrefix + attributeName + reSuffix/g", rePrefix + attributeName + reSuffix); //???
|
394
|
+
// Replace the value using the attribute name as a relationship
|
395
|
+
const attributeRelationshipRegExp = new RegExp(rePrefix + attributeName + reSuffix, "g");
|
396
|
+
labelPrep = labelPrep.replaceAll(attributeRelationshipRegExp, attributes[attributeName]);
|
397
|
+
});
|
398
|
+
});
|
331
399
|
});
|
332
|
-
}
|
400
|
+
});
|
401
|
+
// Replace non-Arcade fields in this feature
|
402
|
+
attributeMatches.forEach((match) => {
|
403
|
+
const attributeName = match.substring(1, match.length - 1);
|
404
|
+
const value = _prepareAttributeValue(feature.attributes[attributeName], attributeTypes[attributeName], attributeDomains[attributeName], attributeFormats[attributeName], intl);
|
405
|
+
labelPrep = labelPrep.replace(match, value);
|
406
|
+
});
|
333
407
|
// Split label into lines
|
334
408
|
let label = labelPrep.split(lineSeparatorChar);
|
335
409
|
// Trim lines
|
336
410
|
label = label.map(line => line.trim());
|
337
411
|
return label;
|
338
|
-
});
|
412
|
+
}));
|
339
413
|
}
|
340
414
|
else {
|
341
415
|
// Export all attributes
|