[Mapbender-commits] r5438 - trunk/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Jan 27 08:19:56 EST 2010


Author: christoph
Date: 2010-01-27 08:19:51 -0500 (Wed, 27 Jan 2010)
New Revision: 5438

Modified:
   trunk/mapbender/http/javascripts/map.php
   trunk/mapbender/http/javascripts/mod_digitize_tab.php
Log:
workaround for sync issues with frames

Modified: trunk/mapbender/http/javascripts/map.php
===================================================================
--- trunk/mapbender/http/javascripts/map.php	2010-01-27 11:18:05 UTC (rev 5437)
+++ trunk/mapbender/http/javascripts/map.php	2010-01-27 13:19:51 UTC (rev 5438)
@@ -252,7 +252,7 @@
 
 	// initialisation
 	Mapbender.events.init.trigger();
-	
+	Mapbender.events.init.done = true;
 	Mapbender.events.afterInit.trigger();
 	
 });

Modified: trunk/mapbender/http/javascripts/mod_digitize_tab.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_digitize_tab.php	2010-01-27 11:18:05 UTC (rev 5437)
+++ trunk/mapbender/http/javascripts/mod_digitize_tab.php	2010-01-27 13:19:51 UTC (rev 5438)
@@ -106,7 +106,8 @@
 };
 
 var digitizeHistory = new DigitizeHistory();
-parent.eventInit.register(function () {
+
+var registerAnotherFunction = function () {
 	var mapIndex = parent.getMapObjIndexByName(mod_digitize_target);
 	mapDomElement = parent.mb_mapObj[mapIndex].getDomElement();
 	mapType = mapDomElement.tagName.toUpperCase();
@@ -151,7 +152,7 @@
 
 	parent.Mapbender.modules[mod_digitize_elName].cancelAjaxRequest = false;
 	parent.Mapbender.modules[mod_digitize_elName].cancelAjaxRequestMessage = "An error occured.";
-});
+};
 
 
 <?php
@@ -820,6 +821,20 @@
 	}
 }
 
