@esri/solutions-components 0.8.8 → 0.8.10
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/assets/t9n/crowdsource-reporter/resources.json +11 -2
- package/dist/assets/t9n/crowdsource-reporter/resources_en.json +11 -2
- package/dist/cjs/{calcite-action-menu_2.cjs.entry.js → calcite-action-menu_3.cjs.entry.js} +114 -7
- package/dist/cjs/calcite-alert_4.cjs.entry.js +47 -5
- package/dist/cjs/{calcite-input-date-picker_3.cjs.entry.js → calcite-block_5.cjs.entry.js} +691 -13
- package/dist/cjs/{calcite-combobox_5.cjs.entry.js → calcite-combobox_3.cjs.entry.js} +876 -844
- package/dist/cjs/calcite-dropdown_4.cjs.entry.js +1023 -0
- package/dist/cjs/{calcite-flow_5.cjs.entry.js → calcite-flow_6.cjs.entry.js} +327 -2
- package/dist/cjs/card-manager_3.cjs.entry.js +5 -5
- package/dist/cjs/crowdsource-manager.cjs.entry.js +25 -17
- package/dist/cjs/crowdsource-reporter.cjs.entry.js +122 -21
- package/dist/cjs/{downloadUtils-8b05d7cc.js → downloadUtils-dd787ddf.js} +2 -2
- package/dist/cjs/{index.es-e7587227.js → index.es-29fa176d.js} +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/map-select-tools_3.cjs.entry.js +8 -8
- package/dist/cjs/{mapViewUtils-3e0fa457.js → mapViewUtils-82018df6.js} +12 -6
- package/dist/cjs/public-notification.cjs.entry.js +2 -2
- package/dist/cjs/solutions-components.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/create-feature/create-feature.js +18 -0
- package/dist/collection/components/crowdsource-manager/crowdsource-manager.css +15 -0
- package/dist/collection/components/crowdsource-manager/crowdsource-manager.js +48 -16
- package/dist/collection/components/crowdsource-reporter/crowdsource-reporter.css +16 -0
- package/dist/collection/components/crowdsource-reporter/crowdsource-reporter.js +155 -35
- package/dist/collection/components/feature-details/feature-details.css +18 -0
- package/dist/collection/components/feature-details/feature-details.js +500 -0
- package/dist/collection/components/feature-details/test/feature-details.e2e.js +14 -0
- package/dist/collection/components/feature-details/test/feature-details.spec.js +22 -0
- package/dist/collection/components/feature-list/feature-list.js +14 -1
- package/dist/collection/components/info-card/info-card.css +15 -5
- package/dist/collection/components/info-card/info-card.js +179 -5
- package/dist/collection/components/layer-table/layer-table.js +2 -2
- package/dist/collection/components/map-card/map-card.js +1 -1
- package/dist/collection/components/map-select-tools/map-select-tools.js +5 -5
- package/dist/collection/components/refine-selection/refine-selection.js +1 -1
- package/dist/collection/demos/crowdsource-manager.html +7 -2
- package/dist/collection/demos/crowdsource-reporter.html +115 -1
- package/dist/collection/utils/mapViewUtils.js +12 -6
- package/dist/collection/utils/mapViewUtils.ts +14 -6
- package/dist/components/create-feature2.js +4 -0
- package/dist/components/crowdsource-manager.js +26 -18
- package/dist/components/crowdsource-reporter.js +270 -81
- package/dist/components/feature-details.d.ts +11 -0
- package/dist/components/feature-details.js +11 -0
- package/dist/components/feature-details2.js +449 -0
- package/dist/components/feature-list2.js +14 -1
- package/dist/components/info-card2.js +54 -5
- package/dist/components/layer-table2.js +2 -2
- package/dist/components/map-card2.js +1 -1
- package/dist/components/map-select-tools2.js +5 -5
- package/dist/components/mapViewUtils.js +12 -6
- package/dist/components/refine-selection2.js +1 -1
- package/dist/esm/{calcite-action-menu_2.entry.js → calcite-action-menu_3.entry.js} +118 -12
- package/dist/esm/calcite-alert_4.entry.js +47 -5
- package/dist/esm/{calcite-input-date-picker_3.entry.js → calcite-block_5.entry.js} +688 -12
- package/dist/esm/{calcite-combobox_5.entry.js → calcite-combobox_3.entry.js} +878 -844
- package/dist/esm/calcite-date-picker-day_3.entry.js +1 -1
- package/dist/esm/calcite-dropdown_4.entry.js +1016 -0
- package/dist/esm/{calcite-flow_5.entry.js → calcite-flow_6.entry.js} +327 -3
- package/dist/esm/card-manager_3.entry.js +5 -5
- package/dist/esm/crowdsource-manager.entry.js +26 -18
- package/dist/esm/crowdsource-reporter.entry.js +122 -21
- package/dist/esm/{date-5630530d.js → date-0c026a8b.js} +1 -1
- package/dist/esm/{downloadUtils-0c1e4d7b.js → downloadUtils-25aa808f.js} +2 -2
- package/dist/esm/{index.es-286e3cfa.js → index.es-a16c9db4.js} +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/map-select-tools_3.entry.js +8 -8
- package/dist/esm/{mapViewUtils-253178f1.js → mapViewUtils-c83c03a4.js} +12 -6
- package/dist/esm/public-notification.entry.js +2 -2
- package/dist/esm/solutions-components.js +1 -1
- package/dist/solutions-components/demos/crowdsource-manager.html +7 -2
- package/dist/solutions-components/demos/crowdsource-reporter.html +115 -1
- package/dist/solutions-components/p-2f687975.entry.js +17 -0
- package/dist/solutions-components/{p-813fd8a4.entry.js → p-3e5085ae.entry.js} +2 -2
- package/dist/solutions-components/p-40039b84.entry.js +6 -0
- package/dist/solutions-components/p-511b1c91.entry.js +23 -0
- package/dist/solutions-components/{p-94de9279.js → p-5817d78c.js} +1 -1
- package/dist/solutions-components/{p-15f9624a.entry.js → p-58997cc1.entry.js} +1 -1
- package/dist/solutions-components/p-82e398cb.entry.js +17 -0
- package/dist/solutions-components/p-ae75d7d7.entry.js +6 -0
- package/dist/solutions-components/{p-331b5d1e.js → p-b1376c75.js} +2 -2
- package/dist/solutions-components/p-b5acfcd8.entry.js +6 -0
- package/dist/solutions-components/{p-212b02e7.js → p-bdd77f17.js} +1 -1
- package/dist/solutions-components/{p-038fcd93.entry.js → p-c273ab7a.entry.js} +1 -1
- package/dist/solutions-components/p-d742b915.entry.js +29 -0
- package/dist/solutions-components/p-d9c89479.js +36 -0
- package/dist/solutions-components/p-dfad61a8.entry.js +24 -0
- package/dist/solutions-components/p-fffc9e08.entry.js +6 -0
- package/dist/solutions-components/solutions-components.esm.js +1 -1
- package/dist/solutions-components/utils/mapViewUtils.ts +14 -6
- package/dist/types/components/create-feature/create-feature.d.ts +4 -4
- package/dist/types/components/crowdsource-manager/crowdsource-manager.d.ts +13 -1
- package/dist/types/components/crowdsource-reporter/crowdsource-reporter.d.ts +91 -10
- package/dist/types/components/feature-details/feature-details.d.ts +151 -0
- package/dist/types/components/feature-list/feature-list.d.ts +6 -0
- package/dist/types/components/info-card/info-card.d.ts +33 -1
- package/dist/types/components.d.ts +148 -12
- package/dist/types/preact.d.ts +9 -2
- package/dist/types/utils/mapViewUtils.d.ts +5 -3
- package/package.json +1 -1
- package/dist/cjs/calcite-block_2.cjs.entry.js +0 -652
- package/dist/cjs/calcite-graph_2.cjs.entry.js +0 -1055
- package/dist/cjs/calcite-scrim.cjs.entry.js +0 -125
- package/dist/cjs/utils-7bc7f595.js +0 -64
- package/dist/esm/calcite-block_2.entry.js +0 -647
- package/dist/esm/calcite-graph_2.entry.js +0 -1050
- package/dist/esm/calcite-scrim.entry.js +0 -121
- package/dist/esm/utils-9fb4104a.js +0 -61
- package/dist/solutions-components/p-04c37d69.entry.js +0 -17
- package/dist/solutions-components/p-0b92e4b1.entry.js +0 -11
- package/dist/solutions-components/p-13ca3b00.entry.js +0 -6
- package/dist/solutions-components/p-238d3b5f.entry.js +0 -6
- package/dist/solutions-components/p-3af79063.js +0 -36
- package/dist/solutions-components/p-80b11ec1.entry.js +0 -17
- package/dist/solutions-components/p-a3a11749.entry.js +0 -6
- package/dist/solutions-components/p-aec06ce4.entry.js +0 -18
- package/dist/solutions-components/p-bfdf89c2.js +0 -11
- package/dist/solutions-components/p-c4ff3b52.entry.js +0 -17
- package/dist/solutions-components/p-ced067bd.entry.js +0 -17
- package/dist/solutions-components/p-d136eab0.entry.js +0 -23
- package/dist/solutions-components/p-e0446d5b.entry.js +0 -6
@@ -0,0 +1,500 @@
|
|
1
|
+
/*!
|
2
|
+
* Copyright 2022 Esri
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
5
|
+
*/
|
6
|
+
import { h } from "@stencil/core";
|
7
|
+
import { loadModules } from "../../utils/loadModules";
|
8
|
+
export class FeatureDetails {
|
9
|
+
constructor() {
|
10
|
+
/**
|
11
|
+
* string[]: Valid field types for like and dislike
|
12
|
+
*/
|
13
|
+
this._validFieldTypes = ["small-integer", "integer", "big-integer", "single", "long"];
|
14
|
+
this.mapView = undefined;
|
15
|
+
this.graphics = undefined;
|
16
|
+
this.reportingOptions = undefined;
|
17
|
+
this._likeFieldAvailable = false;
|
18
|
+
this._likeCount = 0;
|
19
|
+
this._disLikeCount = 0;
|
20
|
+
this._dislikeFieldAvailable = false;
|
21
|
+
this._isLikeBtnClicked = false;
|
22
|
+
this._isDislikeBtnClicked = false;
|
23
|
+
}
|
24
|
+
//--------------------------------------------------------------------------
|
25
|
+
//
|
26
|
+
// Watch handlers
|
27
|
+
//
|
28
|
+
//--------------------------------------------------------------------------
|
29
|
+
/**
|
30
|
+
* Called each time the graphics prop is changed
|
31
|
+
*/
|
32
|
+
async graphicsWatchHandler() {
|
33
|
+
await this.getCompleteGraphic(this.graphics[0]);
|
34
|
+
this.checkLikeDislikeFields();
|
35
|
+
}
|
36
|
+
//--------------------------------------------------------------------------
|
37
|
+
//
|
38
|
+
// Methods (public)
|
39
|
+
/**
|
40
|
+
* Refresh the features comments which will fetch like, dislike and update the component
|
41
|
+
* @returns Promise that resolves when the operation is complete
|
42
|
+
*/
|
43
|
+
async refresh(graphic) {
|
44
|
+
if (this.isLikeDislikeConfigured(graphic.layer)) {
|
45
|
+
// in case of multiple features selected fetch complete feature and update like dislike for current feature
|
46
|
+
if (graphic && this.graphics.length > 1) {
|
47
|
+
await this.getCompleteGraphic(graphic);
|
48
|
+
this.checkLikeDislikeFields();
|
49
|
+
}
|
50
|
+
}
|
51
|
+
else {
|
52
|
+
this._likeFieldAvailable = false;
|
53
|
+
this._dislikeFieldAvailable = false;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
/**
|
57
|
+
* Go to the previous feature in the features widget
|
58
|
+
*/
|
59
|
+
async back() {
|
60
|
+
void this._infoCard.back();
|
61
|
+
}
|
62
|
+
/**
|
63
|
+
* Go to the next feature in the features widget
|
64
|
+
*/
|
65
|
+
async next() {
|
66
|
+
void this._infoCard.next();
|
67
|
+
}
|
68
|
+
/**
|
69
|
+
* Toggle the visibility of the features list view
|
70
|
+
*/
|
71
|
+
async toggleListView() {
|
72
|
+
void this._infoCard.toggleListView();
|
73
|
+
}
|
74
|
+
/**
|
75
|
+
* StencilJS: Called once just after the component is first connected to the DOM.
|
76
|
+
*
|
77
|
+
* @returns Promise when complete
|
78
|
+
*/
|
79
|
+
async componentWillLoad() {
|
80
|
+
await this._initModules();
|
81
|
+
await this.getCompleteGraphic(this.graphics[0]);
|
82
|
+
this.checkLikeDislikeFields();
|
83
|
+
}
|
84
|
+
render() {
|
85
|
+
var _a, _b, _c, _d;
|
86
|
+
return (h("calcite-panel", { "full-height": true }, h("info-card", { allowEditing: false, graphics: this.graphics, highlightEnabled: false, isLoading: false, isMobile: false, mapView: this.mapView, paginationEnabled: false, position: "relative", ref: el => this._infoCard = el, zoomAndScrollToSelected: true }), (this._likeFieldAvailable || this._dislikeFieldAvailable) &&
|
87
|
+
h("div", { class: 'buttons' }, this._likeFieldAvailable &&
|
88
|
+
h("calcite-button", { appearance: "transparent", iconEnd: "thumbs-up", kind: this._isLikeBtnClicked ? "brand" : "neutral", onClick: this.onLikeButtonClick.bind(this), scale: 's' }, (_b = (_a = this._likeCount) !== null && _a !== void 0 ? _a : this._selectedGraphic.attributes[this._likeField]) !== null && _b !== void 0 ? _b : 0), this._dislikeFieldAvailable &&
|
89
|
+
h("calcite-button", { appearance: "transparent", iconEnd: "thumbs-down", kind: this._isDislikeBtnClicked ? "brand" : "neutral", onClick: this.onDislikeButtonClick.bind(this), scale: 's' }, (_d = (_c = this._disLikeCount) !== null && _c !== void 0 ? _c : this._selectedGraphic.attributes[this._dislikeField]) !== null && _d !== void 0 ? _d : 0))));
|
90
|
+
}
|
91
|
+
/**
|
92
|
+
* Load esri javascript api modules
|
93
|
+
*
|
94
|
+
* @returns Promise resolving when function is done
|
95
|
+
*
|
96
|
+
* @protected
|
97
|
+
*/
|
98
|
+
async _initModules() {
|
99
|
+
const [Graphic] = await loadModules([
|
100
|
+
"esri/Graphic"
|
101
|
+
]);
|
102
|
+
this.Graphic = Graphic;
|
103
|
+
}
|
104
|
+
/**
|
105
|
+
* Get complete graphic with complete attributes
|
106
|
+
* @param graphic selected feature graphic
|
107
|
+
* @protected
|
108
|
+
*/
|
109
|
+
async getCompleteGraphic(graphic) {
|
110
|
+
const layer = graphic.layer;
|
111
|
+
const query = layer.createQuery();
|
112
|
+
query.objectIds = [graphic.getObjectId()];
|
113
|
+
const completeGraphic = await layer.queryFeatures(query);
|
114
|
+
this._selectedGraphic = completeGraphic.features[0];
|
115
|
+
}
|
116
|
+
/**
|
117
|
+
* Checks if the layers is configured for like dislike or not
|
118
|
+
* @param selectedLayer Feature layer
|
119
|
+
* @returns boolean
|
120
|
+
* @protected
|
121
|
+
*/
|
122
|
+
isLikeDislikeConfigured(selectedLayer) {
|
123
|
+
let likeFieldAvailable = false;
|
124
|
+
let dislikeFieldAvailable = false;
|
125
|
+
// check if reporting options are configured for the current selected feature's layer
|
126
|
+
if (this.reportingOptions && this.reportingOptions[selectedLayer.id]) {
|
127
|
+
//return false if both like and dislike are disabled for the layer
|
128
|
+
if (!this.reportingOptions[selectedLayer.id].like && !this.reportingOptions[selectedLayer.id].dislike) {
|
129
|
+
return false;
|
130
|
+
}
|
131
|
+
const likeField = this.reportingOptions[selectedLayer.id].likeField;
|
132
|
+
const dislikeField = this.reportingOptions[selectedLayer.id].dislikeField;
|
133
|
+
//if both fields are not configured return false
|
134
|
+
if (!likeField && !dislikeField) {
|
135
|
+
return false;
|
136
|
+
}
|
137
|
+
//Check if selected layer have the configured like and dislike field and it is of integer types
|
138
|
+
;
|
139
|
+
selectedLayer.fields.forEach((eachField) => {
|
140
|
+
if (this._validFieldTypes.indexOf(eachField.type) > -1) {
|
141
|
+
if (eachField.name === likeField && this.reportingOptions[selectedLayer.id].like) {
|
142
|
+
likeFieldAvailable = true;
|
143
|
+
}
|
144
|
+
else if (eachField.name === dislikeField && this.reportingOptions[selectedLayer.id].dislike) {
|
145
|
+
dislikeFieldAvailable = true;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
});
|
149
|
+
}
|
150
|
+
return likeFieldAvailable || dislikeFieldAvailable;
|
151
|
+
}
|
152
|
+
/**
|
153
|
+
* Check if configured like or dislike fields are available in the selected layer
|
154
|
+
* @protected
|
155
|
+
*/
|
156
|
+
checkLikeDislikeFields() {
|
157
|
+
this._likeFieldAvailable = false;
|
158
|
+
this._dislikeFieldAvailable = false;
|
159
|
+
this._isLikeBtnClicked = false;
|
160
|
+
this._isDislikeBtnClicked = false;
|
161
|
+
this._likeCount = 0;
|
162
|
+
this._disLikeCount = 0;
|
163
|
+
const selectedLayer = this._selectedGraphic.layer;
|
164
|
+
// check if reporting options are configured for the current selected feature's layer
|
165
|
+
if (this.reportingOptions && this.reportingOptions[selectedLayer.id]) {
|
166
|
+
this._likeField = this.reportingOptions[selectedLayer.id].likeField;
|
167
|
+
this._dislikeField = this.reportingOptions[selectedLayer.id].dislikeField;
|
168
|
+
//if both fields are not found return
|
169
|
+
if (!this._likeField && !this._dislikeField) {
|
170
|
+
return;
|
171
|
+
}
|
172
|
+
//Check if selected layer have the configured like and dislike fields
|
173
|
+
//also, get the current value for like and dislike field from the attributes
|
174
|
+
selectedLayer.fields.forEach((eachField) => {
|
175
|
+
if (this._validFieldTypes.indexOf(eachField.type) > -1) {
|
176
|
+
if (eachField.name === this._likeField && this.reportingOptions[this._selectedGraphic.layer.id].like) {
|
177
|
+
this._likeFieldAvailable = true;
|
178
|
+
this._likeCount = this._selectedGraphic.attributes[eachField.name];
|
179
|
+
}
|
180
|
+
else if (eachField.name === this._dislikeField && this.reportingOptions[this._selectedGraphic.layer.id].dislike) {
|
181
|
+
this._dislikeFieldAvailable = true;
|
182
|
+
this._disLikeCount = this._selectedGraphic.attributes[eachField.name];
|
183
|
+
}
|
184
|
+
}
|
185
|
+
});
|
186
|
+
this.getFromLocalStorage();
|
187
|
+
}
|
188
|
+
}
|
189
|
+
/**
|
190
|
+
* On like button click highlight the like button and update the feature
|
191
|
+
* @protected
|
192
|
+
*/
|
193
|
+
onLikeButtonClick() {
|
194
|
+
this.loadingStatus.emit(true);
|
195
|
+
if (this._isDislikeBtnClicked && this.reportingOptions[this._selectedGraphic.layer.id].dislike) {
|
196
|
+
this.onDislikeButtonClick();
|
197
|
+
}
|
198
|
+
this._isLikeBtnClicked = !this._isLikeBtnClicked;
|
199
|
+
if (this._isLikeBtnClicked) {
|
200
|
+
this._likeCount++;
|
201
|
+
}
|
202
|
+
else {
|
203
|
+
this._likeCount--;
|
204
|
+
}
|
205
|
+
void this.updateFeaturesLikeDislikeField(this._likeField, this._isLikeBtnClicked);
|
206
|
+
}
|
207
|
+
/**
|
208
|
+
* On dislike button click highlight the dislike button and update the feature
|
209
|
+
* @protected
|
210
|
+
*/
|
211
|
+
onDislikeButtonClick() {
|
212
|
+
this.loadingStatus.emit(true);
|
213
|
+
if (this._isLikeBtnClicked && this.reportingOptions[this._selectedGraphic.layer.id].like) {
|
214
|
+
this.onLikeButtonClick();
|
215
|
+
}
|
216
|
+
this._isDislikeBtnClicked = !this._isDislikeBtnClicked;
|
217
|
+
if (this._isDislikeBtnClicked) {
|
218
|
+
this._disLikeCount++;
|
219
|
+
}
|
220
|
+
else {
|
221
|
+
this._disLikeCount--;
|
222
|
+
}
|
223
|
+
void this.updateFeaturesLikeDislikeField(this._dislikeField, this._isDislikeBtnClicked);
|
224
|
+
}
|
225
|
+
/**
|
226
|
+
* Update the feature if user click on like or dislike button
|
227
|
+
* @param fieldName field name of the feature for like or dislike attribute
|
228
|
+
* @param buttonClicked is like or dislike button clicked
|
229
|
+
* @protected
|
230
|
+
*/
|
231
|
+
async updateFeaturesLikeDislikeField(fieldName, buttonClicked) {
|
232
|
+
const attributesToUpdate = {};
|
233
|
+
const selectedLayer = this._selectedGraphic.layer;
|
234
|
+
//Increment the value if button is clicked or else decrement it
|
235
|
+
const selectFeatureAttr = this._selectedGraphic;
|
236
|
+
if (buttonClicked) {
|
237
|
+
selectFeatureAttr.attributes[fieldName] = Number(selectFeatureAttr.attributes[fieldName]) + 1;
|
238
|
+
}
|
239
|
+
else {
|
240
|
+
selectFeatureAttr.attributes[fieldName] = Number(selectFeatureAttr.attributes[fieldName]) - 1;
|
241
|
+
}
|
242
|
+
//use the oid and like/dislike field value to update
|
243
|
+
attributesToUpdate[selectedLayer.objectIdField] = selectFeatureAttr.attributes[selectedLayer.objectIdField];
|
244
|
+
attributesToUpdate[fieldName] = selectFeatureAttr.attributes[fieldName];
|
245
|
+
const newGraphicInstance = new this.Graphic();
|
246
|
+
newGraphicInstance.attributes = attributesToUpdate;
|
247
|
+
// Update the feature attribute in the feature layer
|
248
|
+
const param = { updateFeatures: [newGraphicInstance] };
|
249
|
+
await selectedLayer.applyEdits(param).then(() => {
|
250
|
+
this._selectedGraphic = selectFeatureAttr;
|
251
|
+
//update the current graphics in info card so that, the updated values are reflected in popup content
|
252
|
+
if (this._infoCard) {
|
253
|
+
void this._infoCard.updateCurrentGraphic(this._selectedGraphic);
|
254
|
+
}
|
255
|
+
//store the like dislike value for the current selected graphic in local storage
|
256
|
+
this.setInLocalStorage();
|
257
|
+
this.loadingStatus.emit(false);
|
258
|
+
}, (err) => {
|
259
|
+
this.loadingStatus.emit(false);
|
260
|
+
console.log(err);
|
261
|
+
});
|
262
|
+
}
|
263
|
+
/**
|
264
|
+
* Gets the like/dislike information form local storage and updates the like and dislike button states
|
265
|
+
* @protected
|
266
|
+
*/
|
267
|
+
getFromLocalStorage() {
|
268
|
+
const uniqueLayerId = this._selectedGraphic.layer.id;
|
269
|
+
//get the data from local storage and check current feature is liked or disliked
|
270
|
+
const localStorageUser = localStorage[uniqueLayerId];
|
271
|
+
if (localStorageUser) {
|
272
|
+
const parseArr = JSON.parse(localStorageUser);
|
273
|
+
const res = parseArr.filter((arr) => arr.id === this._selectedGraphic.getObjectId());
|
274
|
+
if (res.length > 0) {
|
275
|
+
this._isLikeBtnClicked = res[0].like;
|
276
|
+
this._isDislikeBtnClicked = res[0].dislike;
|
277
|
+
}
|
278
|
+
}
|
279
|
+
}
|
280
|
+
/**
|
281
|
+
* Sets the like/dislike information for the current selected graphic in local storage
|
282
|
+
* @protected
|
283
|
+
*/
|
284
|
+
setInLocalStorage() {
|
285
|
+
const uniqueLayerId = this._selectedGraphic.layer.id;
|
286
|
+
const localStorageInfo = localStorage[uniqueLayerId];
|
287
|
+
let information = [];
|
288
|
+
//if information for the current layer found in local storage update it
|
289
|
+
//else add new information for the current layer in the local storage
|
290
|
+
if (localStorageInfo) {
|
291
|
+
information = JSON.parse(localStorageInfo);
|
292
|
+
const index = information.findIndex((arr) => arr.id === this._selectedGraphic.getObjectId());
|
293
|
+
//if information for current objectid found delete it, so that we always have info for each oid in a layer only once
|
294
|
+
if (index >= 0) {
|
295
|
+
information.splice(index, 1);
|
296
|
+
}
|
297
|
+
}
|
298
|
+
//add the information for current selected graphic
|
299
|
+
information.push({
|
300
|
+
id: this._selectedGraphic.getObjectId(),
|
301
|
+
like: this._isLikeBtnClicked && this._likeCount !== 0,
|
302
|
+
dislike: this._isDislikeBtnClicked && this._disLikeCount !== 0
|
303
|
+
});
|
304
|
+
localStorage.setItem(uniqueLayerId, JSON.stringify(information));
|
305
|
+
}
|
306
|
+
static get is() { return "feature-details"; }
|
307
|
+
static get originalStyleUrls() {
|
308
|
+
return {
|
309
|
+
"$": ["feature-details.css"]
|
310
|
+
};
|
311
|
+
}
|
312
|
+
static get styleUrls() {
|
313
|
+
return {
|
314
|
+
"$": ["feature-details.css"]
|
315
|
+
};
|
316
|
+
}
|
317
|
+
static get properties() {
|
318
|
+
return {
|
319
|
+
"mapView": {
|
320
|
+
"type": "unknown",
|
321
|
+
"mutable": false,
|
322
|
+
"complexType": {
|
323
|
+
"original": "__esri.MapView",
|
324
|
+
"resolved": "MapView",
|
325
|
+
"references": {
|
326
|
+
"___esri": {
|
327
|
+
"location": "global",
|
328
|
+
"id": "global::___esri"
|
329
|
+
}
|
330
|
+
}
|
331
|
+
},
|
332
|
+
"required": false,
|
333
|
+
"optional": false,
|
334
|
+
"docs": {
|
335
|
+
"tags": [],
|
336
|
+
"text": "esri/views/MapView: https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html"
|
337
|
+
}
|
338
|
+
},
|
339
|
+
"graphics": {
|
340
|
+
"type": "unknown",
|
341
|
+
"mutable": false,
|
342
|
+
"complexType": {
|
343
|
+
"original": "__esri.Graphic[]",
|
344
|
+
"resolved": "Graphic[]",
|
345
|
+
"references": {
|
346
|
+
"___esri": {
|
347
|
+
"location": "global",
|
348
|
+
"id": "global::___esri"
|
349
|
+
}
|
350
|
+
}
|
351
|
+
},
|
352
|
+
"required": false,
|
353
|
+
"optional": false,
|
354
|
+
"docs": {
|
355
|
+
"tags": [],
|
356
|
+
"text": "esri/Graphic: https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html"
|
357
|
+
}
|
358
|
+
},
|
359
|
+
"reportingOptions": {
|
360
|
+
"type": "unknown",
|
361
|
+
"mutable": false,
|
362
|
+
"complexType": {
|
363
|
+
"original": "IReportingOptions",
|
364
|
+
"resolved": "IReportingOptions",
|
365
|
+
"references": {
|
366
|
+
"IReportingOptions": {
|
367
|
+
"location": "import",
|
368
|
+
"path": "../../components",
|
369
|
+
"id": "src/components.d.ts::IReportingOptions"
|
370
|
+
}
|
371
|
+
}
|
372
|
+
},
|
373
|
+
"required": false,
|
374
|
+
"optional": false,
|
375
|
+
"docs": {
|
376
|
+
"tags": [],
|
377
|
+
"text": "IReportingOptions: Key options for reporting"
|
378
|
+
}
|
379
|
+
}
|
380
|
+
};
|
381
|
+
}
|
382
|
+
static get states() {
|
383
|
+
return {
|
384
|
+
"_likeFieldAvailable": {},
|
385
|
+
"_likeCount": {},
|
386
|
+
"_disLikeCount": {},
|
387
|
+
"_dislikeFieldAvailable": {},
|
388
|
+
"_isLikeBtnClicked": {},
|
389
|
+
"_isDislikeBtnClicked": {}
|
390
|
+
};
|
391
|
+
}
|
392
|
+
static get events() {
|
393
|
+
return [{
|
394
|
+
"method": "loadingStatus",
|
395
|
+
"name": "loadingStatus",
|
396
|
+
"bubbles": true,
|
397
|
+
"cancelable": true,
|
398
|
+
"composed": true,
|
399
|
+
"docs": {
|
400
|
+
"tags": [],
|
401
|
+
"text": "Emitted on demand when like or dislike button is clicked"
|
402
|
+
},
|
403
|
+
"complexType": {
|
404
|
+
"original": "boolean",
|
405
|
+
"resolved": "boolean",
|
406
|
+
"references": {}
|
407
|
+
}
|
408
|
+
}];
|
409
|
+
}
|
410
|
+
static get methods() {
|
411
|
+
return {
|
412
|
+
"refresh": {
|
413
|
+
"complexType": {
|
414
|
+
"signature": "(graphic?: __esri.Graphic) => Promise<void>",
|
415
|
+
"parameters": [{
|
416
|
+
"name": "graphic",
|
417
|
+
"type": "Graphic",
|
418
|
+
"docs": ""
|
419
|
+
}],
|
420
|
+
"references": {
|
421
|
+
"Promise": {
|
422
|
+
"location": "global",
|
423
|
+
"id": "global::Promise"
|
424
|
+
},
|
425
|
+
"___esri": {
|
426
|
+
"location": "global",
|
427
|
+
"id": "global::___esri"
|
428
|
+
}
|
429
|
+
},
|
430
|
+
"return": "Promise<void>"
|
431
|
+
},
|
432
|
+
"docs": {
|
433
|
+
"text": "Refresh the features comments which will fetch like, dislike and update the component",
|
434
|
+
"tags": [{
|
435
|
+
"name": "returns",
|
436
|
+
"text": "Promise that resolves when the operation is complete"
|
437
|
+
}]
|
438
|
+
}
|
439
|
+
},
|
440
|
+
"back": {
|
441
|
+
"complexType": {
|
442
|
+
"signature": "() => Promise<void>",
|
443
|
+
"parameters": [],
|
444
|
+
"references": {
|
445
|
+
"Promise": {
|
446
|
+
"location": "global",
|
447
|
+
"id": "global::Promise"
|
448
|
+
}
|
449
|
+
},
|
450
|
+
"return": "Promise<void>"
|
451
|
+
},
|
452
|
+
"docs": {
|
453
|
+
"text": "Go to the previous feature in the features widget",
|
454
|
+
"tags": []
|
455
|
+
}
|
456
|
+
},
|
457
|
+
"next": {
|
458
|
+
"complexType": {
|
459
|
+
"signature": "() => Promise<void>",
|
460
|
+
"parameters": [],
|
461
|
+
"references": {
|
462
|
+
"Promise": {
|
463
|
+
"location": "global",
|
464
|
+
"id": "global::Promise"
|
465
|
+
}
|
466
|
+
},
|
467
|
+
"return": "Promise<void>"
|
468
|
+
},
|
469
|
+
"docs": {
|
470
|
+
"text": "Go to the next feature in the features widget",
|
471
|
+
"tags": []
|
472
|
+
}
|
473
|
+
},
|
474
|
+
"toggleListView": {
|
475
|
+
"complexType": {
|
476
|
+
"signature": "() => Promise<void>",
|
477
|
+
"parameters": [],
|
478
|
+
"references": {
|
479
|
+
"Promise": {
|
480
|
+
"location": "global",
|
481
|
+
"id": "global::Promise"
|
482
|
+
}
|
483
|
+
},
|
484
|
+
"return": "Promise<void>"
|
485
|
+
},
|
486
|
+
"docs": {
|
487
|
+
"text": "Toggle the visibility of the features list view",
|
488
|
+
"tags": []
|
489
|
+
}
|
490
|
+
}
|
491
|
+
};
|
492
|
+
}
|
493
|
+
static get elementRef() { return "el"; }
|
494
|
+
static get watchers() {
|
495
|
+
return [{
|
496
|
+
"propName": "graphics",
|
497
|
+
"methodName": "graphicsWatchHandler"
|
498
|
+
}];
|
499
|
+
}
|
500
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/*!
|
2
|
+
* Copyright 2022 Esri
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
5
|
+
*/
|
6
|
+
import { newE2EPage } from "@stencil/core/testing";
|
7
|
+
xdescribe('feature-details', () => {
|
8
|
+
it('renders', async () => {
|
9
|
+
const page = await newE2EPage();
|
10
|
+
await page.setContent('<feature-details></feature-details>');
|
11
|
+
const element = await page.find('feature-details');
|
12
|
+
expect(element).toHaveClass('hydrated');
|
13
|
+
});
|
14
|
+
});
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/*!
|
2
|
+
* Copyright 2022 Esri
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
5
|
+
*/
|
6
|
+
import { newSpecPage } from "@stencil/core/testing";
|
7
|
+
import { FeatureDetails } from "../feature-details";
|
8
|
+
xdescribe('feature-details', () => {
|
9
|
+
it('renders', async () => {
|
10
|
+
const page = await newSpecPage({
|
11
|
+
components: [FeatureDetails],
|
12
|
+
html: `<feature-details></feature-details>`,
|
13
|
+
});
|
14
|
+
expect(page.root).toEqualHtml(`
|
15
|
+
<feature-details>
|
16
|
+
<mock:shadow-root>
|
17
|
+
<slot></slot>
|
18
|
+
</mock:shadow-root>
|
19
|
+
</feature-details>
|
20
|
+
`);
|
21
|
+
});
|
22
|
+
});
|
@@ -148,7 +148,20 @@ export class FeatureList {
|
|
148
148
|
const selectedLayerView = await getFeatureLayerView(this.mapView, this.selectedLayerId);
|
149
149
|
this._highlightHandle = await highlightFeatures([selectedFeatureObjectId], selectedLayerView, this.mapView, true);
|
150
150
|
}
|
151
|
-
this.
|
151
|
+
await this.emitSelectedFeature(selectedFeature);
|
152
|
+
}
|
153
|
+
/**
|
154
|
+
* Emit selected feature with its complete graphics and attributes
|
155
|
+
* @param graphic selected feature graphic
|
156
|
+
* @protected
|
157
|
+
*/
|
158
|
+
async emitSelectedFeature(graphic) {
|
159
|
+
const layer = graphic.layer;
|
160
|
+
const query = layer.createQuery();
|
161
|
+
query.returnGeometry = true;
|
162
|
+
query.objectIds = [graphic.getObjectId()];
|
163
|
+
const completeGraphic = await layer.queryFeatures(query);
|
164
|
+
this.featureSelect.emit(completeGraphic.features[0]);
|
152
165
|
}
|
153
166
|
/**
|
154
167
|
* On feature hover in feature list highlight the feature on the map
|
@@ -40,12 +40,16 @@
|
|
40
40
|
overflow: auto;
|
41
41
|
}
|
42
42
|
|
43
|
+
.feature-node {
|
44
|
+
position: relative !important;
|
45
|
+
}
|
46
|
+
|
43
47
|
.feature-node .esri-features__footer {
|
44
48
|
display: none !important;
|
45
49
|
}
|
46
50
|
|
47
51
|
.button-container {
|
48
|
-
justify-content:
|
52
|
+
justify-content: center;
|
49
53
|
align-items: center;
|
50
54
|
}
|
51
55
|
|
@@ -53,10 +57,6 @@
|
|
53
57
|
border-top: 1px solid var(--calcite-color-border-1);
|
54
58
|
}
|
55
59
|
|
56
|
-
.min-width-100 {
|
57
|
-
min-width: 100px;
|
58
|
-
}
|
59
|
-
|
60
60
|
.width-100 {
|
61
61
|
width: 100%;
|
62
62
|
}
|
@@ -95,3 +95,13 @@
|
|
95
95
|
.border-width-0 {
|
96
96
|
border-width: 0px;
|
97
97
|
}
|
98
|
+
|
99
|
+
.pagination-action {
|
100
|
+
position: relative;
|
101
|
+
left: 3px;
|
102
|
+
}
|
103
|
+
|
104
|
+
.pagination-count {
|
105
|
+
color: var(--calcite-color-brand);
|
106
|
+
border-bottom: 1px solid var(--calcite-color-brand);
|
107
|
+
}
|