@esri/solutions-components 0.10.12 → 0.10.13

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.
Files changed (52) hide show
  1. package/dist/cjs/calcite-alert_4.cjs.entry.js +1 -1
  2. package/dist/cjs/calcite-flow_6.cjs.entry.js +103 -7
  3. package/dist/cjs/crowdsource-reporter.cjs.entry.js +173 -43
  4. package/dist/cjs/feature-list.cjs.entry.js +110 -17
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/{popupUtils-92e52dbf.js → popupUtils-47bd97e7.js} +1 -1
  7. package/dist/cjs/solutions-components.cjs.js +1 -1
  8. package/dist/collection/assets/t9n/crowdsource-reporter/resources.json +3 -1
  9. package/dist/collection/assets/t9n/crowdsource-reporter/resources_en.json +3 -1
  10. package/dist/collection/assets/t9n/feature-list/resources.json +3 -1
  11. package/dist/collection/assets/t9n/feature-list/resources_en.json +3 -1
  12. package/dist/collection/components/create-feature/create-feature.js +145 -2
  13. package/dist/collection/components/crowdsource-reporter/crowdsource-reporter.js +227 -43
  14. package/dist/collection/components/feature-list/feature-list.css +16 -1
  15. package/dist/collection/components/feature-list/feature-list.js +165 -15
  16. package/dist/collection/components/layer-list/layer-list.js +35 -6
  17. package/dist/collection/demos/crowdsource-reporter.html +2 -0
  18. package/dist/collection/utils/popupUtils.js +1 -1
  19. package/dist/collection/utils/popupUtils.ts +1 -1
  20. package/dist/components/create-feature2.js +91 -3
  21. package/dist/components/crowdsource-reporter.js +178 -45
  22. package/dist/components/feature-list2.js +152 -50
  23. package/dist/components/layer-list2.js +18 -6
  24. package/dist/components/popupUtils.js +1 -1
  25. package/dist/esm/calcite-alert_4.entry.js +1 -1
  26. package/dist/esm/calcite-flow_6.entry.js +104 -8
  27. package/dist/esm/crowdsource-reporter.entry.js +173 -43
  28. package/dist/esm/feature-list.entry.js +110 -17
  29. package/dist/esm/loader.js +1 -1
  30. package/dist/esm/{popupUtils-00c655fb.js → popupUtils-349a26e6.js} +1 -1
  31. package/dist/esm/solutions-components.js +1 -1
  32. package/dist/solutions-components/assets/t9n/crowdsource-reporter/resources.json +3 -1
  33. package/dist/solutions-components/assets/t9n/crowdsource-reporter/resources_en.json +3 -1
  34. package/dist/solutions-components/assets/t9n/feature-list/resources.json +3 -1
  35. package/dist/solutions-components/assets/t9n/feature-list/resources_en.json +3 -1
  36. package/dist/solutions-components/demos/crowdsource-reporter.html +2 -0
  37. package/dist/solutions-components/p-40e305b4.entry.js +17 -0
  38. package/dist/solutions-components/p-4d44410b.entry.js +6 -0
  39. package/dist/solutions-components/{p-900fee65.js → p-5a473f0d.js} +1 -1
  40. package/dist/solutions-components/p-9b83e593.entry.js +6 -0
  41. package/dist/solutions-components/{p-cde8d6e5.entry.js → p-f6bc95b3.entry.js} +1 -1
  42. package/dist/solutions-components/solutions-components.esm.js +1 -1
  43. package/dist/solutions-components/utils/popupUtils.ts +1 -1
  44. package/dist/types/components/create-feature/create-feature.d.ts +34 -0
  45. package/dist/types/components/crowdsource-reporter/crowdsource-reporter.d.ts +80 -21
  46. package/dist/types/components/feature-list/feature-list.d.ts +49 -7
  47. package/dist/types/components/layer-list/layer-list.d.ts +4 -0
  48. package/dist/types/components.d.ts +77 -0
  49. package/package.json +1 -1
  50. package/dist/solutions-components/p-064e43e0.entry.js +0 -6
  51. package/dist/solutions-components/p-2d1afda0.entry.js +0 -17
  52. package/dist/solutions-components/p-c9260b4c.entry.js +0 -6
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { r as registerInstance, c as createEvent, g as getElement, h } from './index-b793d9aa.js';
7
7
  import { l as loadModules, g as getLocaleComponentStrings } from './locale-b1d53fb1.js';
