[gnome-maps/wip/osm-edit: 14/47] osmApi: Refactor the code dealing with calling out to osmConnection to the manager
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/osm-edit: 14/47] osmApi: Refactor the code dealing with calling out to osmConnection to the manager
- Date: Thu, 30 Apr 2015 12:58:33 +0000 (UTC)
commit 37391036f961e947a23d8b67b39d5b57781740e1
Author: Marcus Lundblad <ml update uu se>
Date: Tue Feb 3 23:35:55 2015 +0100
osmApi: Refactor the code dealing with calling out to osmConnection to the manager
src/application.js | 3 ++
src/mapBubble.js | 29 +---------------------
src/osmEdit.js | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 72 insertions(+), 27 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 375633f..e9706c5 100644
--- a/src/application.js
+++ b/src/application.js
@@ -35,6 +35,7 @@ const GeocodeService = imports.geocodeService;
const MainWindow = imports.mainWindow;
const Maps = imports.gi.GnomeMaps;
const NotificationManager = imports.notificationManager;
+const OSMEdit = imports.osmEdit;
const PlaceStore = imports.placeStore;
const RouteService = imports.routeService;
const Settings = imports.settings;
@@ -51,6 +52,7 @@ let geocodeService = null;
let networkMonitor = null;
let checkInManager = null;
let contactStore = null;
+let osmEditManager = null;
const Application = new Lang.Class({
Name: 'Application',
@@ -202,6 +204,7 @@ const Application = new Lang.Class({
checkInManager = new CheckIn.CheckInManager();
contactStore = new Maps.ContactStore();
contactStore.load();
+ osmEditManager = new OSMEdit.OSMEditManager();
},
_createWindow: function() {
diff --git a/src/mapBubble.js b/src/mapBubble.js
index d77ba82..16fad99 100644
--- a/src/mapBubble.js
+++ b/src/mapBubble.js
@@ -180,35 +180,10 @@ const MapBubble = new Lang.Class({
_initEditButton: function(button) {
button.connect('clicked', (function() {
- // TODO: this should be handled in an "edit manager", something like for the
- // check in service above
print ('about to edit place: type: ' + this._place.osm_type + ' id: ' +
this._place.osm_id);
- let conn = new OSMConnection.OSMConnection();
- let osmType;
-
- switch (this._place.osm_type) {
- case 1:
- osmType = 'node';
- break;
- case 2:
- osmType = 'relation';
- break;
- case 3:
- osmType = 'way';
- break;
- default:
- debug ('Unknown OSM type: ' + this._place.osm_type);
- break;
- }
-
- conn.getOSMObject(osmType, this._place.osm_id,
- (function(success, status, data) {
- print('success: ' + success);
- print('status: ' + status);
- print('data: ' + data);
- }));
- }).bind(this));
+ Application.osmEditManager.initEditing(this.place);
+ }).bind(this));
}
});
diff --git a/src/osmEdit.js b/src/osmEdit.js
new file mode 100644
index 0000000..9f7ce66
--- /dev/null
+++ b/src/osmEdit.js
@@ -0,0 +1,67 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2015 Marcus Lundblad
+ *
+ * GNOME Maps is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * GNOME Maps is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with GNOME Maps; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author: Marcus Lundblad <ml update uu se>
+ */
+
+const GObject = imports.gi.GObject;
+const Lang = imports.lang;
+
+const OSMConnection = imports.osmConnection;
+
+const OSMEditManager = new Lang.Class({
+ Name: 'OSMEditManager',
+ Extends: GObject.Object,
+
+ _init: function() {
+ this._osmConnection = new OSMConnection.OSMConnection();
+ },
+
+ initEditing: function(place) {
+ let osmType = this._getOSMTypeName(place);
+
+ this._osmConnection.getOSMObject(osmType, place.osm_id,
+ (function(success, status, data) {
+ print('success: ' + success);
+ print('status: ' + status);
+ print('data: ' + data);
+ }));
+ },
+
+ _getOSMTypeName: function(place) {
+ let osmType;
+
+ switch (place.osm_type) {
+ case 1:
+ osmType = 'node';
+ break;
+ case 2:
+ osmType = 'relation';
+ break;
+ case 3:
+ osmType = 'way';
+ break;
+ default:
+ debug ('Unknown OSM type: ' + this._place.osm_type);
+ break;
+ }
+
+ return osmType;
+ }
+});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]