@geogirafe/lib-geoportal 1.3.0-dev.3053452205 → 1.3.0-dev.3060317043

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/LICENSE +1 -0
  2. package/assets/i18n/de.json +33 -3
  3. package/assets/i18n/en.json +32 -2
  4. package/assets/i18n/fr.json +34 -4
  5. package/assets/i18n/it.json +36 -6
  6. package/assets/icons/edit.svg +1 -1
  7. package/assets/icons/lock.svg +1 -0
  8. package/components/cross-section/cross-section-settings/component.js +1 -1
  9. package/components/edit/component.d.ts +52 -36
  10. package/components/edit/component.js +340 -292
  11. package/components/edit/editcomponentstate.d.ts +1 -0
  12. package/components/edit/editcomponentstate.js +1 -0
  13. package/components/edit/editform/component.d.ts +34 -4
  14. package/components/edit/editform/component.js +224 -37
  15. package/components/edit/editform/style.css +51 -16
  16. package/components/edit/geometryedithelper.d.ts +47 -0
  17. package/components/edit/geometryedithelper.js +324 -0
  18. package/components/edit/style.css +71 -28
  19. package/components/main.d.ts +1 -1
  20. package/components/main.js +1 -1
  21. package/components/print/component.d.ts +1 -1
  22. package/components/treeview/tools/treeviewelement.d.ts +1 -0
  23. package/components/treeview/tools/treeviewelement.js +22 -0
  24. package/components/treeview/treeviewitem/component.js +7 -1
  25. package/models/gmf.d.ts +18 -2
  26. package/models/gmf.js +3 -1
  27. package/models/layers/editablelayer.d.ts +7 -0
  28. package/models/layers/editablelayer.js +7 -0
  29. package/models/layers/layerwms.d.ts +1 -2
  30. package/models/layers/layerwms.js +4 -8
  31. package/models/main.d.ts +9 -4
  32. package/models/main.js +6 -2
  33. package/models/oapiflayer.d.ts +25 -0
  34. package/models/oapiflayer.js +36 -0
  35. package/models/oapiftypes.d.ts +71 -0
  36. package/models/oapiftypes.js +29 -0
  37. package/models/serverogc.d.ts +5 -3
  38. package/models/serverogc.js +19 -6
  39. package/models/serverogcapi.d.ts +2 -0
  40. package/models/serverogcapi.js +2 -0
  41. package/models/serverogcapifeatures.d.ts +5 -62
  42. package/models/serverogcapifeatures.js +8 -4
  43. package/package.json +1 -1
  44. package/templates/index.html +1 -0
  45. package/templates/public/about.json +1 -1
  46. package/tools/app/geogirafeapp.js +2 -2
  47. package/tools/drawing/olDrawing.js +2 -22
  48. package/tools/drawing/shapeConstraints.d.ts +2 -1
  49. package/tools/drawing/shapeConstraints.js +18 -2
  50. package/tools/main.d.ts +7 -5
  51. package/tools/main.js +7 -5
  52. package/tools/ogcapi/ogcapiclient.d.ts +7 -3
  53. package/tools/ogcapi/ogcapiclient.js +49 -4
  54. package/tools/ogcapi/ogcapiconformance.d.ts +2 -2
  55. package/tools/ogcapi/ogcapiconformance.js +7 -13
  56. package/tools/ogcapi/ogcapifeaturesclient.d.ts +65 -30
  57. package/tools/ogcapi/ogcapifeaturesclient.js +265 -139
  58. package/tools/ogcapi/ogcapifeaturesclientgeorama.d.ts +0 -5
  59. package/tools/ogcapi/ogcapifeaturesclientgeorama.js +0 -11
  60. package/tools/ogcapi/ogcapifeaturesclientqgis.d.ts +8 -0
  61. package/tools/ogcapi/ogcapifeaturesclientqgis.js +13 -0
  62. package/tools/ogcapi/ogcapifeaturesmanager.d.ts +61 -8
  63. package/tools/ogcapi/ogcapifeaturesmanager.js +179 -30
  64. package/tools/ogcapi/ogcapifeaturesschema.d.ts +31 -13
  65. package/tools/ogcapi/ogcapifeaturesschema.js +69 -39
  66. package/tools/ogcapi/ogcapifeaturesschemaproperty.d.ts +44 -0
  67. package/tools/ogcapi/ogcapifeaturesschemaproperty.js +137 -0
  68. package/tools/ogcapi/ogcapifeaturesschemavalidator.d.ts +22 -0
  69. package/tools/ogcapi/ogcapifeaturesschemavalidator.js +121 -0
  70. package/tools/state/state.d.ts +6 -0
  71. package/tools/state/state.js +4 -0
  72. package/tools/themes/themesmanager.d.ts +10 -3
  73. package/tools/themes/themesmanager.js +29 -9
  74. package/tools/time/layertimeformatter.d.ts +0 -5
  75. package/tools/time/layertimeformatter.js +10 -19
  76. package/tools/utils/dateutils.d.ts +40 -0
  77. package/tools/utils/dateutils.js +111 -0
  78. package/tools/utils/utils.d.ts +4 -0
  79. package/tools/utils/utils.js +12 -0
  80. package/tools/wfs/wfsmanager.js +3 -0
  81. package/tools/wms/wmsclient.d.ts +1 -0
  82. package/tools/wms/wmsclient.js +4 -0
  83. package/tools/ogcapi/demolayers.d.ts +0 -1
  84. package/tools/ogcapi/demolayers.js +0 -99
  85. package/tools/ogcapi/ogcapifeaturesclientgmf.d.ts +0 -13
  86. package/tools/ogcapi/ogcapifeaturesclientgmf.js +0 -30
@@ -1,28 +1,20 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
1
7
  import { htmlFor as uHtmlFor } from 'uhtml/keyed';
2
8
  import { html as uHtml } from 'uhtml';
3
9
  // SPDX-License-Identifier: Apache-2.0
4
10
  import GirafeHTMLElement from '../../base/GirafeHTMLElement.js';
5
- import { Draw, Modify, Select } from 'ol/interaction.js';
6
11
  import Feature from 'ol/Feature.js';
