@esri/solutions-components 0.7.31 → 0.7.32
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.
- package/dist/cjs/calcite-flow_5.cjs.entry.js +94 -43
- package/dist/cjs/crowdsource-reporter.cjs.entry.js +35 -8
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/solutions-components.cjs.js +1 -1
- 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/demos/create-feature.html +90 -0
- package/dist/components/create-feature2.js +96 -44
- package/dist/components/crowdsource-reporter.js +35 -8
- package/dist/esm/calcite-flow_5.entry.js +95 -44
- package/dist/esm/crowdsource-reporter.entry.js +35 -8
- package/dist/esm/loader.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-d5263cb9.entry.js +17 -0
- package/dist/solutions-components/p-ea17cefb.entry.js +6 -0
- package/dist/solutions-components/solutions-components.esm.js +1 -1
- 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
|
@@ -339,7 +339,7 @@ const FlowItem = class {
|
|
|
339
339
|
};
|
|
340
340
|
FlowItem.style = flowItemCss;
|
|
341
341
|
|
|
342
|
-
const createFeatureCss = ":host{display:block}.esri-editor__panel-toolbar{display:none !important}";
|
|
342
|
+
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}";
|
|
343
343
|
|
|
344
344
|
const CreateFeature = class {
|
|
345
345
|
constructor(hostRef) {
|
|
@@ -347,8 +347,10 @@ const CreateFeature = class {
|
|
|
347
347
|
this.success = index.createEvent(this, "success", 7);
|
|
348
348
|
this.fail = index.createEvent(this, "fail", 7);
|
|
349
349
|
this.drawComplete = index.createEvent(this, "drawComplete", 7);
|
|
350
|
+
this.editingAttachment = index.createEvent(this, "editingAttachment", 7);
|
|
350
351
|
this.mapView = undefined;
|
|
351
352
|
this.selectedLayerId = undefined;
|
|
353
|
+
this.customizeSubmit = false;
|
|
352
354
|
}
|
|
353
355
|
//--------------------------------------------------------------------------
|
|
354
356
|
//
|
|
@@ -419,18 +421,8 @@ const CreateFeature = class {
|
|
|
419
421
|
* Init Editor widget and starts the create workflow
|
|
420
422
|
*/
|
|
421
423
|
async init() {
|
|
422
|
-
if (this.mapView) {
|
|
423
|
-
|
|
424
|
-
await mapViewUtils.getLayerOrTable(this.mapView, this.selectedLayerId);
|
|
425
|
-
await this.createEditorWidget();
|
|
426
|
-
await this.startCreate();
|
|
427
|
-
this._editor.viewModel.featureFormViewModel.on('submit', this.submitted.bind(this));
|
|
428
|
-
setTimeout(() => {
|
|
429
|
-
var _a, _b;
|
|
430
|
-
this.el.querySelector('.esri-editor').querySelectorAll('calcite-flow-item')[1].shadowRoot.querySelector('calcite-panel').shadowRoot.querySelector('article').querySelector('header').setAttribute('style', 'display: none');
|
|
431
|
-
(_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');
|
|
432
|
-
}, 700);
|
|
433
|
-
}
|
|
424
|
+
if (this.mapView && this.selectedLayerId) {
|
|
425
|
+
await this.createEditorWidget();
|
|
434
426
|
}
|
|
435
427
|
}
|
|
436
428
|
/**
|
|
@@ -439,10 +431,12 @@ const CreateFeature = class {
|
|
|
439
431
|
* @protected
|
|
440
432
|
*/
|
|
441
433
|
async initModules() {
|
|
442
|
-
const [Editor] = await locale$1.loadModules([
|
|
443
|
-
"esri/widgets/Editor"
|
|
434
|
+
const [Editor, reactiveUtils] = await locale$1.loadModules([
|
|
435
|
+
"esri/widgets/Editor",
|
|
436
|
+
"esri/core/reactiveUtils"
|
|
444
437
|
]);
|
|
445
438
|
this.Editor = Editor;
|
|
439
|
+
this.reactiveUtils = reactiveUtils;
|
|
446
440
|
}
|
|
447
441
|
/**
|
|
448
442
|
* Display editor widget to create the new feature
|
|
@@ -452,50 +446,104 @@ const CreateFeature = class {
|
|
|
452
446
|
if (this._editor) {
|
|
453
447
|
this._editor.destroy();
|
|
454
448
|
}
|
|
449
|
+
const layerInfos = [];
|
|
455
450
|
const container = document.createElement("div");
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
451
|
+
const allMapLayers = await mapViewUtils.getAllLayers(this.mapView);
|
|
452
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
453
|
+
allMapLayers.forEach(async (eachLayer) => {
|
|
454
|
+
layerInfos.push({
|
|
455
|
+
layer: eachLayer,
|
|
456
|
+
enabled: (eachLayer === null || eachLayer === void 0 ? void 0 : eachLayer.type) === "feature" && (eachLayer === null || eachLayer === void 0 ? void 0 : eachLayer.id) === this.selectedLayerId,
|
|
457
|
+
addEnabled: true,
|
|
458
|
+
updateEnabled: false,
|
|
459
|
+
deleteEnabled: false // default is true, set to false to disable the ability to delete features
|
|
460
|
+
});
|
|
461
|
+
});
|
|
460
462
|
this._editor = new this.Editor({
|
|
461
463
|
allowedWorkflows: "create-features",
|
|
462
464
|
view: this.mapView,
|
|
463
|
-
layerInfos:
|
|
465
|
+
layerInfos: layerInfos,
|
|
464
466
|
visibleElements: {
|
|
465
|
-
snappingControls: false
|
|
466
|
-
snappingControlsElements: {
|
|
467
|
-
featureEnabledToggle: false,
|
|
468
|
-
layerList: false,
|
|
469
|
-
enabledToggle: false
|
|
470
|
-
}
|
|
467
|
+
snappingControls: false
|
|
471
468
|
},
|
|
472
|
-
container
|
|
469
|
+
container
|
|
473
470
|
});
|
|
474
471
|
this.el.appendChild(container);
|
|
472
|
+
//Add handle to watch if attachments are added/edited
|
|
473
|
+
const attachmentHandle = this.reactiveUtils.watch(() => this._editor.viewModel.state, (state) => {
|
|
474
|
+
if (state === 'adding-attachment' || state === 'editing-attachment') {
|
|
475
|
+
this._addingAttachment = true;
|
|
476
|
+
this.editingAttachment.emit(true);
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
if (this._addingAttachment) {
|
|
480
|
+
this.editingAttachment.emit(false);
|
|
481
|
+
this._addingAttachment = false;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
this._editor.viewModel.addHandles(attachmentHandle);
|
|
486
|
+
//Add handle to watch featureTemplatesViewModel ready state and then start the creation
|
|
487
|
+
const handle = this.reactiveUtils.watch(() => this._editor.viewModel.featureTemplatesViewModel.state, (state) => {
|
|
488
|
+
if (state === 'ready') {
|
|
489
|
+
void this.startCreate();
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
this._editor.viewModel.addHandles(handle);
|
|
475
493
|
}
|
|
476
494
|
/**
|
|
477
495
|
* Start creating the feature
|
|
478
496
|
* @protected
|
|
479
497
|
*/
|
|
480
498
|
async startCreate() {
|
|
481
|
-
var _a
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
499
|
+
var _a;
|
|
500
|
+
if ((_a = this._editor.viewModel.featureTemplatesViewModel.items) === null || _a === void 0 ? void 0 : _a.length) {
|
|
501
|
+
const items = this._editor.viewModel.featureTemplatesViewModel.items[0].get("items");
|
|
502
|
+
//once the feature template is selected handle the event for formSubmit and sketch complete
|
|
503
|
+
//also, hide the headers and footer in the editor as we will be showing our own submit and cancel button
|
|
504
|
+
this._editor.viewModel.featureTemplatesViewModel.on('select', () => {
|
|
505
|
+
setTimeout(() => {
|
|
506
|
+
//on form submit
|
|
507
|
+
this._editor.viewModel.featureFormViewModel.on('submit', this.submitted.bind(this));
|
|
508
|
+
//on sketch complete emit the event
|
|
509
|
+
this._editor.viewModel.sketchViewModel.on("create", (evt) => {
|
|
510
|
+
if (evt.state === "complete") {
|
|
511
|
+
this.drawComplete.emit();
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
this.hideEditorsElements();
|
|
515
|
+
}, 700);
|
|
516
|
+
this.hideEditorsElements();
|
|
497
517
|
});
|
|
518
|
+
//if only one feature template then directly start geometry creation for that
|
|
519
|
+
//else allow feature template selection to user
|
|
520
|
+
if (items.length === 1) {
|
|
521
|
+
this._editor.viewModel.featureTemplatesViewModel.select(items[0]);
|
|
522
|
+
}
|
|
523
|
+
//hides the header and footer elements in editor widget
|
|
524
|
+
this.hideEditorsElements();
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Hides the elements of editor widget
|
|
529
|
+
* @protected
|
|
530
|
+
*/
|
|
531
|
+
hideEditorsElements() {
|
|
532
|
+
if (!this.customizeSubmit) {
|
|
533
|
+
return;
|
|
498
534
|
}
|
|
535
|
+
setTimeout(() => {
|
|
536
|
+
var _a;
|
|
537
|
+
//hides the header and footer on the featureForm
|
|
538
|
+
(_a = this.el.querySelector('.esri-editor').querySelectorAll('calcite-flow-item')) === null || _a === void 0 ? void 0 : _a.forEach((flowItem) => {
|
|
539
|
+
var _a, _b, _c, _d, _e;
|
|
540
|
+
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');
|
|
541
|
+
//hide the header
|
|
542
|
+
(_d = article === null || article === void 0 ? void 0 : article.querySelector('header')) === null || _d === void 0 ? void 0 : _d.setAttribute('style', 'display: none');
|
|
543
|
+
//hide the footer
|
|
544
|
+
(_e = article === null || article === void 0 ? void 0 : article.querySelector('footer')) === null || _e === void 0 ? void 0 : _e.setAttribute('style', 'display: none');
|
|
545
|
+
});
|
|
546
|
+
}, 700);
|
|
499
547
|
}
|
|
500
548
|
/**
|
|
501
549
|
* On creation of feature emit the event that the feature is created
|
|
@@ -504,9 +552,12 @@ const CreateFeature = class {
|
|
|
504
552
|
*/
|
|
505
553
|
async submitted(evt) {
|
|
506
554
|
var _a;
|
|
555
|
+
//return if any attribute is invalid , focus will be shifted to the invalid attribute in feature form
|
|
507
556
|
if (evt.invalid.length) {
|
|
508
557
|
return;
|
|
509
558
|
}
|
|
559
|
+
//Submit only when valid attributes
|
|
560
|
+
//emit success or fail based on the result
|
|
510
561
|
if (evt.valid.length) {
|
|
511
562
|
try {
|
|
512
563
|
await this._editor.activeWorkflow.commit();
|
|
@@ -83,6 +83,7 @@ const CrowdsourceReporter = class {
|
|
|
83
83
|
* @returns Promise when complete
|
|
84
84
|
*/
|
|
85
85
|
async componentWillLoad() {
|
|
86
|
+
this._urlParamsLoaded = false;
|
|
86
87
|
await this._initModules();
|
|
87
88
|
await this._getTranslations();
|
|
88
89
|
}
|
|
@@ -119,6 +120,11 @@ const CrowdsourceReporter = class {
|
|
|
119
120
|
setSelectedLayer(layerId, layerName) {
|
|
120
121
|
this._selectedLayerId = layerId;
|
|
121
122
|
this._selectedLayerName = layerName;
|
|
123
|
+
//show only current layer on map and hide other valid editable layers
|
|
124
|
+
//if layerId is empty then show all the layers on map
|
|
125
|
+
this._validLayers.forEach(layer => {
|
|
126
|
+
layer.set('visible', !layerId || (layer.id === layerId));
|
|
127
|
+
});
|
|
122
128
|
}
|
|
123
129
|
/**
|
|
124
130
|
* Get the reporter app functionality
|
|
@@ -175,15 +181,22 @@ const CrowdsourceReporter = class {
|
|
|
175
181
|
* @protected
|
|
176
182
|
*/
|
|
177
183
|
getFeatureCreateFlowItem() {
|
|
178
|
-
return (index.h("calcite-flow-item", { collapsed: this.isMobile && this._sidePanelCollapsed, heading: this._selectedLayerName, onCalciteFlowItemBack: this.backFromCreateFeaturePanel.bind(this) }, this.isMobile && this.getActionToExpandCollapsePanel(), this._showSubmitCancelButton && index.h("div", { class: "width-full", slot: "footer" }, index.h("calcite-button", { appearance: "secondary", class: "footer-top-button footer-button", onClick: this.onSubmitButtonClick.bind(this), width: "full" }, this._translations.submit), index.h("calcite-button", { appearance: "outline", class: "footer-button", onClick: this.backFromCreateFeaturePanel.bind(this), width: "full" }, this._translations.cancel)), index.h("calcite-panel", { "full-height": true, "full-width": true }, index.h("calcite-notice", { class: "notice-msg", icon: "lightbulb", kind: "success", open: true }, index.h("div", { slot: "message" }, this._translations.featureEditFormInfoMsg)), index.h("create-feature", { mapView: this.mapView, onDrawComplete: this.showSubmitCancelButton.bind(this), onFail: this.createFeatureFailed.bind(this), onSuccess: this.
|
|
184
|
+
return (index.h("calcite-flow-item", { collapsed: this.isMobile && this._sidePanelCollapsed, heading: this._selectedLayerName, onCalciteFlowItemBack: this.backFromCreateFeaturePanel.bind(this) }, this.isMobile && this.getActionToExpandCollapsePanel(), this._showSubmitCancelButton && index.h("div", { class: "width-full", slot: "footer" }, index.h("calcite-button", { appearance: "secondary", class: "footer-top-button footer-button", onClick: this.onSubmitButtonClick.bind(this), width: "full" }, this._translations.submit), index.h("calcite-button", { appearance: "outline", class: "footer-button", onClick: this.backFromCreateFeaturePanel.bind(this), width: "full" }, this._translations.cancel)), index.h("calcite-panel", { "full-height": true, "full-width": true }, index.h("calcite-notice", { class: "notice-msg", icon: "lightbulb", kind: "success", open: true }, index.h("div", { slot: "message" }, this._translations.featureEditFormInfoMsg)), index.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 }))));
|
|
179
185
|
}
|
|
180
186
|
/**
|
|
181
187
|
* When drawing of incident location completed on map show the submit and cancel button
|
|
182
188
|
* @protected
|
|
183
189
|
*/
|
|
184
|
-
|
|
190
|
+
onDrawComplete() {
|
|
185
191
|
this._showSubmitCancelButton = true;
|
|
186
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* When Add attachment panel is enabled hide the submit and cancel button
|
|
195
|
+
* @protected
|
|
196
|
+
*/
|
|
197
|
+
showSubmitCancelButton(evt) {
|
|
198
|
+
this._showSubmitCancelButton = !evt.detail;
|
|
199
|
+
}
|
|
187
200
|
/**
|
|
188
201
|
* On back from create feature, call submit editor to destroy the Editor widget instance
|
|
189
202
|
* @protected
|
|
@@ -216,11 +229,22 @@ const CrowdsourceReporter = class {
|
|
|
216
229
|
* On submit report navigate to the layer list home page and refresh the layer list
|
|
217
230
|
* @protected
|
|
218
231
|
*/
|
|
219
|
-
|
|
232
|
+
onReportSubmitted() {
|
|
220
233
|
this._reportSubmitted = true;
|
|
234
|
+
this.navigateToHomePage();
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Navigates to layer-list
|
|
238
|
+
* @protected
|
|
239
|
+
*/
|
|
240
|
+
navigateToHomePage() {
|
|
241
|
+
if (this._createFeature) {
|
|
242
|
+
this._createFeature.close();
|
|
243
|
+
}
|
|
221
244
|
if (this._layerList) {
|
|
222
245
|
this._layerList.refresh();
|
|
223
246
|
}
|
|
247
|
+
this.setSelectedFeatures([]);
|
|
224
248
|
this._flowItems = ["layer-list"];
|
|
225
249
|
}
|
|
226
250
|
/**
|
|
@@ -266,7 +290,10 @@ const CrowdsourceReporter = class {
|
|
|
266
290
|
//update the has valid layer state
|
|
267
291
|
this._hasValidLayers = layersListed.length > 0;
|
|
268
292
|
//navigate to the feature details if URL params found
|
|
269
|
-
|
|
293
|
+
if (!this._urlParamsLoaded) {
|
|
294
|
+
this._urlParamsLoaded = true;
|
|
295
|
+
await this.loadFeatureFromURLParams();
|
|
296
|
+
}
|
|
270
297
|
}
|
|
271
298
|
/**On click of layer list item show feature list
|
|
272
299
|
* @param evt Event which has details of selected layerId and layerName
|
|
@@ -283,10 +310,10 @@ const CrowdsourceReporter = class {
|
|
|
283
310
|
backFromSelectedPanel() {
|
|
284
311
|
const updatedFlowItems = [...this._flowItems];
|
|
285
312
|
updatedFlowItems.pop();
|
|
286
|
-
//
|
|
313
|
+
//Back to layer list, and return as the flowItems will be reset in navigateToHomePage
|
|
287
314
|
if (updatedFlowItems.length === 1) {
|
|
288
|
-
this.
|
|
289
|
-
|
|
315
|
+
this.navigateToHomePage();
|
|
316
|
+
return;
|
|
290
317
|
}
|
|
291
318
|
this._flowItems = [...updatedFlowItems];
|
|
292
319
|
}
|
|
@@ -435,7 +462,6 @@ const CrowdsourceReporter = class {
|
|
|
435
462
|
}
|
|
436
463
|
/**
|
|
437
464
|
* Updates the share url for current selected feature
|
|
438
|
-
* @returns
|
|
439
465
|
* @protected
|
|
440
466
|
*/
|
|
441
467
|
_updateShareURL() {
|
|
@@ -464,6 +490,7 @@ const CrowdsourceReporter = class {
|
|
|
464
490
|
}
|
|
465
491
|
/**
|
|
466
492
|
* Navigates to selected features detail based on the URL params
|
|
493
|
+
* @protected
|
|
467
494
|
*/
|
|
468
495
|
async loadFeatureFromURLParams() {
|
|
469
496
|
if (this.layerId && this.objectId) {
|