diff --git a/src/app/pages/portal/portal.component.ts b/src/app/pages/portal/portal.component.ts index 172e50cd7..83e640062 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,32 @@ 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 = { - type: 'Feature', - properties: {} - }; - feature.properties = this.createFeatureProperties(workspace.layer); this.workspaceState.rowsInMapExtentCheckCondition$.next(false); - workspace.editFeature(feature, workspace); + workspace.createFeature(); } createFeatureProperties(layer: ImageLayer | VectorLayer) { let properties = {}; layer.options.sourceOptions.sourceFields.forEach((field) => { - if (!field.primary && field.visible) { + if (!field.primary) { properties[field.name] = ''; } }); 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",