7
- import VectorSource from 'ol/source/Vector.js';
8
- import VectorLayer from 'ol/layer/Vector.js';
9
- import { Circle, Fill, Stroke, Style } from 'ol/style.js';
10
- import { bbox } from 'ol/loadingstrategy.js';
11
- import { DEMO_LAYERS } from '../../tools/ogcapi/demolayers.js';
12
- import { getSelectionBoxFromMapClick } from '../../tools/utils/olutils.js';
13
- const getStyle = (col = 'rgb(255,89,0)', width = 4) => {
14
- return new Style({
15
- stroke: new Stroke({ color: col, width: width }),
16
- fill: new Fill({ color: col }),
17
- image: new Circle({
18
- radius: width,
19
- fill: new Fill({ color: col })
20
- })
21
- });
22
- };
23
- const baseStyle = getStyle();
24
- const editStyle = getStyle('rgb(0,81,255)', 6);
25
- const newId = '-';
12
+ import { EditingFormChange } from './editform/component.js';
13
+ import { UsedInTemplateOnly } from '../../decorators.js';
14
+ import GeometryEditHelper from './geometryedithelper.js';
15
+ import LayerWms from '../../models/layers/layerwms.js';
16
+ import { get as getProjection } from 'ol/proj.js';
17
+ import { isEditableLayer } from '../../models/layers/editablelayer.js';
26
18
  export default class EditComponent extends GirafeHTMLElement {
27
19
  templateUrl = null;
28
20
  styleUrls = null;
@@ -30,30 +22,26 @@ export default class EditComponent extends GirafeHTMLElement {
30
22
  return uHtml `<style>
31
23
  .hidden{display:none!important}.gg-rotate90{transform:rotate(90deg)}.gg-rotate180{transform:rotate(180deg)}.gg-rotate270{transform:rotate(270deg)}img{filter:var(--svg-filter)}img.legend-image{filter:var(--svg-map-filter);background:var(--svg-legend-bkg)}div{scrollbar-width:thin}a,a:visited{color:var(--link-color)}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes spin-wait{0%{transform:rotate(0)}7%{transform:rotate(360deg)}to{transform:rotate(360deg)}}.gg-spin{animation-name:spin;animation-duration:2s;animation-timing-function:linear;animation-iteration-count:infinite}.gg-spin-wait{animation-name:spin-wait;animation-duration:10s;animation-timing-function:linear;animation-iteration-count:infinite}::-webkit-scrollbar{width:5px}::-webkit-scrollbar-thumb{background:#999}button,input,select,textarea{font:inherit}.gg-button,.gg-select,.gg-input,.gg-textarea{background-color:var(--bkg-color);color:var(--text-color);border:var(--app-standard-border);box-sizing:border-box;cursor:pointer;border-radius:3px;outline:0;margin:0;padding:0 0 0 .5rem;display:inline-block}.gg-label{background-color:var(--bkg-color);color:var(--text-color);border:none;align-items:center;margin:0;padding:0;display:flex}.gg-button,.gg-select,.gg-input,.gg-label{min-height:calc(var(--app-standard-height) / 1.5)}.gg-textarea{max-height:initial;resize:vertical;height:6rem;padding:.5rem;line-height:1.3rem}.gg-input{cursor:text}.gg-checkbox{accent-color:var(--text-color);cursor:pointer;width:1.2rem}.gg-range{accent-color:var(--text-color)}.gg-button{padding:0 .5rem}.gg-button.active{border:solid 1px var(--text-color-grad1);background-color:var(--bkg-color-grad2)}.gg-button:disabled{background-color:var(--bkg-color-grad1);color:var(--text-color-grad2);cursor:not-allowed;border:none}.gg-button:disabled img{filter:opacity(.6)}.gg-input:disabled,.gg-select:disabled,.gg-textarea:disabled{background-color:var(--bkg-color-grad1);color:var(--text-color-grad2);cursor:not-allowed}.gg-button>img{vertical-align:middle}.gg-icon-button{color:var(--text-color);cursor:pointer;background-color:#0000;border:none;flex-direction:column;justify-content:center;align-items:center;padding:0;display:flex}.gg-icon{justify-content:center;align-items:center;display:flex}.gg-big,.gg-big-withtext{min-width:var(--app-standard-height);min-height:var(--app-standard-height);max-height:var(--app-standard-height)}.gg-big img,.gg-big-withtext img{width:calc(var(--app-standard-height) - 1.5rem);margin:0}.gg-big-withtext span{font-variant:small-caps;padding:0 1rem;font-size:.9rem}.gg-medium,.gg-medium-withtext{min-width:calc(var(--app-standard-height) / 1.2);min-height:calc(var(--app-standard-height) / 1.2);max-height:calc(var(--app-standard-height) / 1.2);flex-direction:row}.gg-medium img{width:calc(var(--app-standard-height) / 2.4);margin:0}.gg-medium-withtext img{width:calc(var(--app-standard-height) / 2.4);margin-left:.5rem}.gg-medium-withtext span{padding:0 1rem 0 .5rem;font-size:.9rem}.gg-small,.gg-small-withtext{min-width:calc(var(--app-standard-height) / 2);min-height:calc(var(--app-standard-height) / 2);max-height:calc(var(--app-standard-height) / 2);flex-direction:row}.gg-small img{width:calc(var(--app-standard-height) / 3);margin:0}.gg-small-withtext img{width:calc(var(--app-standard-height) / 3);margin-left:.5rem}.gg-small-withtext span{padding:0 .5rem 0 .3rem;font-size:.9rem}.gg-button:hover:not(:disabled),.gg-select:hover:not(:disabled),.gg-input:hover:not(:disabled),.gg-textarea:hover:not(:disabled),.gg-icon-button:hover:not(:disabled){background-color:var(--bkg-color-grad1)}.gg-opacity{opacity:.5}.gg-opacity:hover{opacity:1;background-color:#0000}.gg-tabs{cursor:pointer;grid-auto-flow:column;padding-bottom:1rem;font-size:1rem;display:grid}.gg-tab{border:none;border-bottom:var(--app-standard-border);cursor:pointer;color:var(--text-color);background:0 0;padding:.5rem}.gg-tab.active{border-bottom:solid 1px var(--text-color)}.girafe-button-big,.girafe-button-large,.girafe-button-small,.girafe-button-tiny{color:var(--text-color);background-color:#0000;border:none;flex-direction:column;display:flex}.girafe-button-big:hover,.girafe-button-large:hover,.girafe-button-small:hover,.girafe-button-tiny:hover{background-color:var(--bkg-color-grad1);cursor:pointer}.girafe-button-big.dark,.girafe-button-large.dark,.girafe-button-small.dark,.girafe-button-tiny.dark{background-color:var(--bkg-color);filter:invert()}.girafe-button-big{width:var(--app-standard-height);height:var(--app-standard-height);align-items:center;padding:1rem}.girafe-button-big img{overflow:hidden}.girafe-button-large{flex-direction:row}.girafe-button-large img{height:2rem;margin:.3rem}.girafe-button-large span{height:2rem;margin:.3rem;line-height:2rem}.girafe-button-small{min-width:calc(var(--app-standard-height) / 2);height:calc(var(--app-standard-height) / 2);align-items:center;padding:.5rem}.girafe-button-small img{overflow:hidden}.girafe-button-small span{text-align:left;text-overflow:ellipsis;width:100%;overflow:hidden}.girafe-button-tiny{align-items:center;width:1rem;height:1rem;padding:0}.girafe-button-tiny img{overflow:hidden}.girafe-onboarding-theme{background-color:var(--bkg-color)!important;color:var(--text-color)!important}.girafe-onboarding-theme button{background-color:var(--bkg-color)!important;color:var(--text-color)!important;text-shadow:none!important}.girafe-onboarding-theme button.driver-popover-close-btn{z-index:10000}.tippy-box{background-color:var(--bkg-color)!important;border:var(--app-standard-border)!important}.tippy-content{color:var(--text-color)!important}.tippy-arrow{color:var(--bkg-color)!important}.tippy-box[data-theme~=error]{background-color:var(--error-color);white-space:pre-line}div.tippy-box[data-theme=image-popup]{border:var(--app-standard-border)!important;& div.tippy-content{background-color:var(--bkg-color)!important;& img{max-width:20rem;max-height:20rem}}& div.tippy-arrow{color:var(--bkg-color)!important}}
32
24
  </style><style>
33
- #content{background:var(--bkg-color);color:var(--text-color);flex-direction:column;gap:1rem;margin:0;padding:1rem;display:flex}.girafe-prototype{color:#fff;text-align:center;background:#ec5555;font-size:1rem;font-weight:700;line-height:40px}.editing{flex-direction:column;gap:1rem;display:flex}#layer-selector{width:100%}.draw-btn{text-align:right}.current-feature{border-top:var(--app-standard-border);margin-top:2rem}.current-feature-row{align-items:center;gap:.5em;display:flex}.current-feature-row>button{margin-left:auto}.current-feature-row>div:first-child{font-weight:700}.attribute-form-btns{justify-content:flex-end;gap:.5rem;margin-top:1rem;display:flex}.btn-active{background-color:var(--bkg-color-grad2)}
25
+ #content{background:var(--bkg-color);color:var(--text-color);box-sizing:border-box;flex-direction:column;gap:.5rem;width:100%;min-width:0;height:100%;min-height:0;margin:0;display:flex;overflow:hidden}.editing{flex-direction:column;gap:.5rem;padding:1rem;display:flex;overflow:hidden}.separator{background:var(--app-color-grey);width:100%;height:1px;margin:8px 0}.section-title{font-size:1.1rem}#layer-selector{width:100%}.action-bar{justify-content:center;gap:1rem;display:flex;&.vertical{flex-direction:column;align-items:center;margin:1rem 0}}.gg-medium-withtext{align-items:center;display:flex}.drawing-help{color:var(--text-color-grad1);text-align:center;flex-direction:column;align-items:center;gap:.5rem;padding:.5rem 2rem;font-size:.9rem;font-style:italic;display:flex}.attribute-form-btns{justify-content:flex-end;gap:.5rem;margin-top:2rem;display:flex}#delete-btn{border-color:var(--error-color);color:var(--error-color);border-width:2px;margin-left:auto}.scrollable-form-container{padding-right:.5rem;overflow-y:auto}@keyframes fadeOut{0%{opacity:1}to{opacity:0;pointer-events:none}}.successMsg{background:var(--success-color);color:var(--text-color);justify-content:center;align-items:center;padding:.5rem;animation:2s ease-out 5s forwards fadeOut;display:flex}
34
26
  </style>
35
27
  <style>${this.customStyle}</style>
36
- <div id="content"><div class="girafe-prototype" i18n="PROTOTYPE - Work in progress">PROTOTYPE - Work in progress</div><div class="editing"><select id="layer-selector" class="gg-select" aria-label="Layer to edit" disabled="${this.feature}" onchange="${(evt) => this.onSelectLayer(evt)}">${this.editableLayersList.length === 0 && this.state.oauth.status !== 'loggedIn' ? uHtml `<option i18n="Please log in to edit layers..." ?selected="true" value="">Please log in to edit layers...</option>` : uHtml `<option i18n="Choose a layer..." ?selected="true" value="">Choose a layer...</option>`} ${this.editableLayersList.map(layer => uHtmlFor(layer, layer.collectionId) `<option value="${layer.collectionId}">${layer.displayName}</option>`)}</select> ${this.layer ? uHtml `<div class="draw-btn">${this.displayDrawingCancelButton() ? uHtml ` <button class="gg-button gg-medium-withtext btn-active" onclick="${() => this.onCancelDrawing()}"><img alt="cancel-drawing-icon" src="icons/close.svg"> <span i18n="Cancel editing">Cancel editing</span></button> ` : uHtml ` <button class="gg-button gg-medium-withtext" onclick="${() => this.onStartDrawing()}"><img alt="start-drawing-icon" src="${this.getButtonIcon()}"> <span i18n="${this.getButtonText()}">${this.getButtonText()}</span></button> `}</div>` : uHtml ``} ${this.feature ? uHtml `<div class="current-feature"><h3 i18n="Current Feature">Current Feature</h3><div class="current-feature-row"><div i18n="Feature ID">Feature ID</div><div>${this.getFeatureId()}</div><button class="${this.canDelete() ? 'gg-button gg-medium-withtext delete-btn' : 'hidden'}" onclick="${() => this.onDelete()}"><img alt="delete-icon" src="icons/trash.svg"> <span i18n="delete">Delete</span></button></div></div>` : uHtml ``}<girafe-edit-form id="edit-form"></girafe-edit-form>${this.feature ? uHtml `<div class="attribute-form-btns"><button class="gg-button" disabled="${!this.isValidForm()}" onclick="${() => this.onSave()}"><span i18n="Save">Save</span></button> <button class="gg-button" onclick="${() => this.onDiscard()}"><span i18n="Discard">Discard</span></button></div>` : uHtml ``}</div></div>
28
+ <div id="content"><div class="editing"><div class="section-title" i18n="Layer">Layer</div><select id="layer-selector" class="${this.canChangeSelectedLayer() ? 'gg-select' : 'gg-select disabled'}" aria-label="${this.getLayerSelectorPlaceholder()}" ?disabled="${!this.canChangeSelectedLayer()}" onchange="${(evt) => this.onLayerSelectedFromList(evt)}"><option i18n="${this.getLayerSelectorPlaceholder()}" ?selected="${this.layer === undefined}" value="">${this.getLayerSelectorPlaceholder()}</option>${this.editableLayersInTree.map(layer => uHtmlFor(layer, layer.uniqueLayerName) `<option value="${layer.uniqueLayerName}" ?selected="${this.layer?.uniqueLayerName === layer.uniqueLayerName}" i18n="${layer.id}">${layer.id}</option>`)}</select><div class="separator"></div>${this.actionButtonsVisible() ? uHtml `<div class="action-bar"><button class="${this.getActionBtnClass('selectFeatureBtn')}" ?disabled="${this.editComponentState === 'CreateGeometry'}" onclick="${() => this.onStartSelectingFeature()}"><img alt="start-drawing-icon" src="icons/arrow.svg"> <span i18n="Select feature in map">Select feature in map</span></button> <button class="${this.getActionBtnClass('startDrawingBtn')}" onclick="${() => this.onStartDrawing()}"><img alt="start-drawing-icon" src="${this.getButtonIcon()}"> <span i18n="${this.getDrawingActionText()}">${this.getDrawingActionText()}</span></button></div>` : uHtml ``} ${this.geometrySectionVisible() ? uHtml `<div class="separator"></div><div class="section-title" i18n="geometry">Geometry</div><div class="${this.feature ? 'drawing-help' : 'hidden'}"><div i18n="Modify the geometry by grabbing a corner.">Modify the geometry by grabbing a corner.</div><div class="${this.isPoint() ? 'hidden' : ''}" i18n="Add a corner by clicking on an edge.">Add a corner by clicking on an edge.</div></div><div class="${this.feature ? 'hidden' : 'action-bar vertical'}"><div class="${this.isMultiGeometry() && !this.isPoint() ? 'drawing-help' : 'hidden'}"><div i18n="Finish each geometry with a double click.">Finish each geometry with a double click.</div></div><button class="${this.getActionBtnClass('finishDrawingBtn')}" onclick="${() => this.onFinishDrawingByBtnClick()}"><img alt="finish-drawing-icon" src="icons/checked-no-border.svg"> <span i18n="Finish drawing">Finish drawing</span></button> <button class="${this.getActionBtnClass('cancelDrawingBtn')}" onclick="${() => this.onCancelDrawing()}"><img alt="cancel-drawing-icon" src="icons/close.svg"> <span i18n="Cancel drawing">Cancel drawing</span></button></div>` : uHtml ``}<div class="${this.attributeFormVisible() ? 'separator' : 'hidden'}"></div><div class="${this.attributeFormVisible() ? 'section-title' : 'hidden'}" i18n="Attributes">Attributes</div><div class="scrollable-form-container"><girafe-edit-form id="edit-form"></girafe-edit-form></div>${this.attributeFormVisible() ? uHtml `<div class="attribute-form-btns"><button class="gg-button gg-medium-withtext" onclick="${() => this.onDiscard()}"><img alt="cancel-drawing-icon" src="icons/close.svg"> <span i18n="Cancel">Cancel</span></button> <button class="gg-button gg-medium-withtext" disabled="${!this.isValidForm()}" onclick="${() => this.onSave()}"><img alt="cancel-drawing-icon" src="icons/checked-no-border.svg"> <span i18n="Save">Save</span></button></div>${this.canDelete() ? uHtml `<div class="separator"></div><button id="delete-btn" class="gg-button gg-medium-withtext" onclick="${() => this.onDelete()}"><img alt="delete-icon" src="icons/trash.svg"> <span i18n="Delete Feature">Delete Feature</span></button> ` : uHtml ``} ` : uHtml ``}</div><div class="${this.successMsg ? 'successMsg gg-small' : 'hidden'}"><img alt="successful-icon" src="icons/checked-no-border.svg"> <span>${this.successMsg}</span></div></div>
37
29
  ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
38
30
  };
39
31
  isPanelVisible = false;
40
32
  panelTitle = 'edit-panel';
41
33
  panelTogglePath = 'interface.editPanelVisible';
42
- editableLayersList = [];
43
- get map() {
44
- return this.context.mapManager.getMap();
45
- }
46
- draw;
47
- modify;
48
- select;
49
- drawingLayer;
50
- drawingSource;
34
+ editComponentState = 'Idle';
35
+ editableLayersFromServer = new Map();
36
+ editableLayersInTree = [];
37
+ layer;
51
38
  feature;
39
+ // Reference to the layer in the layer tree
40
+ treeLayer;
41
+ previousTreeLayerVisibility;
42
+ geometryEditingHelper;
52
43
  form;
53
- featureSchema;
54
- // POC: Demo layers
55
- layer; // Layer definition / config
56
- demoMapLayer; // Layer in the map
44
+ successMsg;
57
45
  constructor() {
58
46
  super('edit');
59
47
  }
@@ -61,356 +49,416 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
61
49
  super.render();
62
50
  if (this.isPanelVisible) {
63
51
  this.renderComponent();
64
- this.state.layers.isSnappingActive = true;
52
+ super.girafeTranslate();
65
53
  }
66
54
  else {
67
55
  this.renderEmptyComponent();
68
- this.state.layers.isSnappingActive = false;
69
56
  }
70
- super.girafeTranslate();
57
+ }
58
+ refreshRender() {
59
+ super.refreshRender();
60
+ this.successMsg = undefined;
61
+ }
62
+ togglePanel(visible) {
63
+ this.isPanelVisible = visible;
64
+ this.render();
71
65
  }
72
66
  renderComponent() {
73
- this.registerInteractionListener('map.select', true);
74
- this.registerInteractionListener('map.draw', true);
75
- this.registerInteractionListener('map.modify', true);
76
- this.collectEditableLayers();
77
- this.refreshRender();
67
+ this.geometryEditingHelper.registerInteractions(this.name);
78
68
  if (!this.form) {
79
- // The attribute form is managed in a subcomponent
80
69
  this.form = this.getById('edit-form');
70
+ this.form.addEventListener(EditingFormChange, (() => this.refreshRender()));
81
71
  }
72
+ this.refreshRender();
82
73
  }
83
74
  renderEmptyComponent() {
84
- this.resetComponent();
75
+ if (this.layer) {
76
+ void this.setLayer(undefined);
77
+ }
78
+ this.geometryEditingHelper.unregisterInteractions(this.name);
85
79
  this.renderEmpty();
86
80
  }
87
- loginStateChanged() {
88
- // Editable demo layers should only be available if the user is currently on the matching demo instance and is logged in
89
- this.editableLayersList = Object.values(DEMO_LAYERS).filter((layer) => {
90
- try {
91
- const oapifUrl = new URL(layer.url);
92
- const themesUrl = new URL(this.context.configManager.Config.themes.url);
93
- return oapifUrl.hostname === themesUrl.hostname && this.state.oauth.status === 'loggedIn';
94
- }
95
- catch {
96
- // Cannot parse this.configManager.Config.themes.url as URL.
97
- // TODO : This should be changed when editing is not just a demo any more
98
- return false;
81
+ transitionTo(state) {
82
+ this.editComponentState = state;
83
+ this.geometryEditingHelper.updateMapInteractionsByState(this.editComponentState);
84
+ }
85
+ canChangeSelectedLayer() {
86
+ return this.editComponentState === 'Idle' || this.editComponentState === 'LayerSelected';
87
+ }
88
+ actionButtonsVisible() {
89
+ return this.editComponentState === 'LayerSelected' || this.editComponentState === 'CreateGeometry';
90
+ }
91
+ geometrySectionVisible() {
92
+ return this.editComponentState === 'CreateGeometry' || this.editComponentState === 'FeatureSelected';
93
+ }
94
+ attributeFormVisible() {
95
+ return this.editComponentState === 'FeatureSelected';
96
+ }
97
+ getActionBtnClass(btnName) {
98
+ const btnHidden = 'hidden';
99
+ const btnDefault = 'gg-button gg-medium-withtext';
100
+ const btnActive = `${btnDefault} active`;
101
+ switch (btnName) {
102
+ case 'selectFeatureBtn':
103
+ if (this.editComponentState === 'LayerSelected')
104
+ return btnActive;
105
+ if (this.editComponentState === 'CreateGeometry')
106
+ return btnDefault;
107
+ return btnHidden;
108
+ case 'startDrawingBtn':
109
+ if (this.layer?.hasPermission('CREATE') && this.editComponentState === 'CreateGeometry')
110
+ return btnActive;
111
+ if (this.layer?.hasPermission('CREATE') && this.editComponentState === 'LayerSelected')
112
+ return btnDefault;
113
+ return btnHidden;
114
+ case 'finishDrawingBtn':
115
+ case 'cancelDrawingBtn':
116
+ return this.editComponentState === 'CreateGeometry' ? btnDefault : 'hidden';
117
+ default:
118
+ return btnHidden;
119
+ }
120
+ }
121
+ async collectEditableLayers() {
122
+ this.editableLayersFromServer = await this.context.ogcApiFeaturesManager.collectEditableLayers();
123
+ this.filterLayerListByLayersInTree();
124
+ }
125
+ filterLayerListByLayersInTree() {
126
+ this.editableLayersInTree = [];
127
+ for (const [editLayerName, layer] of this.editableLayersFromServer) {
128
+ const layerInTree = this.getLayerInTree(editLayerName);
129
+ if (layerInTree) {
130
+ this.editableLayersInTree.push(layer);
99
131
  }
100
- });
101
- void this.loadDemoServerConfig();
102
- this.render();
132
+ }
133
+ if (this.rendered) {
134
+ this.refreshRender();
135
+ }
103
136
  }
104
- async onSelectLayer(evt) {
105
- const layerId = evt.target?.value;
106
- this.layer = this.editableLayersList.find((layer) => layer.collectionId === layerId);
107
- this.removeMapInteractions();
108
- this.unsetEditFeature();
109
- if (this.layer) {
110
- this.featureSchema = await this.context.ogcApiFeaturesManager.getSchema(this.layer);
111
- this.form.setSchema(this.featureSchema);
112
- this.createDemoMapLayer(); // POC
113
- this.createMapInteractions();
137
+ getLayerSelectorPlaceholder() {
138
+ return this.editableLayersInTree.length === 0 ? 'No editable layer available' : 'Choose a layer...';
139
+ }
140
+ onLayerSelectedInTree(layer) {
141
+ const editLayerName = layer?.editLayers?.length ? layer.editLayers[0] : undefined;
142
+ if (editLayerName !== this.layer?.uniqueLayerName) {
143
+ void this.onSelectLayer(editLayerName);
144
+ }
145
+ }
146
+ onLayerSelectedFromList(evt) {
147
+ const editLayerName = evt.target?.value;
148
+ void this.onSelectLayer(editLayerName);
149
+ }
150
+ async onSelectLayer(editLayerName) {
151
+ if (this.featureIsModified() && !(await this.confirmDiscardChanges())) {
152
+ return;
153
+ }
154
+ let layer = undefined;
155
+ if (editLayerName) {
156
+ layer = this.editableLayersFromServer.get(editLayerName) ?? undefined;
157
+ }
158
+ const layerSelector = this.getById('layer-selector');
159
+ layerSelector?.setAttribute('disabled', 'true');
160
+ await this.setLayer(layer);
161
+ if (this.rendered) {
162
+ this.refreshRender();
163
+ layerSelector?.removeAttribute('disabled');
164
+ }
165
+ }
166
+ async setLayer(layer) {
167
+ this.layer = undefined;
168
+ this.geometryEditingHelper.reset();
169
+ this.revertLayerInTree();
170
+ this.setEditFeature(undefined);
171
+ if (layer) {
172
+ this.layer = await this.context.ogcApiFeaturesManager.analyseLayerForEditing(layer);
173
+ if (!this.layer.valid) {
174
+ await this.setLayer(undefined);
175
+ return;
176
+ }
177
+ await this.checkCrsCompatibilityWithMap();
178
+ this.form?.setSchema(this.layer.schema);
179
+ this.geometryEditingHelper.setupMapInteractions(this.layer);
180
+ this.activateLayerInTree();
181
+ this.transitionTo('LayerSelected');
114
182
  }
115
183
  else {
116
- this.removeDemoMapLayer(); // POC
184
+ this.transitionTo('Idle');
185
+ }
186
+ this.state.editing.layer = this.treeLayer ?? null;
187
+ }
188
+ async confirmDiscardChanges() {
189
+ return await window.gConfirm('Cancel and discard the current changes?', 'Cancel editing');
190
+ }
191
+ async checkCrsCompatibilityWithMap() {
192
+ if (!this.layer?.storageCrs) {
193
+ return;
117
194
  }
195
+ if (this.layer.storageCrs !== this.state.projection) {
196
+ // Check if GG can switch to the storage crs
197
+ const projection = getProjection(this.layer.storageCrs);
198
+ const title = 'Coordinate system mismatch';
199
+ if (!projection) {
200
+ // Edited features will have to be reprojected to be saved
201
+ await window.gAlert('The layer coordinate system is not supported by GeoGirafe. Precision loss may occur while editing.', title);
202
+ return;
203
+ }
204
+ const choice = await window.gPromptChoice('Please switch the map to the layer coordinate system to prevent precision loss while editing geometries.', title, ['Ok, switch', 'No']);
205
+ if (choice !== 'No') {
206
+ this.state.projection = this.layer.storageCrs;
207
+ }
208
+ }
209
+ }
210
+ onStartSelectingFeature() {
211
+ this.transitionTo('LayerSelected');
118
212
  this.refreshRender();
119
213
  }
120
214
  onStartDrawing() {
121
- this.unsetEditFeature();
122
- this.startDrawingMode();
215
+ this.setEditFeature(undefined);
216
+ this.transitionTo('CreateGeometry');
123
217
  this.refreshRender();
124
218
  }
125
219
  onCancelDrawing() {
220
+ this.transitionTo('LayerSelected');
126
221
  this.onDiscard();
127
222
  }
128
223
  onDiscard() {
129
- this.unsetEditFeature();
130
- this.startSelectionMode();
224
+ this.setEditFeature(undefined);
225
+ this.transitionTo('LayerSelected');
131
226
  this.refreshRender();
132
227
  }
133
- startDrawingMode() {
134
- // Stop selection mode
135
- this.select?.getFeatures().clear();
136
- this.select?.setActive(false);
137
- // Start drawing mode
138
- this.drawingSource?.clear();
139
- this.draw?.setActive(true);
140
- }
141
- startSelectionMode() {
142
- this.draw?.setActive(false);
143
- this.select?.getFeatures().clear();
144
- this.select?.setActive(true);
145
- }
146
- onSave() {
228
+ async onSave() {
147
229
  if (!this.feature)
148
230
  return;
149
- void this.saveFeature();
231
+ if (await this.saveFeature()) {
232
+ this.setEditFeature(undefined);
233
+ this.refreshLayerInTree();
234
+ this.geometryEditingHelper.refreshLayers();
235
+ this.transitionTo('LayerSelected');
236
+ this.successMsg = 'Feature saved';
237
+ this.refreshRender();
238
+ }
150
239
  }
151
240
  async onDelete() {
152
- if (!this.feature || !this.canDelete())
241
+ if (!this.canDelete())
153
242
  return;
154
- const confirm = await window.gConfirm('Do you want to delete this feature?', 'Delete feature');
155
- if (confirm) {
156
- void this.deleteFeature(this.getFeatureId());
243
+ const confirm = await window.gConfirm('Do you want to delete this feature?', 'Delete Feature');
244
+ if (!confirm) {
245
+ return;
246
+ }
247
+ if (await this.deleteFeature(this.getFeatureId())) {
248
+ this.setEditFeature(undefined);
249
+ this.refreshLayerInTree();
250
+ this.geometryEditingHelper.refreshLayers();
251
+ this.transitionTo('LayerSelected');
252
+ this.successMsg = 'Feature deleted';
253
+ this.refreshRender();
157
254
  }
158
255
  }
159
256
  canDelete() {
160
- return this.getFeatureId() !== newId;
257
+ return this.getFeatureId() !== null && !!this.layer?.hasPermission('DELETE');
161
258
  }
162
- resetComponent() {
163
- this.removeMapInteractions();
164
- this.unselectLayer();
165
- this.removeDemoMapLayer(); // POC
259
+ async onSelectFeature(selectedFeatures) {
260
+ if (this.featureIsModified() && !(await this.confirmDiscardChanges())) {
261
+ return;
262
+ }
263
+ this.setEditFeature(selectedFeatures[0]);
264
+ if (this.feature) {
265
+ this.transitionTo('FeatureSelected');
266
+ }
166
267
  this.refreshRender();
167
268
  }
168
- unselectLayer() {
169
- this.layer = undefined;
170
- this.unsetEditFeature();
171
- this.getById('layer-selector').value = '';
172
- }
173
- collectEditableLayers() {
174
- // POC
175
- return;
176
- }
177
- createMapInteractions() {
178
- if (!this.drawingLayer) {
179
- // Create drawing layer and source
180
- this.drawingSource = new VectorSource({});
181
- this.drawingLayer = new VectorLayer({
182
- source: this.drawingSource,
183
- style: editStyle,
184
- zIndex: 2001
185
- });
186
- this.map.addLayer(this.drawingLayer);
187
- }
188
- // Interactions
189
- if (this.select) {
190
- this.map.removeInteraction(this.select);
191
- }
192
- if (this.demoMapLayer) {
193
- this.select = new Select({
194
- layers: [this.demoMapLayer],
195
- hitTolerance: 10,
196
- style: editStyle
197
- });
198
- this.select.on('select', (evt) => {
199
- if (!this.canExecute('map.select'))
200
- return;
201
- void this.onSelectFeature(evt);
202
- });
203
- this.map.addInteraction(this.select);
204
- }
205
- if (this.draw) {
206
- this.map.removeInteraction(this.draw);
207
- }
208
- this.draw = new Draw({
209
- source: this.drawingSource,
210
- condition: () => this.canExecute('map.draw'),
211
- type: this.layer.geometryType,
212
- stopClick: true,
213
- style: editStyle
214
- });
215
- this.draw.on('drawstart', () => { });
216
- this.draw.on('drawend', (evt) => {
217
- if (!this.canExecute('map.draw'))
218
- return;
219
- this.setEditFeature(evt.feature);
220
- this.draw?.setActive(false);
221
- });
222
- this.draw.setActive(false);
223
- this.map.addInteraction(this.draw);
224
- if (this.modify) {
225
- this.map.removeInteraction(this.modify);
226
- }
227
- this.modify = new Modify({
228
- source: this.drawingSource,
229
- condition: () => this.canExecute('map.modify')
230
- });
231
- this.map.addInteraction(this.modify);
232
- this.modify.setActive(false);
233
- }
234
- removeMapInteractions() {
235
- this.drawingSource?.clear();
236
- if (this.select)
237
- this.map.removeInteraction(this.select);
238
- if (this.draw)
239
- this.map.removeInteraction(this.draw);
240
- if (this.modify)
241
- this.map.removeInteraction(this.modify);
242
- if (this.drawingLayer) {
243
- this.map.removeLayer(this.drawingLayer);
244
- this.drawingLayer = undefined;
245
- }
246
- }
247
- async onSelectFeature(evt) {
248
- this.drawingSource?.clear();
249
- const bbox = getSelectionBoxFromMapClick(evt.mapBrowserEvent.pixel, this.map, 10);
250
- const selectedFeature = await this.context.ogcApiFeaturesManager.getItems(this.layer, this.map.getView().getProjection().getCode(), bbox, 1);
251
- if (selectedFeature.length > 0) {
252
- this.setEditFeature(selectedFeature[0]);
253
- if (this.feature)
254
- this.drawingSource?.addFeature(this.feature);
255
- }
256
- else {
257
- this.unsetEditFeature();
269
+ canSelectFeatureInMap() {
270
+ return this.editComponentState === 'LayerSelected' || this.editComponentState === 'FeatureSelected';
271
+ }
272
+ onFinishDrawingByBtnClick() {
273
+ const feature = this.geometryEditingHelper.finishDrawing();
274
+ if (feature) {
275
+ this.finishDrawing(feature);
258
276
  }
259
- this.select?.getFeatures().clear();
260
277
  }
261
- setEditFeature(feature) {
262
- if (!feature) {
263
- this.unsetEditFeature();
264
- return;
278
+ onFinishDrawingByInteraction(feature) {
279
+ this.finishDrawing(feature);
280
+ }
281
+ finishDrawing(feature) {
282
+ this.setEditFeature(feature);
283
+ if (this.feature) {
284
+ this.transitionTo('FeatureSelected');
265
285
  }
266
- this.feature = feature;
267
- this.form.setFeature(this.feature);
268
- this.modify?.setActive(true);
269
286
  this.refreshRender();
270
287
  }
271
- unsetEditFeature() {
272
- this.feature = undefined;
273
- this.drawingSource?.clear();
288
+ setEditFeature(feature) {
289
+ this.feature = feature;
290
+ this.geometryEditingHelper.setEditFeature(this.feature);
274
291
  this.form?.setFeature(this.feature);
275
- this.modify?.setActive(false);
276
- this.refreshRender();
277
292
  }
278
293
  isValidForm() {
279
- return this.form.valid();
294
+ return this.form?.valid();
295
+ }
296
+ featureIsModified() {
297
+ return this.form?.dataIsModified || this.geometryEditingHelper.geometryIsModified;
280
298
  }
281
299
  async saveFeature() {
282
- if (!this.layer || !this.feature) {
283
- return;
300
+ if (!this.layer || !this.feature || !this.form) {
301
+ return false;
302
+ }
303
+ if (!this.form.validateForm()) {
304
+ return false;
284
305
  }
285
306
  const formValues = this.form.getFormValues();
286
307
  const featureToSave = new Feature();
287
- const id = this.getFeatureId();
288
- featureToSave.setGeometry(this.feature.getGeometry());
308
+ const featureId = this.getFeatureId();
309
+ featureToSave.setGeometry(this.geometryEditingHelper.getEditFeature()?.getGeometry());
289
310
  featureToSave.setProperties(formValues);
290
- if (id === newId) {
291
- await this.context.ogcApiFeaturesManager.createItem(this.layer, featureToSave);
311
+ if (featureId === null) {
312
+ return await this.context.ogcApiFeaturesManager.createItem(this.layer, featureToSave);
292
313
  }
293
314
  else {
294
- featureToSave.setId(id);
295
- await this.context.ogcApiFeaturesManager.updateItem(this.layer, id, featureToSave);
315
+ featureToSave.setId(featureId);
316
+ return await this.context.ogcApiFeaturesManager.replaceItem(this.layer, featureId, featureToSave);
296
317
  }
297
- this.unsetEditFeature();
298
- this.refreshDemoMapLayer();
299
- this.startSelectionMode();
300
318
  }
301
319
  async deleteFeature(featureId) {
302
- await this.context.ogcApiFeaturesManager.deleteItem(this.layer, featureId);
303
- this.unsetEditFeature();
304
- this.refreshDemoMapLayer();
305
- this.startSelectionMode();
320
+ if (!this.layer || !this.feature || !this.form) {
321
+ return false;
322
+ }
323
+ return await this.context.ogcApiFeaturesManager.deleteItem(this.layer, featureId);
306
324
  }
307
- createDemoMapLayer() {
308
- if (!this.layer)
309
- return;
310
- if (this.demoMapLayer) {
311
- this.removeDemoMapLayer();
312
- }
313
- const vectorSource = new VectorSource({
314
- loader: async (extent, _resolution, projection) => {
315
- const features = await this.context.ogcApiFeaturesManager.getItems(this.layer, projection.getCode(), extent);
316
- if (features) {
317
- vectorSource.addFeatures(features);
318
- }
319
- },
320
- strategy: bbox
321
- });
322
- this.demoMapLayer = new VectorLayer({
323
- source: vectorSource,
324
- style: baseStyle
325
- });
326
- this.map.addLayer(this.demoMapLayer);
325
+ getLayerInTree(editLayerName) {
326
+ return this.context.layerManager
327
+ .getFlattenedLayerTree(this.state.layers.layersList)
328
+ .find((layer) => isEditableLayer(layer) && layer.editLayers?.includes(editLayerName));
327
329
  }
328
- refreshDemoMapLayer() {
329
- if (!this.layer)
330
+ activateLayerInTree() {
331
+ this.treeLayer = undefined;
332
+ this.previousTreeLayerVisibility = undefined;
333
+ if (!this.layer) {
330
334
  return;
331
- if (!this.demoMapLayer) {
332
- this.createDemoMapLayer();
333
335
  }
334
- this.demoMapLayer.getSource().refresh();
336
+ this.treeLayer = this.getLayerInTree(this.layer.uniqueLayerName);
337
+ if (this.treeLayer) {
338
+ this.previousTreeLayerVisibility = this.treeLayer.activeState;
339
+ this.context.layerManager.toggleLayer(this.treeLayer, 'on');
340
+ }
335
341
  }
336
- removeDemoMapLayer() {
337
- if (this.demoMapLayer) {
338
- this.map.removeLayer(this.demoMapLayer);
339
- this.demoMapLayer = undefined;
342
+ revertLayerInTree() {
343
+ if (this.treeLayer) {
344
+ this.context.layerManager.toggleLayer(this.treeLayer, this.previousTreeLayerVisibility);
340
345
  }
346
+ this.treeLayer = undefined;
347
+ this.previousTreeLayerVisibility = undefined;
341
348
  }
342
- togglePanel(visible) {
343
- this.isPanelVisible = visible;
344
- this.render();
349
+ refreshLayerInTree() {
350
+ if (!this.treeLayer)
351
+ return;
352
+ if (this.treeLayer instanceof LayerWms) {
353
+ this.context.wmsManager.getClient(this.treeLayer)?.refreshLayer(this.treeLayer);
354
+ }
345
355
  }
346
356
  getButtonIcon() {
347
357
  let icon = 'draw';
348
- const geometryType = this.layer?.geometryType ?? '';
349
- if (geometryType.includes('Point')) {
358
+ const geometryType = this.layer?.geometryType?.toLowerCase() ?? '';
359
+ if (geometryType.includes('point')) {
350
360
  icon = 'point';
351
361
  }
352
- else if (geometryType.includes('Line')) {
362
+ else if (geometryType.includes('line')) {
353
363
  icon = 'polyline';
354
364
  }
355
- else if (geometryType.includes('Polygon')) {
365
+ else if (geometryType.includes('polygon')) {
356
366
  icon = 'polygon';
357
367
  }
358
368
  return `icons/${icon}.svg`;
359
369
  }
360
- getButtonText() {
370
+ getDrawingActionText() {
361
371
  let text = 'Draw geometry';
362
372
  const geometryType = this.layer?.geometryType ?? '';
363
- if (geometryType.includes('Point')) {
364
- text = geometryType.startsWith('Multi') ? 'Draw points' : 'Draw point';
373
+ if (geometryType.toLowerCase().includes('point')) {
374
+ text = 'point';
365
375
  }
366
- else if (geometryType.includes('Line')) {
367
- text = geometryType.startsWith('Multi') ? 'Draw lines' : 'Draw line';
376
+ else if (geometryType.toLowerCase().includes('line')) {
377
+ text = 'line';
368
378
  }
369
- else if (geometryType.includes('Polygon')) {
370
- text = geometryType.startsWith('Multi') ? 'Draw polygons' : 'Draw polygon';
379
+ else if (geometryType.toLowerCase().includes('polygon')) {
380
+ text = 'polygon';
371
381
  }
372
- return text;
382
+ return this.isMultiGeometry() ? `Draw ${text}s` : `Draw ${text}`;
383
+ }
384
+ isMultiGeometry() {
385
+ return this.layer?.geometryType?.toLowerCase().startsWith('multi') ?? false;
373
386
  }
374
- displayDrawingCancelButton() {
375
- return this.draw?.getActive() ?? false;
387
+ isPoint() {
388
+ return this.layer?.geometryType?.toLowerCase().includes('point') ?? false;
376
389
  }
377
390
  getFeatureId() {
378
- if (this.feature && this.featureSchema) {
379
- return this.feature.getId()?.toString() ?? newId;
391
+ if (this.feature && this.layer) {
392
+ const id = this.feature.getId();
393
+ return this.isNullOrUndefinedOrBlank(id) ? null : `${id}`;
394
+ }
395
+ return null;
396
+ }
397
+ canExecute(command) {
398
+ if (command === 'map.select') {
399
+ return super.canExecute(command) && this.canSelectFeatureInMap();
380
400
  }
381
- return '';
401
+ return super.canExecute(command);
382
402
  }
383
- getFeatureProperties() {
384
- return this.featureSchema?.formAttributes ?? [];
403
+ registerEvents() {
404
+ this.subscribe('oauth.status', () => void this.collectEditableLayers());
405
+ this.subscribe('application.isReady', () => void this.collectEditableLayers());
406
+ this.subscribe(/layers\.layersList\..*\.activeState/, () => this.filterLayerListByLayersInTree());
407
+ this.subscribe('projection', () => (this.state.application.isReady ? void this.setLayer(this.layer) : undefined));
408
+ this.subscribe('editing.layer', (_, layer) => this.onLayerSelectedInTree(layer));
385
409
  }
386
410
  /**
387
- * POC: Add ogc servers to the state and preload them.
411
+ * This should be solved with a generic solution to control button visibility,
412
+ * see https://gitlab.com/geogirafe/gg-viewer/-/work_items/966
388
413
  */
389
- async loadDemoServerConfig() {
390
- for (const layer of this.editableLayersList) {
391
- if (!this.state.ogcServers[layer.server.name]) {
392
- this.state.ogcServers[layer.server.name] = layer.server;
393
- await this.context.ogcApiFeaturesManager.getServer(layer.server);
394
- // A demo layer is defined either by its collection id or title. In the case of the title,
395
- // the id is requested from the server and stored in the layer definition.
396
- if (!layer.collectionId) {
397
- const collection = await this.context.ogcApiFeaturesManager.getCollectionByTitle(layer.collectionTitle, layer.server);
398
- if (collection?.title) {
399
- layer.collectionId = collection.id;
400
- }
401
- }
402
- }
414
+ controlToolbarButtonVisibility() {
415
+ const componentButton = document.querySelector('[data-visibility-control=edit]');
416
+ if (!this.state.editing.available) {
417
+ componentButton?.classList.add('hidden');
403
418
  }
419
+ this.subscribe('editing.available', (_, available) => {
420
+ if (available) {
421
+ componentButton?.classList.remove('hidden');
422
+ }
423
+ else {
424
+ componentButton?.classList.add('hidden');
425
+ }
426
+ });
404
427
  }
405
428
  connectedCallback() {
406
429
  super.connectedCallback();
407
- this.subscribe('oauth.status', () => this.loginStateChanged());
408
- // Add ogc servers to state
409
- this.subscribe('application.isReady', () => {
410
- if (this.state.application.isReady) {
411
- this.loginStateChanged();
412
- }
413
- });
414
- this.render();
430
+ this.registerEvents();
431
+ this.controlToolbarButtonVisibility();
432
+ this.geometryEditingHelper = new GeometryEditHelper(this.context, this.onSelectFeature.bind(this), this.onFinishDrawingByInteraction.bind(this), this.canExecute.bind(this));
415
433
  }
416
434
  }
435
+ __decorate([
436
+ UsedInTemplateOnly()
437
+ ], EditComponent.prototype, "canChangeSelectedLayer", null);
438
+ __decorate([
439
+ UsedInTemplateOnly()
440
+ ], EditComponent.prototype, "actionButtonsVisible", null);
441
+ __decorate([
442
+ UsedInTemplateOnly()
443
+ ], EditComponent.prototype, "geometrySectionVisible", null);
444
+ __decorate([
445
+ UsedInTemplateOnly()
446
+ ], EditComponent.prototype, "attributeFormVisible", null);
447
+ __decorate([
448
+ UsedInTemplateOnly()
449
+ ], EditComponent.prototype, "getActionBtnClass", null);
450
+ __decorate([
451
+ UsedInTemplateOnly()
452
+ ], EditComponent.prototype, "getLayerSelectorPlaceholder", null);
453
+ __decorate([
454
+ UsedInTemplateOnly()
455
+ ], EditComponent.prototype, "isValidForm", null);
456
+ __decorate([
457
+ UsedInTemplateOnly()
458
+ ], EditComponent.prototype, "getButtonIcon", null);
459
+ __decorate([
460
+ UsedInTemplateOnly()
461
+ ], EditComponent.prototype, "getDrawingActionText", null);
462
+ __decorate([
463
+ UsedInTemplateOnly()
464
+ ], EditComponent.prototype, "isPoint", null);