From 97a72d1a202df3860b2e3ac760926e4bcbb1ca1f Mon Sep 17 00:00:00 2001 From: Olivier Saint-Cyr Date: Wed, 17 Apr 2024 14:36:26 -0400 Subject: [PATCH 1/3] feat(edition): add feature --- src/app/pages/portal/portal.component.ts | 31 +++++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/app/pages/portal/portal.component.ts b/src/app/pages/portal/portal.component.ts index 172e50cd7..2d0c977aa 100644 --- a/src/app/pages/portal/portal.component.ts +++ b/src/app/pages/portal/portal.component.ts @@ -96,6 +96,7 @@ import { sourceCanReverseSearch, sourceCanSearch } from '@igo2/geo'; +import { NewEditionWorkspace } from '@igo2/geo'; import { AnalyticsListenerService, ContextState, @@ -636,26 +637,38 @@ export class PortalComponent implements OnInit, OnDestroy { } isEditionWorkspace(workspace) { + return ( + workspace instanceof EditionWorkspace || + workspace instanceof NewEditionWorkspace + ); + } + + addFeature(workspace: EditionWorkspace | NewEditionWorkspace) { if (workspace instanceof EditionWorkspace) { - return true; + let feature = { + type: 'Feature', + properties: {} + }; + feature.properties = this.createFeatureProperties(workspace.layer); + this.workspaceState.rowsInMapExtentCheckCondition$.next(false); + workspace.editFeature(feature, workspace); + return; } - return false; - } - addFeature(workspace: EditionWorkspace) { - let feature = { + const feature = { type: 'Feature', - properties: {} + properties: this.createFeatureProperties(workspace.layer) }; - feature.properties = this.createFeatureProperties(workspace.layer); + this.workspaceState.rowsInMapExtentCheckCondition$.next(false); - workspace.editFeature(feature, workspace); + workspace.createFeature(feature); } createFeatureProperties(layer: ImageLayer | VectorLayer) { let properties = {}; + console.log('source fields', layer.options.sourceOptions.sourceFields); layer.options.sourceOptions.sourceFields.forEach((field) => { - if (!field.primary && field.visible) { + if (!field.primary) { properties[field.name] = ''; } }); From 6ded4a7a2ec68256c95d9183c6b950d554507e84 Mon Sep 17 00:00:00 2001 From: Olivier Saint-Cyr Date: Fri, 19 Apr 2024 14:17:06 -0400 Subject: [PATCH 2/3] refactor(workspace-edition): add feature --- src/app/pages/portal/portal.component.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/app/pages/portal/portal.component.ts b/src/app/pages/portal/portal.component.ts index 2d0c977aa..83e640062 100644 --- a/src/app/pages/portal/portal.component.ts +++ b/src/app/pages/portal/portal.component.ts @@ -655,18 +655,12 @@ export class PortalComponent implements OnInit, OnDestroy { return; } - const feature = { - type: 'Feature', - properties: this.createFeatureProperties(workspace.layer) - }; - this.workspaceState.rowsInMapExtentCheckCondition$.next(false); - workspace.createFeature(feature); + workspace.createFeature(); } createFeatureProperties(layer: ImageLayer | VectorLayer) { let properties = {}; - console.log('source fields', layer.options.sourceOptions.sourceFields); layer.options.sourceOptions.sourceFields.forEach((field) => { if (!field.primary) { properties[field.name] = ''; From f41a07d98238ccc8b2d0c7d7995697c22e5db904 Mon Sep 17 00:00:00 2001 From: Olivier Saint-Cyr Date: Wed, 24 Apr 2024 10:22:43 -0400 Subject: [PATCH 3/3] edition config --- src/config/config.json | 2 +- src/contexts/_base.json | 49 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/config/config.json b/src/config/config.json index ca6c7ad85..0d2d70f84 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -49,7 +49,7 @@ "nbVisitToShowAgain": 30 }, "edition": { - "url": "/apis/inedit/" + "url": "http://localhost/" }, "wakeLockApiButton": false, "offlineButton": false, diff --git a/src/contexts/_base.json b/src/contexts/_base.json index 7020af950..aea6f1cf7 100644 --- a/src/contexts/_base.json +++ b/src/contexts/_base.json @@ -9,6 +9,55 @@ } }, "layers": [ + { + "title": "Montreal Parking Terminals", + "id": "parking", + "visible": true, + "editable": true, + "sourceOptions": { + "queryable": true, + "params": { + "featureTypes": "parking", + "fieldNameGeometry": "msGeometry", + "maxFeatures": 10000, + "version": "1.0.0" + }, + "edition": { + "enabled": true, + "baseUrl": "parking_terminal_on_roads", + "addUrl": "", + "deleteUrl": "?id=eq.", + "modifyUrl": "?id=eq.", + "geomType": "Point", + "modifyButton": true, + "addWithDraw": false, + "hasGeometry": false + }, + "sourceFields": [ + { + "name": "id", + "primary": true, + "validation": { + "readonly": true + } + }, + { + "name": "status" + }, + { + "name": "roadname" + }, + { + "name": "exploitationtype" + }, + { + "name": "zonegroupcode" + } + ], + "type": "wfs", + "url": "http://localhost:8080/?map=/etc/mapserver/parking.map" + } + }, { "id": "fond_osm", "title": "Open Street Map",