+function completeInitialization() {
+	registerAnotherFunction();
+	initializeDigitize();
+	setStyleForTargetFrame();
+	checkDigitizeTag();
+	initialiseSnapping();
+//		appendGeometryArrayFromKML();
+	if (!nonTransactionalEditable) {
+		initialiseHighlight();
+	}
+	initialiseMeasure();
+	getMessages();
+}
+
 function registerFunctions(){
 	mod_digitizePreFunctions = [];
 	mod_digitizeSubFunctions = [];
@@ -827,18 +842,16 @@
 	registerDigitizePreFunctions("drawDashedLine()");
 	registerDigitizeSubFunctions("updateListOfGeometries()");
 	registerDigitizeSubFunctions("drawDashedLine()");
-	parent.eventInit.register(function () {
-		initializeDigitize();
-		setStyleForTargetFrame();
-		checkDigitizeTag();
-		initialiseSnapping();
-//		appendGeometryArrayFromKML();
-		if (!nonTransactionalEditable) {
-			initialiseHighlight();
-		}
-		initialiseMeasure();
-		getMessages();
-	});
+
+
+	if (parent.Mapbender.events.init.done) {
+		completeInitialization();
+		alert("done");
+	}
+	else {
+		alert("registering");
+		parent.Mapbender.events.init.register(completeInitialization);
+	}
 	parent.eventLocalize.register(function() {
 		getMessages();
 	});
@@ -1201,11 +1214,14 @@
 					d.get(-1).wfs_conf = wfsConfId;
 					var wfsProperties = d.get(0).e;
 
-					for (var i = 0; i < wfsProperties.count(); i++) {
-						if (wfsProperties.getName(i) === "fid") {
+					for (var j = 0; j < wfsProperties.count(); j++) {
+						if (i > 0 && wfsProperties.getName(j) === "fid") {
 							continue;
 						}
-						d.get(-1).e.setElement(wfsProperties.getName(i), wfsProperties.getValue(i));
+						d.get(-1).e.setElement(
+							wfsProperties.getName(j), 
+							wfsProperties.getValue(j)
+						);
 					}
 				}
 				// remove the original geometry and the temporary line
@@ -1526,7 +1542,8 @@
 		wfsConf = parent.get_complete_wfs_conf();
 		for (var i = 0 ; i < d.count(); i ++) {
 
-			if (d.get(i).get(-1).isComplete() && (nonTransactionalEditable || isTransactional(d.get(i)))) {
+//			if (d.get(i).get(-1).isComplete() && (nonTransactionalEditable || isTransactional(d.get(i)))) {
+			if ((nonTransactionalEditable || isTransactional(d.get(i)))) {
 	
 				// for the geometries from a kml, there is another save dialogue
 				if (d.get(i).isFromKml()) {
@@ -1540,7 +1557,7 @@
 				else {
 					// button: geometry information, save, update, delete
 					listOfGeom += "<li>";
-					if (wfsExistsForGeom(d.get(i), wfsConf)) {
+					if (d.get(i).get(-1).isComplete() && wfsExistsForGeom(d.get(i), wfsConf)) {
 						listOfGeom += "<img src = '"+buttonDig_imgdir+buttonDig_wfs_src+"' title='"+msgObj.buttonDig_wfs_title+"' onclick='showWfs("+i+")'>";
 					}
 
@@ -1548,7 +1565,7 @@
 					listOfGeom += "<img src = '"+buttonDig_imgdir+buttonDig_remove_src+"' title='"+msgObj.buttonDig_remove_title+"' onclick='parent.mb_disableThisButton(mod_digitizeEvent);d.del("+i+");executeDigitizeSubFunctions();'>";
 
 					// button clone this geometry
-					if (addCloneGeometryButton === true) {
+					if (d.get(i).get(-1).isComplete() && addCloneGeometryButton === true) {
 						listOfGeom += "<img src = '"+buttonDig_imgdir+buttonDig_clone_src+"' title='"+msgObj.buttonDig_clone_title+"' onclick='d.addCopy(d.get("+i+"));d.get(-1).e.delElement(\"fid\");eventCloseGeometry.trigger({index: d.count() - 1, geometry: d.get(-1)});executeDigitizeSubFunctions();'>";
 					}
 				}
@@ -1875,7 +1892,8 @@
 function showWfs(geometryIndex) {
 	var res = true;	
 	res = parent.Mapbender.modules[mod_digitize_elName].events.openDialog.trigger({
-		geometryIndex: geometryIndex	
+		geometryIndex: geometryIndex,
+		feature: d.get(geometryIndex)
 	});
 	if (res === false) {
 		return;	
@@ -2304,15 +2322,16 @@
 	return str;
 }
 
-function dbGeom(type, m, callback, wfsConfId) {
+function dbGeom(type, m, callback, dbWfsConfId) {
+	if (typeof dbWfsConfId !== "undefined") {
+		d.get(m).wfs_conf = getJsWfsConfIdByDbWfsConfId(wfsConf, dbWfsConfId);
+		d.get(m).e = new parent.Wfs_element();
+	}
+
 	var hasFid = d.get(m).e.getElementValueByName("fid") !== false;
 
 	if (!hasFid) {
-		if (typeof wfsConfId !== "undefined") {
-			d.get(m).wfs_conf = wfsConfId;
-			d.get(m).e = new parent.Wfs_element();
-		}
-		else if (typeof(wfsWindow) != 'undefined' && !wfsWindow.closed) {
+		if (typeof(wfsWindow) != 'undefined' && !wfsWindow.closed) {
 			d.get(m).wfs_conf = parseInt(wfsWindow.document.forms[0].wfs.options[wfsWindow.document.forms[0].wfs.selectedIndex].value);
 			d.get(m).e = new parent.Wfs_element();
 		}
@@ -2417,6 +2436,15 @@
 	}
 }
 
+function getJsWfsConfIdByDbWfsConfId (wfsConf, id) {
+	for (var i = 0; i < wfsConf.length; i++) {
+		if (parseInt(wfsConf[i].wfs_conf_id, 10) === id) {
+			return i
+		}
+	}
+	return null;
+}
+
 function wfsSubWrite(m, type, status, success, fid, callback) {
 	if (status == "success" && success) {
 		if (type == 'insert' && fid) {
@@ -2441,15 +2469,14 @@
 			callback();		
 	}
 
-	executeDigitizeSubFunctions();
-
 	if (typeof(wfsWindow) != 'undefined' && !wfsWindow.closed) {
 		if (status !== "success" || !success) {
 			wfsWindow.alert(wfsWriteMessage);
 		}
 		else {
 			parent.Mapbender.modules[mod_digitize_elName].events.geometryInserted.trigger({
-				fid: fid
+				fid: fid,
+				feature: d.get(m)
 			});
 			new parent.Mb_notice(wfsWriteMessage);
 		}
@@ -2461,12 +2488,15 @@
 		}
 		else {
 			parent.Mapbender.modules[mod_digitize_elName].events.geometryInserted.trigger({
-				fid: fid
+				fid: fid,
+				feature: d.get(m)
 			});
 			new parent.Mb_notice(wfsWriteMessage);
 		}
 	}
+	executeDigitizeSubFunctions();
 }
+
 function getMultiGeometryIdsByPlacemarkId (placemarkId) {
 	var multiGeometryIdArray = [];
 	for (var i = 0; i < d.count(); i++) {
@@ -2546,6 +2576,6 @@
 		<img id="digitizeForward" style="position:absolute;top:28;left:112" src="../img/button_digitize/forward_on.png" title="" onclick="digitizeHistory.forward()" name="digitizeForward"/>
  -->
 		<div id='digButtons'></div>
-		<div id='listOfGeometries' class='digitizeGeometryList'></div>
+		<div style='position:absolute;top:60px;left:5px' id='listOfGeometries' class='digitizeGeometryList'></div>
 	</body>
 </html>



More information about the Mapbender_commits mailing list