8
- import { P as PopupUtils } from './popupUtils-00c655fb.js';
8
+ import { P as PopupUtils } from './popupUtils-349a26e6.js';
9
9
  import { g as getLayerOrTable, c as getFeatureLayerView, h as highlightFeatures } from './mapViewUtils-3e3d33ea.js';
10
10
  import './esri-loader-c6842c6b.js';
11
11
  import './_commonjsHelpers-089957fe.js';
@@ -14,7 +14,7 @@ import './solution-resource-966f8511.js';
14
14
  import './restHelpersGet-788d7f7b.js';
15
15
  import './interfaces-659e3836.js';
16
16
 
17
- const featureListCss = ":host{display:block}.width-full{width:100%}.pagination{display:flex;justify-content:center}.error-msg{padding:10px;width:calc(100% - 20px)}.feature-list-popup-title{font-weight:500;white-space:pre-line}.feature-list-popup-title-small{font-size:small;white-space:pre-line}.feature-list-popup-title-padding{padding:10px 12px}.feature-list-popup-title-padding-reduced{padding:10px 0}.profile-img{margin:0 0.75rem;min-width:32px}";
17
+ const featureListCss = ":host{display:block}.width-full{width:100%}.pagination{display:flex;justify-content:center}.error-msg{padding:10px;width:calc(100% - 20px)}.feature-list-popup-title{font-weight:500;white-space:pre-line}.feature-list-popup-title-small{font-size:small;white-space:pre-line}.feature-list-popup-title-padding{padding:10px 12px}.feature-list-popup-title-padding-reduced{padding:10px 0}.profile-img{margin:0 0.75rem;min-width:32px}.like-container{display:flex;align-items:center;gap:5px;color:gray !important;font-style:italic}.feature-symbol{padding:3px 10px;min-width:30px;display:flex;justify-content:center}";
18
18
  const FeatureListStyle0 = featureListCss;
19
19
 
