@esri/solutions-components 0.7.31 → 0.7.33
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/calcite-flow_5.cjs.entry.js +94 -43
- package/dist/cjs/card-manager_3.cjs.entry.js +1 -1
- package/dist/cjs/crowdsource-reporter.cjs.entry.js +35 -8
- package/dist/cjs/{downloadUtils-10e0de31.js → downloadUtils-6b451886.js} +2 -2
- package/dist/cjs/{index.es-72dc7ab9.js → index.es-3eaba9ef.js} +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/map-select-tools_3.cjs.entry.js +1 -1
- package/dist/cjs/public-notification.cjs.entry.js +1 -1
- package/dist/cjs/solutions-components.cjs.js +1 -1
- package/dist/collection/components/basemap-gallery/basemap-gallery.css +19 -19
- package/dist/collection/components/create-feature/create-feature.css +27 -0
- package/dist/collection/components/create-feature/create-feature.js +126 -43
- package/dist/collection/components/crowdsource-reporter/crowdsource-reporter.js +35 -8
- package/dist/collection/components/map-fullscreen/map-fullscreen.css +19 -19
- package/dist/collection/components/map-legend/map-legend.css +3 -3
- package/dist/collection/demos/create-feature.html +90 -0
- package/dist/collection/utils/downloadUtils.js +1 -1
- package/dist/collection/utils/downloadUtils.ts +1 -1
- package/dist/components/create-feature2.js +96 -44
- package/dist/components/crowdsource-reporter.js +35 -8
- package/dist/components/downloadUtils.js +1 -1
- package/dist/esm/calcite-flow_5.entry.js +95 -44
- package/dist/esm/card-manager_3.entry.js +1 -1
- package/dist/esm/crowdsource-reporter.entry.js +35 -8
- package/dist/esm/{downloadUtils-d297078f.js → downloadUtils-4577cf8b.js} +2 -2
- package/dist/esm/{index.es-3b4fa9d0.js → index.es-a28dad8e.js} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/map-select-tools_3.entry.js +1 -1
- package/dist/esm/public-notification.entry.js +1 -1
- package/dist/esm/solutions-components.js +1 -1
- package/dist/solutions-components/demos/create-feature.html +90 -0
- package/dist/solutions-components/{p-09ec8c8f.entry.js → p-288dfd06.entry.js} +1 -1
- package/dist/solutions-components/{p-103c5318.js → p-6c85b276.js} +2 -2
- package/dist/solutions-components/{p-57d49d15.entry.js → p-a84acc82.entry.js} +1 -1
- package/dist/solutions-components/{p-8ec25bf4.js → p-b1a5f341.js} +1 -1
- package/dist/solutions-components/p-d5263cb9.entry.js +17 -0
- package/dist/solutions-components/{p-921f21d5.entry.js → p-e22bce70.entry.js} +1 -1
- package/dist/solutions-components/p-ea17cefb.entry.js +6 -0
- package/dist/solutions-components/solutions-components.esm.js +1 -1
- package/dist/solutions-components/utils/downloadUtils.ts +1 -1
- package/dist/solutions-components_commit.txt +7 -0
- package/dist/types/components/create-feature/create-feature.d.ts +21 -3
- package/dist/types/components/crowdsource-reporter/crowdsource-reporter.d.ts +18 -4
- package/dist/types/components.d.ts +13 -0
- package/dist/types/preact.d.ts +2 -1
- package/package.json +1 -1
- package/dist/solutions-components/p-b4e2cac4.entry.js +0 -17
- package/dist/solutions-components/p-bb6562ab.entry.js +0 -6
@@ -5,9 +5,9 @@
|
|
5
5
|
*/
|
6
6
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
7
7
|
import { l as loadModules } from './loadModules.js';
|
8
|
-
import {
|
8
|
+
import { a as getAllLayers } from './mapViewUtils.js';
|
9
9
|
|
10
|
-
const createFeatureCss = ":host{display:block}.esri-editor__panel-toolbar{display:none !important}";
|
10
|
+
const createFeatureCss = ":host{display:block}.esri-editor__panel-toolbar{display:none !important}.esri-editor__update-actions{display:none !important}.esri-editor__panel-content{padding-block:0px !important}.esri-editor .esri-item-list__group__header{display:none !important}.esri-editor__panel-content__section .esri-widget__heading{display:none !important}.esri-editor .esri-item-list__filter-container--sticky{padding-block:0px !important;padding-inline:10px !important}";
|
11
11
|
|
12
12
|
const CreateFeature = /*@__PURE__*/ proxyCustomElement(class CreateFeature extends HTMLElement {
|
13
13
|
constructor() {
|
@@ -16,8 +16,10 @@ const CreateFeature = /*@__PURE__*/ proxyCustomElement(class CreateFeature exten
|
|
16
16
|
this.success = createEvent(this, "success", 7);
|
17
17
|
this.fail = createEvent(this, "fail", 7);
|
18
18
|
this.drawComplete = createEvent(this, "drawComplete", 7);
|
19
|
+
this.editingAttachment = createEvent(this, "editingAttachment", 7);
|
19
20
|
this.mapView = undefined;
|
20
21
|
this.selectedLayerId = undefined;
|
22
|
+
this.customizeSubmit = false;
|
21
23
|
}
|
22
24
|
//--------------------------------------------------------------------------
|
23
25
|
//
|
@@ -88,18 +90,8 @@ const CreateFeature = /*@__PURE__*/ proxyCustomElement(class CreateFeature exten
|
|
88
90
|
* Init Editor widget and starts the create workflow
|
89
91
|
*/
|
90
92
|
async init() {
|
91
|
-
if (this.mapView) {
|
92
|
-
|
93
|
-
await getLayerOrTable(this.mapView, this.selectedLayerId);
|
94
|
-
await this.createEditorWidget();
|
95
|
-
await this.startCreate();
|
96
|
-
this._editor.viewModel.featureFormViewModel.on('submit', this.submitted.bind(this));
|
97
|
-
setTimeout(() => {
|
98
|
-
var _a, _b;
|
99
|
-
this.el.querySelector('.esri-editor').querySelectorAll('calcite-flow-item')[1].shadowRoot.querySelector('calcite-panel').shadowRoot.querySelector('article').querySelector('header').setAttribute('style', 'display: none');
|
100
|
-
(_b = (_a = this.el.querySelector('.esri-editor').querySelectorAll('calcite-flow-item')[1].shadowRoot.querySelector('calcite-panel').shadowRoot.querySelector('article')) === null || _a === void 0 ? void 0 : _a.querySelector('footer')) === null || _b === void 0 ? void 0 : _b.setAttribute('style', 'display: none');
|
101
|
-
}, 700);
|
102
|
-
}
|
93
|
+
if (this.mapView && this.selectedLayerId) {
|
94
|
+
await this.createEditorWidget();
|
103
95
|
}
|
104
96
|
}
|
105
97
|
/**
|
@@ -108,10 +100,12 @@ const CreateFeature = /*@__PURE__*/ proxyCustomElement(class CreateFeature exten
|
|
108
100
|
* @protected
|
109
101
|
*/
|
110
102
|
async initModules() {
|
111
|
-
const [Editor] = await loadModules([
|
112
|
-
"esri/widgets/Editor"
|
103
|
+
const [Editor, reactiveUtils] = await loadModules([
|
104
|
+
"esri/widgets/Editor",
|
105
|
+
"esri/core/reactiveUtils"
|
113
106
|
]);
|
114
107
|
this.Editor = Editor;
|
108
|
+
this.reactiveUtils = reactiveUtils;
|
115
109
|
}
|
116
110
|
/**
|
117
111
|
* Display editor widget to create the new feature
|
@@ -121,51 +115,105 @@ const CreateFeature = /*@__PURE__*/ proxyCustomElement(class CreateFeature exten
|
|
121
115
|
if (this._editor) {
|
122
116
|
this._editor.destroy();
|
123
117
|
}
|
118
|
+
const layerInfos = [];
|
124
119
|
const container = document.createElement("div");
|
125
|
-
const
|
126
|
-
|
127
|
-
|
128
|
-
|
120
|
+
const allMapLayers = await getAllLayers(this.mapView);
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
122
|
+
allMapLayers.forEach(async (eachLayer) => {
|
123
|
+
layerInfos.push({
|
124
|
+
layer: eachLayer,
|
125
|
+
enabled: (eachLayer === null || eachLayer === void 0 ? void 0 : eachLayer.type) === "feature" && (eachLayer === null || eachLayer === void 0 ? void 0 : eachLayer.id) === this.selectedLayerId,
|
126
|
+
addEnabled: true,
|
127
|
+
updateEnabled: false,
|
128
|
+
deleteEnabled: false // default is true, set to false to disable the ability to delete features
|
129
|
+
});
|
130
|
+
});
|
129
131
|
this._editor = new this.Editor({
|
130
132
|
allowedWorkflows: "create-features",
|
131
133
|
view: this.mapView,
|
132
|
-
layerInfos:
|
134
|
+
layerInfos: layerInfos,
|
133
135
|
visibleElements: {
|
134
|
-
snappingControls: false
|
135
|
-
snappingControlsElements: {
|
136
|
-
featureEnabledToggle: false,
|
137
|
-
layerList: false,
|
138
|
-
enabledToggle: false
|
139
|
-
}
|
136
|
+
snappingControls: false
|
140
137
|
},
|
141
|
-
container
|
138
|
+
container
|
142
139
|
});
|
143
140
|
this.el.appendChild(container);
|
141
|
+
//Add handle to watch if attachments are added/edited
|
142
|
+
const attachmentHandle = this.reactiveUtils.watch(() => this._editor.viewModel.state, (state) => {
|
143
|
+
if (state === 'adding-attachment' || state === 'editing-attachment') {
|
144
|
+
this._addingAttachment = true;
|
145
|
+
this.editingAttachment.emit(true);
|
146
|
+
}
|
147
|
+
else {
|
148
|
+
if (this._addingAttachment) {
|
149
|
+
this.editingAttachment.emit(false);
|
150
|
+
this._addingAttachment = false;
|
151
|
+
}
|
152
|
+
}
|
153
|
+
});
|
154
|
+
this._editor.viewModel.addHandles(attachmentHandle);
|
155
|
+
//Add handle to watch featureTemplatesViewModel ready state and then start the creation
|
156
|
+
const handle = this.reactiveUtils.watch(() => this._editor.viewModel.featureTemplatesViewModel.state, (state) => {
|
157
|
+
if (state === 'ready') {
|
158
|
+
void this.startCreate();
|
159
|
+
}
|
160
|
+
});
|
161
|
+
this._editor.viewModel.addHandles(handle);
|
144
162
|
}
|
145
163
|
/**
|
146
164
|
* Start creating the feature
|
147
165
|
* @protected
|
148
166
|
*/
|
149
167
|
async startCreate() {
|
150
|
-
var _a
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
168
|
+
var _a;
|
169
|
+
if ((_a = this._editor.viewModel.featureTemplatesViewModel.items) === null || _a === void 0 ? void 0 : _a.length) {
|
170
|
+
const items = this._editor.viewModel.featureTemplatesViewModel.items[0].get("items");
|
171
|
+
//once the feature template is selected handle the event for formSubmit and sketch complete
|
172
|
+
//also, hide the headers and footer in the editor as we will be showing our own submit and cancel button
|
173
|
+
this._editor.viewModel.featureTemplatesViewModel.on('select', () => {
|
174
|
+
setTimeout(() => {
|
175
|
+
//on form submit
|
176
|
+
this._editor.viewModel.featureFormViewModel.on('submit', this.submitted.bind(this));
|
177
|
+
//on sketch complete emit the event
|
178
|
+
this._editor.viewModel.sketchViewModel.on("create", (evt) => {
|
179
|
+
if (evt.state === "complete") {
|
180
|
+
this.drawComplete.emit();
|
181
|
+
}
|
182
|
+
});
|
183
|
+
this.hideEditorsElements();
|
184
|
+
}, 700);
|
185
|
+
this.hideEditorsElements();
|
166
186
|
});
|
187
|
+
//if only one feature template then directly start geometry creation for that
|
188
|
+
//else allow feature template selection to user
|
189
|
+
if (items.length === 1) {
|
190
|
+
this._editor.viewModel.featureTemplatesViewModel.select(items[0]);
|
191
|
+
}
|
192
|
+
//hides the header and footer elements in editor widget
|
193
|
+
this.hideEditorsElements();
|
167
194
|
}
|
168
195
|
}
|
196
|
+
/**
|
197
|
+
* Hides the elements of editor widget
|
198
|
+
* @protected
|
199
|
+
*/
|
200
|
+
hideEditorsElements() {
|
201
|
+
if (!this.customizeSubmit) {
|
202
|
+
return;
|
203
|
+
}
|
204
|
+
setTimeout(() => {
|
205
|
+
var _a;
|
206
|
+
//hides the header and footer on the featureForm
|
207
|
+
(_a = this.el.querySelector('.esri-editor').querySelectorAll('calcite-flow-item')) === null || _a === void 0 ? void 0 : _a.forEach((flowItem) => {
|
208
|
+
var _a, _b, _c, _d, _e;
|
209
|
+
const article = (_c = (_b = (_a = flowItem.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('calcite-panel')) === null || _b === void 0 ? void 0 : _b.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('article');
|
210
|
+
//hide the header
|
211
|
+
(_d = article === null || article === void 0 ? void 0 : article.querySelector('header')) === null || _d === void 0 ? void 0 : _d.setAttribute('style', 'display: none');
|
212
|
+
//hide the footer
|
213
|
+
(_e = article === null || article === void 0 ? void 0 : article.querySelector('footer')) === null || _e === void 0 ? void 0 : _e.setAttribute('style', 'display: none');
|
214
|
+
});
|
215
|
+
}, 700);
|
216
|
+
}
|
169
217
|
/**
|
170
218
|
* On creation of feature emit the event that the feature is created
|
171
219
|
* @param evt feature submit event
|
@@ -173,9 +221,12 @@ const CreateFeature = /*@__PURE__*/ proxyCustomElement(class CreateFeature exten
|
|
173
221
|
*/
|
174
222
|
async submitted(evt) {
|
175
223
|
var _a;
|
224
|
+
//return if any attribute is invalid , focus will be shifted to the invalid attribute in feature form
|
176
225
|
if (evt.invalid.length) {
|
177
226
|
return;
|
178
227
|
}
|
228
|
+
//Submit only when valid attributes
|
229
|
+
//emit success or fail based on the result
|
179
230
|
if (evt.valid.length) {
|
180
231
|
try {
|
181
232
|
await this._editor.activeWorkflow.commit();
|
@@ -203,6 +254,7 @@ const CreateFeature = /*@__PURE__*/ proxyCustomElement(class CreateFeature exten
|
|
203
254
|
}, [0, "create-feature", {
|
204
255
|
"mapView": [16],
|
205
256
|
"selectedLayerId": [1, "selected-layer-id"],
|
257
|
+
"customizeSubmit": [4, "customize-submit"],
|
206
258
|
"close": [64],
|
207
259
|
"submit": [64]
|
208
260
|
}, undefined, {
|
@@ -110,6 +110,7 @@ const CrowdsourceReporter$1 = /*@__PURE__*/ proxyCustomElement(class Crowdsource
|
|
110
110
|
* @returns Promise when complete
|
111
111
|
*/
|
112
112
|
async componentWillLoad() {
|
113
|
+
this._urlParamsLoaded = false;
|
113
114
|
await this._initModules();
|
114
115
|
await this._getTranslations();
|
115
116
|
}
|
@@ -146,6 +147,11 @@ const CrowdsourceReporter$1 = /*@__PURE__*/ proxyCustomElement(class Crowdsource
|
|
146
147
|
setSelectedLayer(layerId, layerName) {
|
147
148
|
this._selectedLayerId = layerId;
|
148
149
|
this._selectedLayerName = layerName;
|
150
|
+
//show only current layer on map and hide other valid editable layers
|
151
|
+
//if layerId is empty then show all the layers on map
|
152
|
+
this._validLayers.forEach(layer => {
|
153
|
+
layer.set('visible', !layerId || (layer.id === layerId));
|
154
|
+
});
|
149
155
|
}
|
150
156
|
/**
|
151
157
|
* Get the reporter app functionality
|
@@ -202,15 +208,22 @@ const CrowdsourceReporter$1 = /*@__PURE__*/ proxyCustomElement(class Crowdsource
|
|
202
208
|
* @protected
|
203
209
|
*/
|
204
210
|
getFeatureCreateFlowItem() {
|
205
|
-
return (h("calcite-flow-item", { collapsed: this.isMobile && this._sidePanelCollapsed, heading: this._selectedLayerName, onCalciteFlowItemBack: this.backFromCreateFeaturePanel.bind(this) }, this.isMobile && this.getActionToExpandCollapsePanel(), this._showSubmitCancelButton && h("div", { class: "width-full", slot: "footer" }, h("calcite-button", { appearance: "secondary", class: "footer-top-button footer-button", onClick: this.onSubmitButtonClick.bind(this), width: "full" }, this._translations.submit), h("calcite-button", { appearance: "outline", class: "footer-button", onClick: this.backFromCreateFeaturePanel.bind(this), width: "full" }, this._translations.cancel)), h("calcite-panel", { "full-height": true, "full-width": true }, h("calcite-notice", { class: "notice-msg", icon: "lightbulb", kind: "success", open: true }, h("div", { slot: "message" }, this._translations.featureEditFormInfoMsg)), h("create-feature", { mapView: this.mapView, onDrawComplete: this.showSubmitCancelButton.bind(this), onFail: this.createFeatureFailed.bind(this), onSuccess: this.
|
211
|
+
return (h("calcite-flow-item", { collapsed: this.isMobile && this._sidePanelCollapsed, heading: this._selectedLayerName, onCalciteFlowItemBack: this.backFromCreateFeaturePanel.bind(this) }, this.isMobile && this.getActionToExpandCollapsePanel(), this._showSubmitCancelButton && h("div", { class: "width-full", slot: "footer" }, h("calcite-button", { appearance: "secondary", class: "footer-top-button footer-button", onClick: this.onSubmitButtonClick.bind(this), width: "full" }, this._translations.submit), h("calcite-button", { appearance: "outline", class: "footer-button", onClick: this.backFromCreateFeaturePanel.bind(this), width: "full" }, this._translations.cancel)), h("calcite-panel", { "full-height": true, "full-width": true }, h("calcite-notice", { class: "notice-msg", icon: "lightbulb", kind: "success", open: true }, h("div", { slot: "message" }, this._translations.featureEditFormInfoMsg)), h("create-feature", { customizeSubmit: true, mapView: this.mapView, onDrawComplete: this.onDrawComplete.bind(this), onEditingAttachment: this.showSubmitCancelButton.bind(this), onFail: this.createFeatureFailed.bind(this), onSuccess: this.onReportSubmitted.bind(this), ref: el => this._createFeature = el, selectedLayerId: this._selectedLayerId }))));
|
206
212
|
}
|
207
213
|
/**
|
208
214
|
* When drawing of incident location completed on map show the submit and cancel button
|
209
215
|
* @protected
|
210
216
|
*/
|
211
|
-
|
217
|
+
onDrawComplete() {
|
212
218
|
this._showSubmitCancelButton = true;
|
213
219
|
}
|
220
|
+
/**
|
221
|
+
* When Add attachment panel is enabled hide the submit and cancel button
|
222
|
+
* @protected
|
223
|
+
*/
|
224
|
+
showSubmitCancelButton(evt) {
|
225
|
+
this._showSubmitCancelButton = !evt.detail;
|
226
|
+
}
|
214
227
|
/**
|
215
228
|
* On back from create feature, call submit editor to destroy the Editor widget instance
|
216
229
|
* @protected
|
@@ -243,11 +256,22 @@ const CrowdsourceReporter$1 = /*@__PURE__*/ proxyCustomElement(class Crowdsource
|
|
243
256
|
* On submit report navigate to the layer list home page and refresh the layer list
|
244
257
|
* @protected
|
245
258
|
*/
|
246
|
-
|
259
|
+
onReportSubmitted() {
|
247
260
|
this._reportSubmitted = true;
|
261
|
+
this.navigateToHomePage();
|
262
|
+
}
|
263
|
+
/**
|
264
|
+
* Navigates to layer-list
|
265
|
+
* @protected
|
266
|
+
*/
|
267
|
+
navigateToHomePage() {
|
268
|
+
if (this._createFeature) {
|
269
|
+
this._createFeature.close();
|
270
|
+
}
|
248
271
|
if (this._layerList) {
|
249
272
|
this._layerList.refresh();
|
250
273
|
}
|
274
|
+
this.setSelectedFeatures([]);
|
251
275
|
this._flowItems = ["layer-list"];
|
252
276
|
}
|
253
277
|
/**
|
@@ -293,7 +317,10 @@ const CrowdsourceReporter$1 = /*@__PURE__*/ proxyCustomElement(class Crowdsource
|
|
293
317
|
//update the has valid layer state
|
294
318
|
this._hasValidLayers = layersListed.length > 0;
|
295
319
|
//navigate to the feature details if URL params found
|
296
|
-
|
320
|
+
if (!this._urlParamsLoaded) {
|
321
|
+
this._urlParamsLoaded = true;
|
322
|
+
await this.loadFeatureFromURLParams();
|
323
|
+
}
|
297
324
|
}
|
298
325
|
/**On click of layer list item show feature list
|
299
326
|
* @param evt Event which has details of selected layerId and layerName
|
@@ -310,10 +337,10 @@ const CrowdsourceReporter$1 = /*@__PURE__*/ proxyCustomElement(class Crowdsource
|
|
310
337
|
backFromSelectedPanel() {
|
311
338
|
const updatedFlowItems = [...this._flowItems];
|
312
339
|
updatedFlowItems.pop();
|
313
|
-
//
|
340
|
+
//Back to layer list, and return as the flowItems will be reset in navigateToHomePage
|
314
341
|
if (updatedFlowItems.length === 1) {
|
315
|
-
this.
|
316
|
-
|
342
|
+
this.navigateToHomePage();
|
343
|
+
return;
|
317
344
|
}
|
318
345
|
this._flowItems = [...updatedFlowItems];
|
319
346
|
}
|
@@ -462,7 +489,6 @@ const CrowdsourceReporter$1 = /*@__PURE__*/ proxyCustomElement(class Crowdsource
|
|
462
489
|
}
|
463
490
|
/**
|
464
491
|
* Updates the share url for current selected feature
|
465
|
-
* @returns
|
466
492
|
* @protected
|
467
493
|
*/
|
468
494
|
_updateShareURL() {
|
@@ -491,6 +517,7 @@ const CrowdsourceReporter$1 = /*@__PURE__*/ proxyCustomElement(class Crowdsource
|
|
491
517
|
}
|
492
518
|
/**
|
493
519
|
* Navigates to selected features detail based on the URL params
|
520
|
+
* @protected
|
494
521
|
*/
|
495
522
|
async loadFeatureFromURLParams() {
|
496
523
|
if (this.layerId && this.objectId) {
|
@@ -3082,7 +3082,7 @@ async function _prepareLabelsFromPattern(layer, featureSet, attributeOrigNames,
|
|
3082
3082
|
const match = arcadeExpressionMatches[i];
|
3083
3083
|
const expressionName = match.substring(match.indexOf("/") + 1, match.length - 1);
|
3084
3084
|
const value = await arcadeExecutors[expressionName].executeAsync({ "$feature": feature, "$layer": layer });
|
3085
|
-
labelPrep = labelPrep.replace(match, value);
|
3085
|
+
labelPrep = labelPrep.replace(match, value).replace(/\n/gi, "|");
|
3086
3086
|
}
|
3087
3087
|
// Replace non-Arcade fields in this feature
|
3088
3088
|
const attributeValues = (_a = feature.attributes) !== null && _a !== void 0 ? _a : feature;
|
@@ -12,7 +12,7 @@ import { c as connectLocalized, d as disconnectLocalized } from './locale-6107ef
|
|
12
12
|
import { c as connectMessages, s as setUpMessages, d as disconnectMessages, u as updateMessages } from './t9n-f16911e7.js';
|
13
13
|
import { S as SLOTS$1 } from './resources-649a0f91.js';
|
14
14
|
import { l as loadModules, g as getLocaleComponentStrings, f as formatNumber } from './locale-731e75a8.js';
|
15
|
-
import { g as getLayerOrTable, c as getFeatureLayerView, h as highlightFeatures, d as getMapLayerHash
|
15
|
+
import { a as getAllLayers, g as getLayerOrTable, c as getFeatureLayerView, h as highlightFeatures, d as getMapLayerHash } from './mapViewUtils-cf05e880.js';
|
16
16
|
import { P as PopupUtils } from './popupUtils-d75edf93.js';
|
17
17
|
import './guid-36c6c6a5.js';
|
18
18
|
import './resources-cdc36705.js';
|
@@ -335,7 +335,7 @@ const FlowItem = class {
|
|
335
335
|
};
|
336
336
|
FlowItem.style = flowItemCss;
|
337
337
|
|
338
|
-
const createFeatureCss = ":host{display:block}.esri-editor__panel-toolbar{display:none !important}";
|
338
|
+
const createFeatureCss = ":host{display:block}.esri-editor__panel-toolbar{display:none !important}.esri-editor__update-actions{display:none !important}.esri-editor__panel-content{padding-block:0px !important}.esri-editor .esri-item-list__group__header{display:none !important}.esri-editor__panel-content__section .esri-widget__heading{display:none !important}.esri-editor .esri-item-list__filter-container--sticky{padding-block:0px !important;padding-inline:10px !important}";
|
339
339
|
|
340
340
|
const CreateFeature = class {
|
341
341
|
constructor(hostRef) {
|
@@ -343,8 +343,10 @@ const CreateFeature = class {
|
|
343
343
|
this.success = createEvent(this, "success", 7);
|
344
344
|
this.fail = createEvent(this, "fail", 7);
|
345
345
|
this.drawComplete = createEvent(this, "drawComplete", 7);
|
346
|
+
this.editingAttachment = createEvent(this, "editingAttachment", 7);
|
346
347
|
this.mapView = undefined;
|
347
348
|
this.selectedLayerId = undefined;
|
349
|
+
this.customizeSubmit = false;
|
348
350
|
}
|
349
351
|
//--------------------------------------------------------------------------
|
350
352
|
//
|
@@ -415,18 +417,8 @@ const CreateFeature = class {
|
|
415
417
|
* Init Editor widget and starts the create workflow
|
416
418
|
*/
|
417
419
|
async init() {
|
418
|
-
if (this.mapView) {
|
419
|
-
|
420
|
-
await getLayerOrTable(this.mapView, this.selectedLayerId);
|
421
|
-
await this.createEditorWidget();
|
422
|
-
await this.startCreate();
|
423
|
-
this._editor.viewModel.featureFormViewModel.on('submit', this.submitted.bind(this));
|
424
|
-
setTimeout(() => {
|
425
|
-
var _a, _b;
|
426
|
-
this.el.querySelector('.esri-editor').querySelectorAll('calcite-flow-item')[1].shadowRoot.querySelector('calcite-panel').shadowRoot.querySelector('article').querySelector('header').setAttribute('style', 'display: none');
|
427
|
-
(_b = (_a = this.el.querySelector('.esri-editor').querySelectorAll('calcite-flow-item')[1].shadowRoot.querySelector('calcite-panel').shadowRoot.querySelector('article')) === null || _a === void 0 ? void 0 : _a.querySelector('footer')) === null || _b === void 0 ? void 0 : _b.setAttribute('style', 'display: none');
|
428
|
-
}, 700);
|
429
|
-
}
|
420
|
+
if (this.mapView && this.selectedLayerId) {
|
421
|
+
await this.createEditorWidget();
|
430
422
|
}
|
431
423
|
}
|
432
424
|
/**
|
@@ -435,10 +427,12 @@ const CreateFeature = class {
|
|
435
427
|
* @protected
|
436
428
|
*/
|
437
429
|
async initModules() {
|
438
|
-
const [Editor] = await loadModules([
|
439
|
-
"esri/widgets/Editor"
|
430
|
+
const [Editor, reactiveUtils] = await loadModules([
|
431
|
+
"esri/widgets/Editor",
|
432
|
+
"esri/core/reactiveUtils"
|
440
433
|
]);
|
441
434
|
this.Editor = Editor;
|
435
|
+
this.reactiveUtils = reactiveUtils;
|
442
436
|
}
|
443
437
|
/**
|
444
438
|
* Display editor widget to create the new feature
|
@@ -448,50 +442,104 @@ const CreateFeature = class {
|
|
448
442
|
if (this._editor) {
|
449
443
|
this._editor.destroy();
|
450
444
|
}
|
445
|
+
const layerInfos = [];
|
451
446
|
const container = document.createElement("div");
|
452
|
-
const
|
453
|
-
|
454
|
-
|
455
|
-
|
447
|
+
const allMapLayers = await getAllLayers(this.mapView);
|
448
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
449
|
+
allMapLayers.forEach(async (eachLayer) => {
|
450
|
+
layerInfos.push({
|
451
|
+
layer: eachLayer,
|
452
|
+
enabled: (eachLayer === null || eachLayer === void 0 ? void 0 : eachLayer.type) === "feature" && (eachLayer === null || eachLayer === void 0 ? void 0 : eachLayer.id) === this.selectedLayerId,
|
453
|
+
addEnabled: true,
|
454
|
+
updateEnabled: false,
|
455
|
+
deleteEnabled: false // default is true, set to false to disable the ability to delete features
|
456
|
+
});
|
457
|
+
});
|
456
458
|
this._editor = new this.Editor({
|
457
459
|
allowedWorkflows: "create-features",
|
458
460
|
view: this.mapView,
|
459
|
-
layerInfos:
|
461
|
+
layerInfos: layerInfos,
|
460
462
|
visibleElements: {
|
461
|
-
snappingControls: false
|
462
|
-
snappingControlsElements: {
|
463
|
-
featureEnabledToggle: false,
|
464
|
-
layerList: false,
|
465
|
-
enabledToggle: false
|
466
|
-
}
|
463
|
+
snappingControls: false
|
467
464
|
},
|
468
|
-
container
|
465
|
+
container
|
469
466
|
});
|
470
467
|
this.el.appendChild(container);
|
468
|
+
//Add handle to watch if attachments are added/edited
|
469
|
+
const attachmentHandle = this.reactiveUtils.watch(() => this._editor.viewModel.state, (state) => {
|
470
|
+
if (state === 'adding-attachment' || state === 'editing-attachment') {
|
471
|
+
this._addingAttachment = true;
|
472
|
+
this.editingAttachment.emit(true);
|
473
|
+
}
|
474
|
+
else {
|
475
|
+
if (this._addingAttachment) {
|
476
|
+
this.editingAttachment.emit(false);
|
477
|
+
this._addingAttachment = false;
|
478
|
+
}
|
479
|
+
}
|
480
|
+
});
|
481
|
+
this._editor.viewModel.addHandles(attachmentHandle);
|
482
|
+
//Add handle to watch featureTemplatesViewModel ready state and then start the creation
|
483
|
+
const handle = this.reactiveUtils.watch(() => this._editor.viewModel.featureTemplatesViewModel.state, (state) => {
|
484
|
+
if (state === 'ready') {
|
485
|
+
void this.startCreate();
|
486
|
+
}
|
487
|
+
});
|
488
|
+
this._editor.viewModel.addHandles(handle);
|
471
489
|
}
|
472
490
|
/**
|
473
491
|
* Start creating the feature
|
474
492
|
* @protected
|
475
493
|
*/
|
476
494
|
async startCreate() {
|
477
|
-
var _a
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
495
|
+
var _a;
|
496
|
+
if ((_a = this._editor.viewModel.featureTemplatesViewModel.items) === null || _a === void 0 ? void 0 : _a.length) {
|
497
|
+
const items = this._editor.viewModel.featureTemplatesViewModel.items[0].get("items");
|
498
|
+
//once the feature template is selected handle the event for formSubmit and sketch complete
|
499
|
+
//also, hide the headers and footer in the editor as we will be showing our own submit and cancel button
|
500
|
+
this._editor.viewModel.featureTemplatesViewModel.on('select', () => {
|
501
|
+
setTimeout(() => {
|
502
|
+
//on form submit
|
503
|
+
this._editor.viewModel.featureFormViewModel.on('submit', this.submitted.bind(this));
|
504
|
+
//on sketch complete emit the event
|
505
|
+
this._editor.viewModel.sketchViewModel.on("create", (evt) => {
|
506
|
+
if (evt.state === "complete") {
|
507
|
+
this.drawComplete.emit();
|
508
|
+
}
|
509
|
+
});
|
510
|
+
this.hideEditorsElements();
|
511
|
+
}, 700);
|
512
|
+
this.hideEditorsElements();
|
493
513
|
});
|
514
|
+
//if only one feature template then directly start geometry creation for that
|
515
|
+
//else allow feature template selection to user
|
516
|
+
if (items.length === 1) {
|
517
|
+
this._editor.viewModel.featureTemplatesViewModel.select(items[0]);
|
518
|
+
}
|
519
|
+
//hides the header and footer elements in editor widget
|
520
|
+
this.hideEditorsElements();
|
521
|
+
}
|
522
|
+
}
|
523
|
+
/**
|
524
|
+
* Hides the elements of editor widget
|
525
|
+
* @protected
|
526
|
+
*/
|
527
|
+
hideEditorsElements() {
|
528
|
+
if (!this.customizeSubmit) {
|
529
|
+
return;
|
494
530
|
}
|
531
|
+
setTimeout(() => {
|
532
|
+
var _a;
|
533
|
+
//hides the header and footer on the featureForm
|
534
|
+
(_a = this.el.querySelector('.esri-editor').querySelectorAll('calcite-flow-item')) === null || _a === void 0 ? void 0 : _a.forEach((flowItem) => {
|
535
|
+
var _a, _b, _c, _d, _e;
|
536
|
+
const article = (_c = (_b = (_a = flowItem.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('calcite-panel')) === null || _b === void 0 ? void 0 : _b.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('article');
|
537
|
+
//hide the header
|
538
|
+
(_d = article === null || article === void 0 ? void 0 : article.querySelector('header')) === null || _d === void 0 ? void 0 : _d.setAttribute('style', 'display: none');
|
539
|
+
//hide the footer
|
540
|
+
(_e = article === null || article === void 0 ? void 0 : article.querySelector('footer')) === null || _e === void 0 ? void 0 : _e.setAttribute('style', 'display: none');
|
541
|
+
});
|
542
|
+
}, 700);
|
495
543
|
}
|
496
544
|
/**
|
497
545
|
* On creation of feature emit the event that the feature is created
|
@@ -500,9 +548,12 @@ const CreateFeature = class {
|
|
500
548
|
*/
|
501
549
|
async submitted(evt) {
|
502
550
|
var _a;
|
551
|
+
//return if any attribute is invalid , focus will be shifted to the invalid attribute in feature form
|
503
552
|
if (evt.invalid.length) {
|
504
553
|
return;
|
505
554
|
}
|
555
|
+
//Submit only when valid attributes
|
556
|
+
//emit success or fail based on the result
|
506
557
|
if (evt.valid.length) {
|
507
558
|
try {
|
508
559
|
await this._editor.activeWorkflow.commit();
|
@@ -6,7 +6,7 @@
|
|
6
6
|
import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-7183ce4a.js';
|
7
7
|
import { g as getLocaleComponentStrings, l as loadModules } from './locale-731e75a8.js';
|
8
8
|
import { q as queryFeaturesByID, g as getLayerOrTable, b as goToSelection, e as queryAllIds, f as queryFeatureIds, i as queryFeaturesByGlobalID } from './mapViewUtils-cf05e880.js';
|
9
|
-
import { d as downloadCSV } from './downloadUtils-
|
9
|
+
import { d as downloadCSV } from './downloadUtils-4577cf8b.js';
|
10
10
|
import './esri-loader-eda07632.js';
|
11
11
|
import './_commonjsHelpers-d5f9d613.js';
|
12
12
|
import './interfaces-586e863c.js';
|