@geogirafe/lib-geoportal 1.3.0-dev.3053452205 → 1.3.0-dev.3079206142
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/LICENSE +1 -0
- package/assets/i18n/de.json +33 -3
- package/assets/i18n/en.json +32 -2
- package/assets/i18n/fr.json +34 -4
- package/assets/i18n/it.json +36 -6
- package/assets/icons/edit.svg +1 -1
- package/assets/icons/lock.svg +1 -0
- package/components/cross-section/cross-section-settings/component.js +1 -1
- package/components/edit/component.d.ts +52 -36
- package/components/edit/component.js +340 -292
- package/components/edit/editcomponentstate.d.ts +1 -0
- package/components/edit/editcomponentstate.js +1 -0
- package/components/edit/editform/component.d.ts +33 -4
- package/components/edit/editform/component.js +218 -37
- package/components/edit/editform/style.css +51 -16
- package/components/edit/geometryedithelper.d.ts +47 -0
- package/components/edit/geometryedithelper.js +324 -0
- package/components/edit/style.css +71 -28
- package/components/main.d.ts +1 -1
- package/components/main.js +1 -1
- package/components/print/component.d.ts +1 -1
- package/components/treeview/tools/treeviewelement.d.ts +1 -0
- package/components/treeview/tools/treeviewelement.js +22 -0
- package/components/treeview/treeviewitem/component.js +7 -1
- package/models/gmf.d.ts +18 -2
- package/models/gmf.js +3 -1
- package/models/layers/editablelayer.d.ts +7 -0
- package/models/layers/editablelayer.js +7 -0
- package/models/layers/layerwms.d.ts +1 -2
- package/models/layers/layerwms.js +4 -8
- package/models/main.d.ts +9 -4
- package/models/main.js +6 -2
- package/models/oapiflayer.d.ts +29 -0
- package/models/oapiflayer.js +40 -0
- package/models/oapiftypes.d.ts +71 -0
- package/models/oapiftypes.js +29 -0
- package/models/serverogc.d.ts +5 -3
- package/models/serverogc.js +19 -6
- package/models/serverogcapi.d.ts +2 -0
- package/models/serverogcapi.js +2 -0
- package/models/serverogcapifeatures.d.ts +5 -62
- package/models/serverogcapifeatures.js +8 -4
- package/package.json +1 -1
- package/templates/index.html +1 -0
- package/templates/public/about.json +1 -1
- package/tools/app/geogirafeapp.js +2 -2
- package/tools/drawing/olDrawing.js +2 -22
- package/tools/drawing/shapeConstraints.d.ts +2 -1
- package/tools/drawing/shapeConstraints.js +18 -2
- package/tools/main.d.ts +7 -5
- package/tools/main.js +7 -5
- package/tools/ogcapi/ogcapiclient.d.ts +7 -3
- package/tools/ogcapi/ogcapiclient.js +49 -4
- package/tools/ogcapi/ogcapiconformance.d.ts +2 -2
- package/tools/ogcapi/ogcapiconformance.js +7 -13
- package/tools/ogcapi/ogcapifeaturesclient.d.ts +65 -30
- package/tools/ogcapi/ogcapifeaturesclient.js +265 -139
- package/tools/ogcapi/ogcapifeaturesclientgeorama.d.ts +0 -5
- package/tools/ogcapi/ogcapifeaturesclientgeorama.js +0 -11
- package/tools/ogcapi/ogcapifeaturesclientqgis.d.ts +8 -0
- package/tools/ogcapi/ogcapifeaturesclientqgis.js +13 -0
- package/tools/ogcapi/ogcapifeaturesmanager.d.ts +61 -8
- package/tools/ogcapi/ogcapifeaturesmanager.js +179 -30
- package/tools/ogcapi/ogcapifeaturesschema.d.ts +31 -13
- package/tools/ogcapi/ogcapifeaturesschema.js +69 -39
- package/tools/ogcapi/ogcapifeaturesschemaproperty.d.ts +44 -0
- package/tools/ogcapi/ogcapifeaturesschemaproperty.js +137 -0
- package/tools/ogcapi/ogcapifeaturesschemavalidator.d.ts +22 -0
- package/tools/ogcapi/ogcapifeaturesschemavalidator.js +121 -0
- package/tools/state/state.d.ts +6 -0
- package/tools/state/state.js +4 -0
- package/tools/themes/themesmanager.d.ts +10 -3
- package/tools/themes/themesmanager.js +29 -9
- package/tools/time/layertimeformatter.d.ts +0 -5
- package/tools/time/layertimeformatter.js +10 -19
- package/tools/utils/dateutils.d.ts +40 -0
- package/tools/utils/dateutils.js +111 -0
- package/tools/utils/utils.d.ts +4 -0
- package/tools/utils/utils.js +12 -0
- package/tools/wfs/wfsmanager.js +3 -0
- package/tools/wms/wmsclient.d.ts +1 -0
- package/tools/wms/wmsclient.js +4 -0
- package/tools/ogcapi/demolayers.d.ts +0 -1
- package/tools/ogcapi/demolayers.js +0 -99
- package/tools/ogcapi/ogcapifeaturesclientgmf.d.ts +0 -13
- package/tools/ogcapi/ogcapifeaturesclientgmf.js +0 -30
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type EditComponentState = 'Idle' | 'LayerSelected' | 'FeatureSelected' | 'CreateGeometry';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,19 +1,48 @@
|
|
|
1
1
|
import GirafeHTMLElement from '../../../base/GirafeHTMLElement.js';
|
|
2
2
|
import Feature from 'ol/Feature.js';
|
|
3
3
|
import OgcApiFeaturesSchema from '../../../tools/ogcapi/ogcapifeaturesschema.js';
|
|
4
|
-
|
|
4
|
+
import { OgcApiFeaturesSchemaProperty } from '../../../tools/ogcapi/ogcapifeaturesschemaproperty.js';
|
|
5
|
+
import OgcApiFeaturesSchemaValidator from '../../../tools/ogcapi/ogcapifeaturesschemavalidator.js';
|
|
6
|
+
export declare const EditingFormChange = "editingFormChange";
|
|
7
|
+
type FormValue = string | number | boolean | null;
|
|
8
|
+
export default class EditFormComponent extends GirafeHTMLElement {
|
|
5
9
|
protected templateUrl: string | null;
|
|
6
10
|
protected styleUrls: string[] | null;
|
|
7
11
|
template: () => import("uhtml").Hole;
|
|
8
12
|
featureSchema?: OgcApiFeaturesSchema;
|
|
13
|
+
schemaValidator: OgcApiFeaturesSchemaValidator;
|
|
9
14
|
feature?: Feature;
|
|
15
|
+
validationError: Record<string, string[]>;
|
|
16
|
+
dataIsModified: boolean;
|
|
17
|
+
emptySelectOption: string;
|
|
10
18
|
constructor();
|
|
11
19
|
setSchema(schema: OgcApiFeaturesSchema): void;
|
|
12
20
|
setFeature(feature: Feature | undefined): void;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
21
|
+
refreshRender(): void;
|
|
22
|
+
private setFormInputAttributes;
|
|
23
|
+
private applyPropertyAttributes;
|
|
24
|
+
elementId(property: OgcApiFeaturesSchemaProperty): string;
|
|
25
|
+
getFormElementType(property: OgcApiFeaturesSchemaProperty): "select" | "input" | "checkbox";
|
|
26
|
+
getInputType(property: OgcApiFeaturesSchemaProperty): string;
|
|
27
|
+
isEmpty(property: OgcApiFeaturesSchemaProperty): boolean;
|
|
16
28
|
getFormValues(): Record<string, string | number | boolean | null>;
|
|
29
|
+
private getRawFormValue;
|
|
30
|
+
private getFormValue;
|
|
17
31
|
private resetForm;
|
|
32
|
+
validateForm(): boolean;
|
|
33
|
+
valid(): boolean;
|
|
34
|
+
private processNumericValue;
|
|
35
|
+
private processTemporalValue;
|
|
36
|
+
validateField(property: OgcApiFeaturesSchemaProperty, delayRendering?: boolean): void;
|
|
37
|
+
fieldValueHasChanged(property: OgcApiFeaturesSchemaProperty): void;
|
|
38
|
+
private createFormChangeEvent;
|
|
39
|
+
getCurrentValue(property: OgcApiFeaturesSchemaProperty): FormValue;
|
|
40
|
+
/**
|
|
41
|
+
* Depending on whether the value list is an enum, oneOf or foreign key, the feature may contain either the
|
|
42
|
+
* display title (label) or the raw value. We therefore use a fuzzy comparison against both title and value,
|
|
43
|
+
* including loose equality (==) to handle numbers represented as strings.
|
|
44
|
+
*/
|
|
45
|
+
private fuzzyCompareForValueListEntry;
|
|
18
46
|
protected connectedCallback(): void;
|
|
19
47
|
}
|
|
48
|
+
export {};
|
|
@@ -1,82 +1,263 @@
|
|
|
1
|
-
|
|
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
|
+
};
|
|
2
7
|
import { html as uHtml } from 'uhtml';
|
|
3
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
9
|
import GirafeHTMLElement from '../../../base/GirafeHTMLElement.js';
|
|
5
|
-
|
|
10
|
+
import { UsedInTemplateOnly } from '../../../decorators.js';
|
|
11
|
+
import OgcApiFeaturesSchemaValidator from '../../../tools/ogcapi/ogcapifeaturesschemavalidator.js';
|
|
12
|
+
import DateUtils from '../../../tools/utils/dateutils.js';
|
|
13
|
+
export const EditingFormChange = 'editingFormChange';
|
|
14
|
+
export default class EditFormComponent extends GirafeHTMLElement {
|
|
6
15
|
templateUrl = null;
|
|
7
16
|
styleUrls = null;
|
|
8
17
|
template = () => {
|
|
9
18
|
return uHtml `<style>
|
|
10
19
|
.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}}
|
|
11
20
|
</style><style>
|
|
12
|
-
.
|
|
21
|
+
.attribute-form{color:var(--text-color);flex-direction:column;gap:.8rem;margin:1rem 0;display:flex}#feature-id{min-height:calc(var(--app-standard-height) / 1.5);align-content:center;padding-left:.5rem}.form-field{flex-direction:column;gap:.3rem;display:flex}.form-field .gg-checkbox{margin-left:0}label{font-weight:700}.read-only-icon{opacity:.5;width:1rem;height:1rem}.is-required{font-size:1.2rem;font-weight:700}.description{color:var(--text-color-grad1);max-width:400px;font-style:italic}.text-ellipsis{text-overflow:ellipsis;width:100%;min-width:0;overflow:hidden}input:invalid{border:var(--error-color) solid 2px}.validation-error{color:var(--error-color);flex-direction:column;gap:.25rem;margin-bottom:.5rem;font-size:.8rem;font-style:italic;display:flex}
|
|
13
22
|
</style>
|
|
14
23
|
<style>${this.customStyle}</style>
|
|
15
|
-
${this.feature ? uHtml `<div class="attribute-form">${this.featureSchema?.
|
|
24
|
+
${this.feature ? uHtml `<div class="attribute-form">${this.featureSchema?.formProperties.map((property) => uHtml `<div class="form-field"><div><label for="${this.elementId(property)}" i18n="${property.title}">${property.title}</label> <span class="${property.isRequired && !property.isReadOnly ? 'is-required' : 'hidden'}">*</span> <img class="${property.isReadOnly ? 'read-only-icon' : 'hidden'}" alt="readonly-icon" src="icons/lock.svg"></div><div class="${property.description ? 'description' : 'hidden'}" i18n="${property.description}">${property.description}</div>${this.getFormElementType(property) === 'select' ? uHtml ` <select id="${this.elementId(property)}" aria-label="Select a value" class="gg-select text-ellipsis" onchange="${() => this.fieldValueHasChanged(property)}"><option value="${this.emptySelectOption}" i18n="${(property.valueListEntries?.length ?? 0) === 0 ? 'No values available' : 'Select a value'}" ?selected="${this.getCurrentValue(property) === null}" disabled="disabled">${(property.valueListEntries?.length ?? 0) === 0 ? 'No values available' : 'Select a value'}</option>${(property.valueListEntries ?? []).map(entry => uHtml `<option value="${entry.value}" i18n="${entry.title}" ?selected="${entry.value == this.getCurrentValue(property)}">${entry.title}</option>`)}</select> ` : this.getFormElementType(property) === 'checkbox' ? uHtml ` <input id="${this.elementId(property)}" type="checkbox" class="gg-checkbox" onchange="${() => this.fieldValueHasChanged(property)}" ?checked="${this.getCurrentValue(property) === true}"> ` : uHtml ` <input id="${this.elementId(property)}" type="${this.getInputType(property)}" class="gg-input" value="${this.getCurrentValue(property)}" onchange="${() => this.fieldValueHasChanged(property)}" onkeyup="${() => this.fieldValueHasChanged(property)}"> `}<div class="${this.validationError[property.name]?.length ? 'validation-error' : 'hidden'}">${(this.validationError[property.name] ?? []).map(error => uHtml ` <span>${error}</span> `)}</div></div>`)}</div>` : uHtml ``}
|
|
16
25
|
${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
|
|
17
26
|
};
|
|
18
27
|
featureSchema;
|
|
19
|
-
|
|
28
|
+
schemaValidator;
|
|
29
|
+
feature = undefined;
|
|
30
|
+
validationError = {};
|
|
31
|
+
dataIsModified = false;
|
|
32
|
+
emptySelectOption = '_null_';
|
|
20
33
|
constructor() {
|
|
21
34
|
super('editform');
|
|
22
35
|
}
|
|
23
36
|
setSchema(schema) {
|
|
24
37
|
this.featureSchema = schema;
|
|
25
|
-
this.
|
|
38
|
+
this.setFeature(undefined);
|
|
26
39
|
}
|
|
27
40
|
setFeature(feature) {
|
|
41
|
+
this.resetForm();
|
|
28
42
|
this.feature = feature;
|
|
29
|
-
if (!this.feature) {
|
|
30
|
-
this.resetForm();
|
|
31
|
-
}
|
|
32
43
|
this.refreshRender();
|
|
44
|
+
this.validateForm();
|
|
45
|
+
this.refreshRender();
|
|
46
|
+
}
|
|
47
|
+
refreshRender() {
|
|
48
|
+
super.refreshRender();
|
|
49
|
+
this.setFormInputAttributes();
|
|
33
50
|
}
|
|
34
|
-
|
|
35
|
-
|
|
51
|
+
setFormInputAttributes() {
|
|
52
|
+
for (const property of this.featureSchema?.formProperties ?? []) {
|
|
53
|
+
const formField = this.getById(this.elementId(property));
|
|
54
|
+
if (formField) {
|
|
55
|
+
this.applyPropertyAttributes(formField, property);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
applyPropertyAttributes(formField, property) {
|
|
60
|
+
if (property.isReadOnly) {
|
|
61
|
+
formField.setAttribute('readonly', '');
|
|
62
|
+
formField.setAttribute('disabled', '');
|
|
63
|
+
}
|
|
64
|
+
if (property.maxLength !== undefined) {
|
|
65
|
+
formField.setAttribute('maxlength', property.maxLength.toString());
|
|
66
|
+
}
|
|
67
|
+
if (property.isTemporalProperty) {
|
|
68
|
+
formField.setAttribute('step', '1');
|
|
69
|
+
}
|
|
70
|
+
if (property.isNumericProperty) {
|
|
71
|
+
formField.setAttribute('step', property.isIntegerProperty() ? '1' : 'any');
|
|
72
|
+
}
|
|
73
|
+
if (property.minimum !== undefined) {
|
|
74
|
+
formField.setAttribute('min', property.minimum.toString());
|
|
75
|
+
}
|
|
76
|
+
if (property.maximum !== undefined) {
|
|
77
|
+
formField.setAttribute('max', property.maximum.toString());
|
|
78
|
+
}
|
|
79
|
+
if (property.exclusiveMinimum !== undefined) {
|
|
80
|
+
formField.setAttribute('min', property.exclusiveMinimum.toString());
|
|
81
|
+
}
|
|
82
|
+
if (property.exclusiveMaximum !== undefined) {
|
|
83
|
+
formField.setAttribute('max', property.exclusiveMaximum.toString());
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
elementId(property) {
|
|
87
|
+
return `form-${property.name}`;
|
|
88
|
+
}
|
|
89
|
+
getFormElementType(property) {
|
|
90
|
+
if (property.isValueListProperty) {
|
|
91
|
+
return 'select';
|
|
92
|
+
}
|
|
93
|
+
if (property.isBooleanProperty) {
|
|
94
|
+
return 'checkbox';
|
|
95
|
+
}
|
|
96
|
+
return 'input';
|
|
97
|
+
}
|
|
98
|
+
getInputType(property) {
|
|
99
|
+
if (property.isNumericProperty) {
|
|
36
100
|
return 'number';
|
|
37
101
|
}
|
|
38
|
-
if (
|
|
39
|
-
|
|
102
|
+
if (property.isTemporalProperty) {
|
|
103
|
+
switch (property.format) {
|
|
104
|
+
case 'date':
|
|
105
|
+
return 'date';
|
|
106
|
+
case 'time':
|
|
107
|
+
return 'time';
|
|
108
|
+
case 'datetime':
|
|
109
|
+
case 'date-time':
|
|
110
|
+
return 'datetime-local';
|
|
111
|
+
default:
|
|
112
|
+
return 'text';
|
|
113
|
+
}
|
|
40
114
|
}
|
|
41
115
|
return 'text';
|
|
42
116
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
valid() {
|
|
47
|
-
return true;
|
|
117
|
+
isEmpty(property) {
|
|
118
|
+
const currentValue = this.getCurrentValue(property);
|
|
119
|
+
return property.isNullValue(currentValue);
|
|
48
120
|
}
|
|
49
121
|
getFormValues() {
|
|
50
122
|
if (!this.feature || !this.featureSchema) {
|
|
51
123
|
return {};
|
|
52
124
|
}
|
|
53
|
-
const properties = this.featureSchema.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const formField = this.getById(`form-${attrName}`);
|
|
57
|
-
let formValue = formField.value;
|
|
58
|
-
if (this.featureSchema.isNumericProperty(attrName)) {
|
|
59
|
-
if (formValue === '' || Number.isNaN(Number(formValue))) {
|
|
60
|
-
formValue = null;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
formValue = Number(formValue);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
properties[attrName] = formValue;
|
|
125
|
+
const properties = this.featureSchema.formDataTemplate;
|
|
126
|
+
for (const property of this.featureSchema.formProperties) {
|
|
127
|
+
properties[property.name] = this.getFormValue(property);
|
|
67
128
|
}
|
|
68
129
|
return properties;
|
|
69
130
|
}
|
|
131
|
+
getRawFormValue(property) {
|
|
132
|
+
const formField = this.getById(this.elementId(property));
|
|
133
|
+
if (formField?.type === 'checkbox') {
|
|
134
|
+
return formField?.checked ? 'true' : 'false';
|
|
135
|
+
}
|
|
136
|
+
return formField?.value;
|
|
137
|
+
}
|
|
138
|
+
getFormValue(property) {
|
|
139
|
+
const rawFormValue = this.getRawFormValue(property);
|
|
140
|
+
if (rawFormValue === undefined) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
if (property.isNumericProperty) {
|
|
144
|
+
return this.processNumericValue(rawFormValue, property);
|
|
145
|
+
}
|
|
146
|
+
else if (property.isTemporalProperty) {
|
|
147
|
+
return this.processTemporalValue(rawFormValue, property);
|
|
148
|
+
}
|
|
149
|
+
else if (property.isBooleanProperty) {
|
|
150
|
+
return rawFormValue === 'true';
|
|
151
|
+
}
|
|
152
|
+
else if (property.isValueListProperty) {
|
|
153
|
+
// Use loose equality because the dropdown value is always a string but the value in the value list could be a number
|
|
154
|
+
return property.valueListEntries?.find((entry) => entry.value == rawFormValue)?.value ?? null;
|
|
155
|
+
}
|
|
156
|
+
return rawFormValue === '' ? null : rawFormValue;
|
|
157
|
+
}
|
|
70
158
|
resetForm() {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
159
|
+
this.validationError = {};
|
|
160
|
+
this.dataIsModified = false;
|
|
161
|
+
}
|
|
162
|
+
validateForm() {
|
|
163
|
+
this.validationError = {};
|
|
164
|
+
if (!this.featureSchema || !this.feature) {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
for (const property of this.featureSchema.formProperties) {
|
|
168
|
+
this.validateField(property, true);
|
|
169
|
+
}
|
|
170
|
+
this.refreshRender();
|
|
171
|
+
return this.valid();
|
|
172
|
+
}
|
|
173
|
+
valid() {
|
|
174
|
+
return Object.keys(this.validationError).length === 0;
|
|
175
|
+
}
|
|
176
|
+
processNumericValue(rawFormValue, _property) {
|
|
177
|
+
if (rawFormValue === '' || Number.isNaN(Number(rawFormValue))) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
return Number(rawFormValue);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
processTemporalValue(rawFormValue, property) {
|
|
185
|
+
if (rawFormValue === '') {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
if (['datetime', 'date-time'].includes(property.format ?? '')) {
|
|
189
|
+
const previousValue = this.feature?.getProperties()[property.name] ?? null;
|
|
190
|
+
return DateUtils.fromLocalToApiDateTime(rawFormValue, previousValue);
|
|
191
|
+
}
|
|
192
|
+
if (property.format === 'date') {
|
|
193
|
+
return DateUtils.dateTimeStringToDate(rawFormValue);
|
|
194
|
+
}
|
|
195
|
+
return rawFormValue;
|
|
196
|
+
}
|
|
197
|
+
validateField(property, delayRendering = false) {
|
|
198
|
+
if (property.isReadOnly) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const formValue = this.getRawFormValue(property) ?? null;
|
|
202
|
+
const newErrors = this.schemaValidator.validate(property, formValue);
|
|
203
|
+
const previousErrors = this.validationError[property.name] ?? [];
|
|
204
|
+
const hasChanged = newErrors.length !== previousErrors.length || newErrors.some((err, idx) => err !== previousErrors[idx]);
|
|
205
|
+
if (hasChanged) {
|
|
206
|
+
if (newErrors.length > 0) {
|
|
207
|
+
this.validationError[property.name] = newErrors;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
delete this.validationError[property.name];
|
|
75
211
|
}
|
|
212
|
+
if (!delayRendering) {
|
|
213
|
+
this.refreshRender();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
fieldValueHasChanged(property) {
|
|
218
|
+
this.dataIsModified = true;
|
|
219
|
+
if (this.getFormElementType(property) === 'input') {
|
|
220
|
+
this.validateField(property);
|
|
221
|
+
// Inform parent component of change
|
|
222
|
+
this.createFormChangeEvent();
|
|
76
223
|
}
|
|
77
224
|
}
|
|
225
|
+
createFormChangeEvent() {
|
|
226
|
+
this.dispatchEvent(new CustomEvent(EditingFormChange, {
|
|
227
|
+
bubbles: true,
|
|
228
|
+
cancelable: true
|
|
229
|
+
}));
|
|
230
|
+
}
|
|
231
|
+
getCurrentValue(property) {
|
|
232
|
+
const value = this.feature?.getProperties()[property.name] ?? null;
|
|
233
|
+
if (property.isPrimaryKey) {
|
|
234
|
+
return this.feature?.getId() ?? null;
|
|
235
|
+
}
|
|
236
|
+
if (['datetime', 'date-time'].includes(property.format ?? '')) {
|
|
237
|
+
return DateUtils.fromApiToLocalDateTime(value, 'seconds');
|
|
238
|
+
}
|
|
239
|
+
if (property.format === 'date') {
|
|
240
|
+
return DateUtils.dateTimeStringToDate(value);
|
|
241
|
+
}
|
|
242
|
+
if (property.isValueListProperty) {
|
|
243
|
+
return this.fuzzyCompareForValueListEntry(property, value);
|
|
244
|
+
}
|
|
245
|
+
return value;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Depending on whether the value list is an enum, oneOf or foreign key, the feature may contain either the
|
|
249
|
+
* display title (label) or the raw value. We therefore use a fuzzy comparison against both title and value,
|
|
250
|
+
* including loose equality (==) to handle numbers represented as strings.
|
|
251
|
+
*/
|
|
252
|
+
fuzzyCompareForValueListEntry(property, value) {
|
|
253
|
+
return property.valueListEntries?.find((entry) => entry.title == value || entry.value == value)?.value ?? null;
|
|
254
|
+
}
|
|
78
255
|
connectedCallback() {
|
|
79
256
|
super.connectedCallback();
|
|
80
|
-
|
|
257
|
+
this.schemaValidator = new OgcApiFeaturesSchemaValidator(this.context);
|
|
258
|
+
this.render();
|
|
81
259
|
}
|
|
82
260
|
}
|
|
261
|
+
__decorate([
|
|
262
|
+
UsedInTemplateOnly()
|
|
263
|
+
], EditFormComponent.prototype, "getInputType", null);
|
|
@@ -1,31 +1,66 @@
|
|
|
1
1
|
/* SPDX-License-Identifier: Apache-2.0 */
|
|
2
|
-
.
|
|
3
|
-
border-top: var(--app-standard-border);
|
|
4
|
-
margin-top: 3rem;
|
|
5
|
-
}
|
|
6
|
-
.current-feature-row {
|
|
2
|
+
.attribute-form {
|
|
7
3
|
display: flex;
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: 0.8rem;
|
|
6
|
+
margin: 1rem 0;
|
|
7
|
+
color: var(--text-color);
|
|
10
8
|
}
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
#feature-id {
|
|
11
|
+
min-height: calc(var(--app-standard-height) / 1.5);
|
|
12
|
+
padding-left: 0.5rem;
|
|
13
|
+
align-content: center;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
.
|
|
16
|
+
.form-field {
|
|
17
|
+
gap: 0.3rem;
|
|
17
18
|
display: flex;
|
|
18
19
|
flex-direction: column;
|
|
19
|
-
gap: 0.5rem;
|
|
20
|
-
margin-top: 2rem;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
flex-direction: column;
|
|
26
|
-
gap: 0.5rem;
|
|
22
|
+
.form-field .gg-checkbox {
|
|
23
|
+
margin-left: 0;
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
label {
|
|
30
27
|
font-weight: bold;
|
|
31
28
|
}
|
|
29
|
+
|
|
30
|
+
.read-only-icon {
|
|
31
|
+
opacity: 0.5;
|
|
32
|
+
width: 1rem;
|
|
33
|
+
height: 1rem;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.is-required {
|
|
37
|
+
font-weight: bold;
|
|
38
|
+
font-size: 1.2rem;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.description {
|
|
42
|
+
font-style: italic;
|
|
43
|
+
color: var(--text-color-grad1);
|
|
44
|
+
max-width: 400px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.text-ellipsis {
|
|
48
|
+
overflow: hidden;
|
|
49
|
+
text-overflow: ellipsis;
|
|
50
|
+
width: 100%;
|
|
51
|
+
min-width: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
input:invalid {
|
|
55
|
+
border: var(--error-color) solid 2px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.validation-error {
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-direction: column;
|
|
61
|
+
gap: 0.25rem;
|
|
62
|
+
color: var(--error-color);
|
|
63
|
+
font-style: italic;
|
|
64
|
+
font-size: 0.8rem;
|
|
65
|
+
margin-bottom: 0.5rem;
|
|
66
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import Feature from 'ol/Feature.js';
|
|
2
|
+
import { OapifLayer } from '../../models/oapiflayer.js';
|
|
3
|
+
import { GgUserInteractionEvent } from '../../tools/state/userinteractionevent.js';
|
|
4
|
+
import IGirafeContext from '../../tools/context/icontext.js';
|
|
5
|
+
import { EditComponentState } from './editcomponentstate.js';
|
|
6
|
+
/**
|
|
7
|
+
* Helper class for map interactions in the edit component.
|
|
8
|
+
* Controls map interactions for selecting a feature, drawing, and modifying geometries.
|
|
9
|
+
*/
|
|
10
|
+
export default class GeometryEditingHelper {
|
|
11
|
+
private readonly context;
|
|
12
|
+
private readonly map;
|
|
13
|
+
private draw?;
|
|
14
|
+
private modify?;
|
|
15
|
+
private select?;
|
|
16
|
+
private selectionLayer?;
|
|
17
|
+
private drawingLayer?;
|
|
18
|
+
private drawingSource?;
|
|
19
|
+
private multiGeomDrawingFeature?;
|
|
20
|
+
private readonly originalGeometries;
|
|
21
|
+
geometryIsModified: boolean;
|
|
22
|
+
private readonly onSelectCallback;
|
|
23
|
+
private readonly onDrawCallback;
|
|
24
|
+
private readonly canExecuteCallback;
|
|
25
|
+
constructor(context: IGirafeContext, onSelectCallback: (features: Feature[]) => void, onDrawCallback: (feature: Feature) => void, canExecuteCallback: (action: GgUserInteractionEvent) => boolean);
|
|
26
|
+
updateMapInteractionsByState(editState: EditComponentState): void;
|
|
27
|
+
private disableAllMapInteractions;
|
|
28
|
+
private enableSelectFeatureInteraction;
|
|
29
|
+
private enableGeometryDrawingInteractions;
|
|
30
|
+
private enableGeometryModifyInteractions;
|
|
31
|
+
setupMapInteractions(layer: OapifLayer): void;
|
|
32
|
+
private setupSelectInteraction;
|
|
33
|
+
private setupDrawInteraction;
|
|
34
|
+
private setupModifyInteraction;
|
|
35
|
+
private addDrawingToMultiGeometry;
|
|
36
|
+
refreshLayers(): void;
|
|
37
|
+
reset(): void;
|
|
38
|
+
finishDrawing(): Feature | undefined;
|
|
39
|
+
revertModifications(): void;
|
|
40
|
+
setEditFeature(feature?: Feature | undefined): void;
|
|
41
|
+
getEditFeature(): Feature | undefined;
|
|
42
|
+
registerInteractions(componentName: string): void;
|
|
43
|
+
unregisterInteractions(componentName: string): void;
|
|
44
|
+
private createBaseStyle;
|
|
45
|
+
private createVertexStyle;
|
|
46
|
+
private getEditStyle;
|
|
47
|
+
}
|