20
20
  const FeatureList = class {
@@ -33,6 +33,9 @@ const FeatureList = class {
33
33
  this.showInitialLoading = true;
34
34
  this.showErrorWhenNoFeatures = true;
35
35
  this.showUserImageInList = false;
36
+ this.showFeatureSymbol = false;
37
+ this.applyLayerViewFilter = false;
38
+ this.reportingOptions = undefined;
36
39
  this._featureItems = [];
37
40
  this._featuresCount = 0;
38
41
  this._isLoading = false;
@@ -54,6 +57,11 @@ const FeatureList = class {
54
57
  * Esri config
55
58
  */
56
59
  esriConfig;
60
+ /**
61
+ * "esri/symbols/support/symbolUtils": https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-support-symbolUtils.html
62
+ * Symbol utils
63
+ */
64
+ symbolUtils;
57
65
  /**
58
66
  * IPopupUtils: To fetch the list label using popup titles
59
67
  */
@@ -70,6 +78,18 @@ const FeatureList = class {
70
78
  * HTMLCalcitePaginationElement: Calcite pagination element instance
71
79
  */
72
80
  _pagination;
81
+ /**
82
+ * string[]: Valid field types for like
83
+ */
84
+ _validFieldTypes = ["small-integer", "integer", "big-integer", "single", "long"];
85
+ /**
86
+ * string: Abbrivated like count of the feature
87
+ */
88
+ _abbreviatedLikeCount;
89
+ /**
90
+ * boolean: When true configured like field is available in selected layer
91
+ */
92
+ _likeFieldAvailable = false;
73
93
  //--------------------------------------------------------------------------
74
94
  //
75
95
  // Watch handlers
@@ -143,9 +163,9 @@ const FeatureList = class {
143
163
  * Renders the component.
144
164
  */
145
165
  render() {
146
- return (h("calcite-panel", { key: 'ace7bcabf497e9a61d261fd7ea29dc664ee0a526', "full-height": true, "full-width": true }, this._isLoading && h("calcite-loader", { key: '675c7f5be7f8456954acdf353f357bac6145c390', label: "", scale: "m" }), this.showErrorWhenNoFeatures && this._featureItems.length === 0 && !this._isLoading &&
147
- h("calcite-notice", { key: 'b2e6537acdec801ef066a74c78a2c4a13dbbc44b', class: "error-msg", icon: "feature-details", kind: "info", open: true }, h("div", { key: '7697470234b396a904906b80e4fc8df3a0cc732b', slot: "message" }, this.noFeaturesFoundMsg ? this.noFeaturesFoundMsg : this._translations.featureErrorMsg)), h("calcite-list", { key: 'd2b40c9a5e1bf009cb78d640351a16b24711ff59', "selection-appearance": "border", "selection-mode": "none" }, !this._isLoading && this._featureItems.length > 0 && this._featureItems), this._featuresCount > this.pageSize &&
148
- h("div", { key: '15b0dae0fb914faf053a4b0cbea6e35ef7abc038', class: "width-full", slot: "footer" }, h("calcite-pagination", { key: '04f8eb02535f8cff8de0c111ac2d4bfa883ac128', class: "pagination", "full-width": true, onCalcitePaginationChange: this.pageChanged.bind(this), "page-size": this.pageSize, ref: el => this._pagination = el, "start-item": "1", "total-items": this._featuresCount }))));
166
+ return (h("calcite-panel", { key: 'b84cbd9d8c0f4d9d84fe7a49d149b67e88e46c53', "full-height": true, "full-width": true }, this._isLoading && h("calcite-loader", { key: '91ee86a3223b55141206be0d3f20bca1b777e4db', label: "", scale: "m" }), this.showErrorWhenNoFeatures && this._featureItems.length === 0 && !this._isLoading &&
167
+ h("calcite-notice", { key: '3c3b4a35c45715a86bd17630e8f3f9b566592c27', class: "error-msg", icon: "feature-details", kind: "info", open: true }, h("div", { key: '63a35389ac64f66c706fa05e92fb8f1af8dd0b69', slot: "message" }, this.noFeaturesFoundMsg ? this.noFeaturesFoundMsg : this._translations.featureErrorMsg)), h("calcite-list", { key: 'a237f97a0d286af17cce837bfbdd3c0d868ea023', "selection-appearance": "border", "selection-mode": "none" }, !this._isLoading && this._featureItems.length > 0 && this._featureItems), this._featuresCount > this.pageSize &&
168
+ h("div", { key: '9cb166b5095167a2004e93217240bea6789e9039', class: "width-full", slot: "footer" }, h("calcite-pagination", { key: 'a413b26dd30fdc89be1d65ef06995604f1430a18', class: "pagination", "full-width": true, onCalcitePaginationChange: this.pageChanged.bind(this), "page-size": this.pageSize, ref: el => this._pagination = el, "start-item": "1", "total-items": this._featuresCount }))));
149
169
  }
150
170
  //--------------------------------------------------------------------------
151
171
  //
@@ -153,23 +173,25 @@ const FeatureList = class {
153
173
  //
154
174
  //--------------------------------------------------------------------------
155
175
  /**
156
- * Load esri javascript api modules
157
- * @returns Promise resolving when function is done
158
- * @protected
159
- */
176
+ * Load esri javascript api modules
177
+ * @returns Promise resolving when function is done
178
+ * @protected
179
+ */
160
180
  async initModules() {
161
- const [Color, esriConfig] = await loadModules([
181
+ const [Color, esriConfig, symbolUtils] = await loadModules([
162
182
  "esri/Color",
163
183
  "esri/config",
184
+ "esri/symbols/support/symbolUtils"
164
185
  ]);
165
186
  this.Color = Color;
166
187
  this.esriConfig = esriConfig;
188
+ this.symbolUtils = symbolUtils;
167
189
  }
168
190
  /**
169
191
  * Return the where condition string considering the defined where clause and layer's definition expression
170
192
  * @protected
171
193
  */
172
- getWhereCondition() {
194
+ async getWhereCondition() {
173
195
  //By Default load all the features
174
196
  let whereClause = '1=1';
175
197
  //if where clause is defined use it
@@ -180,6 +202,13 @@ const FeatureList = class {
180
202
  if (this._selectedLayer?.definitionExpression) {
181
203
  whereClause = whereClause + ' AND ' + this._selectedLayer.definitionExpression;
182
204
  }
205
+ // if layerview has any applied filter, use it
206
+ if (this.applyLayerViewFilter) {
207
+ const selectedLayerView = await getFeatureLayerView(this.mapView, this.selectedLayerId);
208
+ if (selectedLayerView?.filter?.where) {
209
+ whereClause = whereClause + ' AND ' + selectedLayerView.filter.where;
210
+ }
211
+ }
183
212
  return whereClause;
184
213
  }
185
214
  /**
@@ -191,8 +220,9 @@ const FeatureList = class {
191
220
  void this._pagination?.goTo("start");
192
221
  this._isLoading = this.showInitialLoading;
193
222
  this._featureItems = await this.queryPage(0);
223
+ const whereCondition = await this.getWhereCondition();
194
224
  const query = {
195
- where: this.getWhereCondition()
225
+ where: whereCondition
196
226
  };
197
227
  this._featuresCount = await this._selectedLayer.queryFeatureCount(query);
198
228
  this._isLoading = false;
@@ -278,12 +308,13 @@ const FeatureList = class {
278
308
  const featureLayer = this._selectedLayer;
279
309
  const sortField = this.sortingInfo?.field ? this.sortingInfo.field : featureLayer.objectIdField;
280
310
  const sortOrder = this.sortingInfo?.order ? this.sortingInfo.order : 'desc';
311
+ const whereCondition = await this.getWhereCondition();
281
312
  const query = {
282
313
  start: page,
283
314
  num: this.pageSize,
284
315
  outFields: ["*"],
285
316
  returnGeometry: true,
286
- where: this.getWhereCondition(),
317
+ where: whereCondition,
287
318
  outSpatialReference: this.mapView.spatialReference.toJSON()
288
319
  };
289
320
  //sort only when sort field and order is valid
@@ -301,10 +332,12 @@ const FeatureList = class {
301
332
  */
302
333
  async createFeatureItem(featureSet) {
303
334
  const currentFeatures = featureSet?.features;
335
+ const showLikeCount = this.reportingOptions && this.reportingOptions[this.selectedLayerId].like;
304
336
  const items = currentFeatures.map(async (feature) => {
305
337
  const popupTitle = await this._popupUtils.getPopupTitle(feature, this.mapView.map);
306
338
  //fetch the feature creator user info to show the creator user image
307
339
  let userInfo;
340
+ let featureSymbol;
308
341
  if (this.showUserImageInList) {
309
342
  const creatorField = this._selectedLayer.editFieldsInfo?.creatorField.toLowerCase();
310
343
  // if feature's creator field is present then only we can fetch the information of user
@@ -312,10 +345,37 @@ const FeatureList = class {
312
345
  userInfo = await this.getUserInformation(feature, creatorField);
313
346
  }
314
347
  }
315
- return this.getFeatureItem(feature, popupTitle, userInfo);
348
+ if (this.showFeatureSymbol) {
349
+ featureSymbol = await this.getFeatureSymbol(feature);
350
+ }
351
+ if (showLikeCount) {
352
+ void this.getAbbreviatedLikeCount(feature);
353
+ }
354
+ return this.getFeatureItem(feature, popupTitle, featureSymbol, userInfo);
316
355
  });
317
356
  return Promise.all(items);
318
357
  }
358
+ /**
359
+ * Displays the abbrivated like count on the feature list
360
+ * @param feature feature of the layer
361
+ * @protected
362
+ */
363
+ getAbbreviatedLikeCount(feature) {
364
+ const selectedLayer = this._selectedLayer;
365
+ const likeField = this.reportingOptions[selectedLayer.id].likeField;
366
+ selectedLayer.fields.forEach((eachField) => {
367
+ if (this._validFieldTypes.indexOf(eachField.type) > -1) {
368
+ if (eachField.name === likeField && this.reportingOptions[selectedLayer.id].like) {
369
+ this._likeFieldAvailable = true;
370
+ let likes = feature.attributes[likeField] || 0;
371
+ if (likes > 999) {
372
+ likes = likes > 999999 ? this._translations.millionsAbbreviation.replace("{{abbreviated_value}}", Math.floor(likes / 1000000).toString()) : this._translations.thousandsAbbreviation.replace("{{abbreviated_value}}", Math.floor(likes / 1000).toString());
373
+ }
374
+ this._abbreviatedLikeCount = likes;
375
+ }
376
+ }
377
+ });
378
+ }
319
379
  /**
320
380
  * Get each feature item
321
381
  * @param selectedFeature Each individual feature instance to be listed
@@ -323,15 +383,19 @@ const FeatureList = class {
323
383
  * @returns individual feature item to be rendered
324
384
  * @protected
325
385
  */
326
- getFeatureItem(selectedFeature, popupTitle, userInfo) {
386
+ getFeatureItem(selectedFeature, popupTitle, featureSymbol, userInfo) {
327
387
  //get the object id value of the feature
328
388
  const oId = selectedFeature.attributes[this._selectedLayer.objectIdField].toString();
329
389
  //use object id if popupTitle is null or undefined
330
390
  popupTitle = popupTitle ?? oId;
391
+ // get the formatted like count
392
+ const formattedLikeCount = Number(selectedFeature.attributes[this.reportingOptions?.[this._selectedLayer.id].likeField]).toLocaleString();
331
393
  const popupTitleClass = this.textSize === 'small' ? 'feature-list-popup-title-small' : 'feature-list-popup-title';
332
- const popupTitlePaddingClass = this.showUserImageInList ? 'feature-list-popup-title-padding-reduced' : 'feature-list-popup-title-padding';
394
+ const popupTitlePaddingClass = this.showUserImageInList || this.showFeatureSymbol ? 'feature-list-popup-title-padding-reduced' : 'feature-list-popup-title-padding';
333
395
  return (h("calcite-list-item", { onCalciteListItemSelect: (e) => { void this.featureClicked(e, selectedFeature); }, onMouseLeave: () => { void this.clearHighlights(); }, onMouseOver: () => { void this.onFeatureHover(selectedFeature); }, value: oId }, this.showUserImageInList &&
334
- h("calcite-avatar", { class: 'profile-img', "full-name": userInfo?.fullName, id: userInfo?.id, scale: "m", slot: "content-start", thumbnail: userInfo?.userProfileUrl, username: userInfo?.username }), h("div", { class: `${popupTitleClass} ${popupTitlePaddingClass}`, slot: "content-start" }, popupTitle), h("calcite-icon", { flipRtl: true, icon: "chevron-right", scale: "s", slot: "content-end" })));
396
+ h("calcite-avatar", { class: 'profile-img', "full-name": userInfo?.fullName, id: userInfo?.id, scale: "m", slot: "content-start", thumbnail: userInfo?.userProfileUrl, username: userInfo?.username }), this.showFeatureSymbol &&
397
+ h("div", { class: 'feature-symbol', ref: (el) => el && el.appendChild(featureSymbol), slot: "content-start" }), h("div", { class: `${popupTitleClass} ${popupTitlePaddingClass}`, slot: "content-start" }, popupTitle), this._likeFieldAvailable &&
398
+ h("div", { class: "like-container", id: oId.concat("like"), slot: "content-end" }, h("span", null, this._abbreviatedLikeCount), h("calcite-icon", { icon: "thumbs-up", scale: 's' }), h("calcite-tooltip", { "reference-element": oId.concat("like") }, formattedLikeCount)), h("calcite-icon", { flipRtl: true, icon: "chevron-right", scale: "s", slot: "content-end" })));
335
399
  }
336
400
  /**
337
401
  *
@@ -358,6 +422,35 @@ const FeatureList = class {
358
422
  userInfo.userProfileUrl = userProfileUrl;
359
423
  return userInfo;
360
424
  }
425
+ /**
426
+ * Creates a feature symbology
427
+ * @param feature Each individual feature
428
+ * @returns Feature symbology
429
+ * @protected
430
+ */
431
+ async getFeatureSymbol(feature) {
432
+ const nodeHtml = document.createElement('div');
433
+ await this.symbolUtils.getDisplayedSymbol(feature).then(async (symbol) => {
434
+ symbol && await this.symbolUtils?.renderPreviewHTML(symbol, {
435
+ node: nodeHtml
436
+ });
437
+ if (nodeHtml.children?.length) {
438
+ const imgOrSvgElm = nodeHtml.children[0];
439
+ if (imgOrSvgElm) {
440
+ const height = Number(imgOrSvgElm.getAttribute('height'));
441
+ const width = Number(imgOrSvgElm.getAttribute('width'));
442
+ if (width > 30) {
443
+ imgOrSvgElm.setAttribute('width', '30');
444
+ }
445
+ else if (width < 19) {
446
+ imgOrSvgElm.setAttribute('width', '20');
447
+ }
448
+ imgOrSvgElm.setAttribute('viewBox', `0 0 ${width} ${height}`);
449
+ }
450
+ }
451
+ });
452
+ return nodeHtml;
453
+ }
361
454
  /**
362
455
  * Fetches the component's translations
363
456
  * @returns Promise when complete