@esri/solutions-components 0.7.49 → 0.7.50

Sign up to get free protection for your applications and to get access to all the features.
@@ -149,7 +149,6 @@ const LayerTable = class {
149
149
  this.onTableNodeCreate = (node) => {
150
150
  this._tableNode = node;
151
151
  };
152
- this.defaultFilter = undefined;
153
152
  this.defaultGlobalId = undefined;
154
153
  this.defaultLayerId = undefined;
155
154
  this.defaultOid = undefined;
@@ -185,6 +184,12 @@ const LayerTable = class {
185
184
  // Watch handlers
186
185
  //
187
186
  //--------------------------------------------------------------------------
187
+ async defaultOidWatchHandler() {
188
+ await this._handleDefaults();
189
+ }
190
+ async defaultGlobalIdWatchHandler() {
191
+ await this._handleDefaults();
192
+ }
188
193
  /**
189
194
  * Reset the toolInfos when export csv is enabled/disabled
190
195
  */
@@ -872,22 +877,6 @@ const LayerTable = class {
872
877
  else {
873
878
  urlObj.searchParams.delete("oid");
874
879
  }
875
- if (this._filterActive) {
876
- const filter = JSON.parse(this._filterList.urlParams.get("filter"));
877
- const layerExpressions = this._filterList.layerExpressions.map(layerExp => {
878
- layerExp.expressions = layerExp.expressions.map(exp => {
879
- if (exp.id.toString() === filter.expressionId.toString()) {
880
- exp.active = true;
881
- }
882
- return exp;
883
- });
884
- return layerExp;
885
- });
886
- urlObj.searchParams.set("filter", JSON.stringify(layerExpressions));
887
- }
888
- else {
889
- urlObj.searchParams.delete("filter");
890
- }
891
880
  this._shareNode.shareUrl = urlObj.href;
892
881
  }
893
882
  /**
@@ -901,7 +890,7 @@ const LayerTable = class {
901
890
  * @returns VNode The tooltip node
902
891
  */
903
892
  _getToolTip(placement, referenceElement, text) {
904
- return (index.h("calcite-tooltip", { placement: placement, "reference-element": referenceElement }, index.h("span", null, text)));
893
+ return document.getElementById(referenceElement) ? (index.h("calcite-tooltip", { placement: placement, "reference-element": referenceElement }, index.h("span", null, text))) : undefined;
905
894
  }
906
895
  /**
907
896
  * Get an id with a prefix to the user supplied value
@@ -1064,7 +1053,11 @@ const LayerTable = class {
1064
1053
  _resetColumnTemplates() {
1065
1054
  var _a, _b;
1066
1055
  const columnTemplates = this._getColumnTemplates((_a = this._layer) === null || _a === void 0 ? void 0 : _a.id, (_b = this._layer) === null || _b === void 0 ? void 0 : _b.fields);
1067
- if (this._table && columnTemplates) {
1056
+ const hasChange = columnTemplates.some((ct, i) => {
1057
+ var _a;
1058
+ return JSON.stringify((_a = this._table) === null || _a === void 0 ? void 0 : _a.tableTemplate.columnTemplates[i]) !== JSON.stringify(ct);
1059
+ });
1060
+ if (this._table && columnTemplates && hasChange) {
1068
1061
  this._table.tableTemplate = new this.TableTemplate({
1069
1062
  columnTemplates
1070
1063
  });
@@ -1087,37 +1080,64 @@ const LayerTable = class {
1087
1080
  this._table.view = this.mapView;
1088
1081
  this._table.layer = this._layer;
1089
1082
  }
1083
+ await this._initLayerRefresh();
1090
1084
  this._checkEditEnabled();
1091
1085
  this._table.editingEnabled = this._editEnabled && this.enableInlineEdit;
1092
1086
  await this.reactiveUtils.once(() => this._table.state === "loaded")
1093
1087
  .then(async () => {
1094
- var _a, _b, _c;
1095
1088
  this._table.highlightIds.removeAll();
1096
1089
  this._table.clearSelectionFilter();
1097
1090
  this._resetColumnTemplates();
1098
- if (!this._defaultOidHonored && ((_a = this.defaultOid) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.defaultOid[0] > -1) {
1099
- this._selectDefaultFeature(this.defaultOid);
1100
- this._defaultOidHonored = true;
1101
- }
1102
- if (!this._defaultGlobalIdHonored && ((_b = this.defaultGlobalId) === null || _b === void 0 ? void 0 : _b.length) > 0) {
1103
- const features = await mapViewUtils.queryFeaturesByGlobalID(this.defaultGlobalId, this._layer);
1104
- const oids = (features === null || features === void 0 ? void 0 : features.length) > 0 ? features.map(f => f.getObjectId()) : undefined;
1105
- if (oids) {
1106
- this._selectDefaultFeature(oids);
1107
- }
1108
- this._defaultGlobalIdHonored = true;
1109
- }
1110
- if (!this._defaultFilterHonored && ((_c = this.defaultFilter) === null || _c === void 0 ? void 0 : _c.length) > 0 && this._filterList) {
1111
- this._layerExpressions = this.defaultFilter;
1112
- this._filterActive = true;
1113
- this._defaultFilterHonored = true;
1114
- }
1115
1091
  this._showOnlySelected = false;
1092
+ await this._handleDefaults();
1116
1093
  await this._sortTable();
1117
1094
  this._initToolInfos();
1118
1095
  this._updateToolbar();
1119
1096
  });
1120
1097
  }
1098
+ /**
1099
+ * Update the current IDs when that layers data is modified
1100
+ */
1101
+ async _initLayerRefresh() {
1102
+ if (this._refreshHandle) {
1103
+ this._refreshHandle.remove();
1104
+ }
1105
+ this._refreshHandle = this._layer.on("refresh", (evt) => {
1106
+ if (evt.dataChanged) {
1107
+ this._skipOnChange = true;
1108
+ void this._updateAllIds();
1109
+ }
1110
+ });
1111
+ }
1112
+ /**
1113
+ * Reset _allIds when the layers data has changed and refresh the selection ids and table
1114
+ */
1115
+ async _updateAllIds() {
1116
+ this._allIds = await mapViewUtils.queryAllIds(this._layer);
1117
+ this.selectedIds = this.selectedIds.filter(id => this._allIds.indexOf(id) > -1);
1118
+ await this._refresh();
1119
+ }
1120
+ async _handleDefaults() {
1121
+ var _a, _b;
1122
+ if (!this._defaultOidHonored && ((_a = this.defaultOid) === null || _a === void 0 ? void 0 : _a.length) > 0 && this.defaultOid[0] > -1 && this._table) {
1123
+ await this._selectDefaultFeature(this.defaultOid);
1124
+ this._defaultOidHonored = true;
1125
+ this.defaultOid = undefined;
1126
+ this._showOnlySelected = false;
1127
+ this._toggleShowSelected();
1128
+ }
1129
+ if (!this._defaultGlobalIdHonored && ((_b = this.defaultGlobalId) === null || _b === void 0 ? void 0 : _b.length) > 0 && this._table) {
1130
+ const features = await mapViewUtils.queryFeaturesByGlobalID(this.defaultGlobalId, this._layer);
1131
+ const oids = (features === null || features === void 0 ? void 0 : features.length) > 0 ? features.map(f => f.getObjectId()) : undefined;
1132
+ if (oids) {
1133
+ await this._selectDefaultFeature(oids);
1134
+ }
1135
+ this._defaultGlobalIdHonored = true;
1136
+ this.defaultGlobalId = undefined;
1137
+ this._showOnlySelected = false;
1138
+ this._toggleShowSelected();
1139
+ }
1140
+ }
1121
1141
  /**
1122
1142
  * Store the column names and current hidden status to support show/hide of columns
1123
1143
  * @param fieldNames optional list of names from new config options
@@ -1146,13 +1166,12 @@ const LayerTable = class {
1146
1166
  /**
1147
1167
  * Select the feature that was specified via url params
1148
1168
  */
1149
- _selectDefaultFeature(oids) {
1169
+ async _selectDefaultFeature(oids) {
1150
1170
  if (oids.length > 0) {
1151
1171
  this._table.highlightIds.addMany(oids);
1152
- void this._table.when(() => {
1153
- const i = this._table.viewModel.getObjectIdIndex(oids[0]);
1154
- this._table.viewModel.scrollToIndex(i);
1155
- });
1172
+ // This is messed up and only make this worse
1173
+ //const i = this._table.viewModel.getObjectIdIndex(oids[0]);
1174
+ //this._table.viewModel.scrollToIndex(i);
1156
1175
  }
1157
1176
  }
1158
1177
  /**
@@ -1528,6 +1547,8 @@ const LayerTable = class {
1528
1547
  }
1529
1548
  get el() { return index.getElement(this); }
1530
1549
  static get watchers() { return {
1550
+ "defaultOid": ["defaultOidWatchHandler"],
1551
+ "defaultGlobalId": ["defaultGlobalIdWatchHandler"],
1531
1552
  "enableCSV": ["enableCSVWatchHandler"],
1532
1553
  "enableInlineEdit": ["enableInlineEditWatchHandler"],
1533
1554
  "enableShare": ["enableShareWatchHandler"],
@@ -24,8 +24,9 @@ const CrowdsourceManager = class {
24
24
  * MapView.when is not fired when mapView is not currently visible
25
25
  */
26
26
  this._shouldSetMapView = false;
27
+ this._defaultCenterHonored = false;
28
+ this._defaultLevelHonored = false;
27
29
  this.defaultCenter = "";
28
- this.defaultFilter = "";
29
30
  this.defaultGlobalId = "";
30
31
  this.defaultLayer = "";
31
32
  this.defaultLevel = "";
@@ -70,39 +71,6 @@ const CrowdsourceManager = class {
70
71
  // Watch handlers
71
72
  //
72
73
  //--------------------------------------------------------------------------
73
- /**
74
- * Watch for center url param to be set
75
- */
76
- defaultCenterWatchHandler() {
77
- this._defaultCenter = !this.defaultCenter ? undefined :
78
- this.defaultCenter.split(";").map(v => parseFloat(v));
79
- }
80
- /**
81
- * Watch for filter url param to be set
82
- */
83
- defaultFilterWatchHandler() {
84
- this._defaultFilter = JSON.parse(this.defaultFilter);
85
- }
86
- /**
87
- * Watch for globalid url param to be set
88
- */
89
- defaultGlobalIdWatchHandler() {
90
- this._defaultGlobalId = !this.defaultGlobalId ? undefined :
91
- this.defaultGlobalId.indexOf(",") > -1 ? this.defaultGlobalId.split(",") : [this.defaultGlobalId];
92
- }
93
- /**
94
- * Watch for oid url param to be set
95
- */
96
- defaultOidWatchHandler() {
97
- this._defaultOid = !this.defaultOid ? undefined :
98
- this.defaultOid.indexOf(",") > -1 ? this.defaultOid.split(",").map(o => parseInt(o, 10)) : [parseInt(this.defaultOid, 10)];
99
- }
100
- /**
101
- * Watch for zoom level param to be set
102
- */
103
- defaultLevelWatchHandler() {
104
- this._defaultLevel = !this.defaultLevel ? undefined : parseInt(this.defaultLevel, 10);
105
- }
106
74
  /**
107
75
  * When true the map zoom tools will be available
108
76
  */
@@ -394,6 +362,7 @@ const CrowdsourceManager = class {
394
362
  * @protected
395
363
  */
396
364
  _getTable(layoutMode, panelOpen, hideTable) {
365
+ var _a, _b;
397
366
  const tableClass = hideTable && this._isMobile ? "visibility-hidden" : "";
398
367
  const tableSizeClass = this._getTableSizeClass(layoutMode, panelOpen);
399
368
  const icon = this._getDividerIcon(layoutMode, panelOpen);
@@ -402,7 +371,11 @@ const CrowdsourceManager = class {
402
371
  const toggleLayout = layoutMode === interfaces.ELayoutMode.HORIZONTAL ? "horizontal" : "vertical";
403
372
  const toggleSlot = layoutMode === interfaces.ELayoutMode.HORIZONTAL ? "header" : "panel-start";
404
373
  const hasMapAndLayer = this.defaultWebmap && this.defaultLayer;
405
- return (index.h("calcite-shell", { class: `${tableSizeClass} ${tableClass} border-bottom` }, !this._isMobile ? (index.h("calcite-action-bar", { class: "border-sides", expandDisabled: true, layout: toggleLayout, slot: toggleSlot }, index.h("calcite-action", { class: "toggle-node", icon: icon, id: id, onClick: () => this._toggleLayout(), text: "" }), index.h("calcite-tooltip", { label: tooltip, placement: "bottom", "reference-element": id }, index.h("span", null, tooltip)))) : undefined, index.h("div", { class: `width-full height-full position-relative` }, index.h("layer-table", { defaultFilter: hasMapAndLayer ? this._defaultFilter : undefined, defaultGlobalId: hasMapAndLayer ? this._defaultGlobalId : undefined, defaultLayerId: hasMapAndLayer ? this.defaultLayer : "", defaultOid: hasMapAndLayer && !this.defaultGlobalId ? this._defaultOid : undefined, enableAutoRefresh: this.enableAutoRefresh, enableCSV: this.enableCSV, enableColumnReorder: this.enableColumnReorder, enableInlineEdit: this.enableInlineEdit, enableShare: this.enableShare, isMobile: this._isMobile, mapInfo: this._mapInfo, mapView: this === null || this === void 0 ? void 0 : this._mapView, onlyShowUpdatableLayers: this.onlyShowUpdatableLayers, ref: (el) => this._layerTable = el, shareIncludeEmbed: this.shareIncludeEmbed, shareIncludeSocial: this.shareIncludeSocial, showNewestFirst: this.showNewestFirst, zoomAndScrollToSelected: this.zoomAndScrollToSelected }))));
374
+ const globalId = !this.defaultGlobalId ? undefined :
375
+ ((_a = this.defaultGlobalId) === null || _a === void 0 ? void 0 : _a.indexOf(",")) > -1 ? this.defaultGlobalId.split(",") : [this.defaultGlobalId];
376
+ const defaultOid = !this.defaultOid ? undefined :
377
+ ((_b = this.defaultOid) === null || _b === void 0 ? void 0 : _b.indexOf(",")) > -1 ? this.defaultOid.split(",").map(o => parseInt(o, 10)) : [parseInt(this.defaultOid, 10)];
378
+ return (index.h("calcite-shell", { class: `${tableSizeClass} ${tableClass} border-bottom` }, !this._isMobile ? (index.h("calcite-action-bar", { class: "border-sides", expandDisabled: true, layout: toggleLayout, slot: toggleSlot }, index.h("calcite-action", { class: "toggle-node", icon: icon, id: id, onClick: () => this._toggleLayout(), text: "" }), index.h("calcite-tooltip", { label: tooltip, placement: "bottom", "reference-element": id }, index.h("span", null, tooltip)))) : undefined, index.h("div", { class: `width-full height-full position-relative` }, index.h("layer-table", { defaultGlobalId: hasMapAndLayer ? globalId : undefined, defaultLayerId: hasMapAndLayer ? this.defaultLayer : "", defaultOid: hasMapAndLayer && !globalId ? defaultOid : undefined, enableAutoRefresh: this.enableAutoRefresh, enableCSV: this.enableCSV, enableColumnReorder: this.enableColumnReorder, enableInlineEdit: this.enableInlineEdit, enableShare: this.enableShare, isMobile: this._isMobile, mapInfo: this._mapInfo, mapView: this === null || this === void 0 ? void 0 : this._mapView, onlyShowUpdatableLayers: this.onlyShowUpdatableLayers, ref: (el) => this._layerTable = el, shareIncludeEmbed: this.shareIncludeEmbed, shareIncludeSocial: this.shareIncludeSocial, showNewestFirst: this.showNewestFirst, zoomAndScrollToSelected: this.zoomAndScrollToSelected }))));
406
379
  }
407
380
  /**
408
381
  * Update the component layout when its size changes
@@ -455,17 +428,22 @@ const CrowdsourceManager = class {
455
428
  * @protected
456
429
  */
457
430
  async _setMapView() {
431
+ var _a;
458
432
  this._mapInfo = this._getMapInfo(this._mapChange.id);
459
433
  this._mapView = this._mapChange.mapView;
460
434
  this._initMapZoom();
461
435
  this._mapView.popupEnabled = false;
462
- if (this._defaultCenter && this._defaultLevel) {
436
+ const center = !this.defaultCenter || this._defaultCenterHonored ?
437
+ undefined : (_a = this.defaultCenter) === null || _a === void 0 ? void 0 : _a.split(";").map(v => parseFloat(v));
438
+ const zoom = !this.defaultLevel || this._defaultLevelHonored ?
439
+ undefined : parseInt(this.defaultLevel, 10);
440
+ if (center && zoom) {
463
441
  await this._mapView.goTo({
464
- center: this._defaultCenter,
465
- zoom: this._defaultLevel
442
+ center,
443
+ zoom
466
444
  });
467
- this._defaultCenter = undefined;
468
- this._defaultLevel = undefined;
445
+ this._defaultCenterHonored = true;
446
+ this._defaultLevelHonored = true;
469
447
  }
470
448
  }
471
449
  /**
@@ -497,11 +475,6 @@ const CrowdsourceManager = class {
497
475
  }
498
476
  get el() { return index.getElement(this); }
499
477
  static get watchers() { return {
500
- "defaultCenter": ["defaultCenterWatchHandler"],
501
- "defaultFilter": ["defaultFilterWatchHandler"],
502
- "defaultGlobalId": ["defaultGlobalIdWatchHandler"],
503
- "defaultOid": ["defaultOidWatchHandler"],
504
- "defaultLevel": ["defaultLevelWatchHandler"],
505
478
  "enableZoom": ["enableZoomWatchHandler"]
506
479
  }; }
507
480
  };