@esri/solutions-components 0.10.12 → 0.10.14

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