fixed: #10887: Map Point dropdown doesn't update
This commit is contained in:
parent
b24a3f4eb5
commit
b577b950e9
4 changed files with 93 additions and 28 deletions
|
|
@ -14,6 +14,7 @@
|
|||
- fixed #11116: Deleted user's version tags and revisions
|
||||
- fixed #11168: Points do not work with uncommitted Map
|
||||
- fixed #10888: Add Point... how do I enter details?
|
||||
- fixed #10887: Map Point dropdown doesn't update
|
||||
|
||||
7.8.2
|
||||
- Added scheduled vendor payout workflow activity. (Special thanks to Martin @ Oqapi)
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -388,6 +388,8 @@ sub view {
|
|||
var mapId = "%s";
|
||||
var mapUrl = "%s";
|
||||
var map = new GMap2( document.getElementById("map_" + mapId) );
|
||||
map.url = mapUrl;
|
||||
map.assetId = mapId;
|
||||
map.setCenter(new GLatLng(%s, %s), %s);
|
||||
map.setUIToDefault();
|
||||
map.extrasUrl = "%s";
|
||||
|
|
@ -414,7 +416,7 @@ ENDHTML
|
|||
}
|
||||
|
||||
$mapHtml .= <<'ENDHTML';
|
||||
markermanager.addMarkers( WebGUI.Map.preparePoints(map, markermanager, mapUrl, points), 0 );
|
||||
markermanager.addMarkers( WebGUI.Map.preparePoints(map, markermanager, points), 0 );
|
||||
ENDHTML
|
||||
}
|
||||
|
||||
|
|
@ -434,13 +436,13 @@ ENDHTML
|
|||
if ( document.getElementById( "setCenter_" + mapId ) ) {
|
||||
var button = document.getElementById( "setCenter_" + mapId );
|
||||
GEvent.addDomListener( button, "click", function () {
|
||||
WebGUI.Map.setCenter( map, mapUrl );
|
||||
WebGUI.Map.setCenter( map );
|
||||
} );
|
||||
}
|
||||
if ( document.getElementById( "addPoint_" + mapId ) ) {
|
||||
var button = document.getElementById( "addPoint_" + mapId );
|
||||
GEvent.addDomListener( button, "click", function () {
|
||||
WebGUI.Map.editPoint( map, markermanager, mapUrl );
|
||||
WebGUI.Map.editPoint( map, markermanager );
|
||||
} );
|
||||
}
|
||||
});
|
||||
|
|
@ -463,6 +465,18 @@ ENDHTML
|
|||
id => sprintf( 'setCenter_%s', $self->getId ),
|
||||
} );
|
||||
|
||||
# Select box to choose a map point
|
||||
tie my %selectPointOptions, 'Tie::IxHash', (
|
||||
"" => '-- ' . $i18n->get('select a point'),
|
||||
map { $_->{assetId} => $_->{title} } sort { $a->{title} cmp $b->{title} } @{$var->{mapPoints}},
|
||||
);
|
||||
$var->{ selectPoint }
|
||||
= WebGUI::Form::selectBox( $session, {
|
||||
extras => q{onchange="WebGUI.Map.focusOn(this.options[this.selectedIndex].value);"},
|
||||
id => sprintf( q{selectPoint_%s}, $self->getId ),
|
||||
options => \%selectPointOptions,
|
||||
} );
|
||||
|
||||
return $self->processTemplate( $var, undef, $self->{_viewTemplate} );
|
||||
}
|
||||
|
||||
|
|
|
|||
100
www/extras/yui-webgui/build/map/map.js
vendored
100
www/extras/yui-webgui/build/map/map.js
vendored
|
|
@ -7,38 +7,40 @@ if (typeof WebGUI.Map == "undefined") {
|
|||
}
|
||||
|
||||
// Keep track of all points on all maps and how to focus on them
|
||||
// A hash (map) of hashes (markers)
|
||||
WebGUI.Map.markers = {};
|
||||
|
||||
// Keep a loading dialog
|
||||
WebGUI.Map.loadingDialog = undefined;
|
||||
|
||||
/**
|
||||
* WebGUI.Map.deletePoint( map, mgr, mapUrl, marker )
|
||||
* WebGUI.Map.deletePoint( map, mgr, marker )
|
||||
* Delete a point from the map.
|
||||
* NOTE: We assume the user has already confirmed this action
|
||||
*/
|
||||
WebGUI.Map.deletePoint
|
||||
= function ( map, mgr, mapUrl, marker ) {
|
||||
= function ( map, mgr, marker ) {
|
||||
var callback = function ( text, code ) {
|
||||
WebGUI.Map.hideLoading();
|
||||
var response = YAHOO.lang.JSON.parse( text );
|
||||
// remove the marker from the map
|
||||
if ( !response.error ) {
|
||||
mgr.removeMarker( marker );
|
||||
delete WebGUI.Map.markers[ map.assetId ][ marker.assetId ];
|
||||
}
|
||||
};
|
||||
WebGUI.Map.showLoading();
|
||||
GDownloadUrl( mapUrl + '?func=ajaxDeletePoint;assetId=' + marker.assetId, callback);
|
||||
GDownloadUrl( map.url + '?func=ajaxDeletePoint;assetId=' + marker.assetId, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* WebGUI.Map.editPoint( map, mgr, mapUrl, marker )
|
||||
* WebGUI.Map.editPoint( map, mgr, marker )
|
||||
* Edit a point on the map.
|
||||
* up the edit box. mgr is the Marker Manager to add the marker
|
||||
* to. mapUrl is the URL of the map asset
|
||||
* to.
|
||||
*/
|
||||
WebGUI.Map.editPoint
|
||||
= function ( map, mgr, mapUrl, marker ) {
|
||||
= function ( map, mgr, marker ) {
|
||||
var assetId = '';
|
||||
if ( !marker ) {
|
||||
marker = new GMarker( map.getCenter(), { draggable: true } );
|
||||
|
|
@ -49,7 +51,7 @@ WebGUI.Map.editPoint
|
|||
assetId = "new";
|
||||
marker.assetId = "new";
|
||||
GEvent.addListener( marker, "dragend", function (latlng) {
|
||||
WebGUI.Map.setPointLocation( marker, latlng, mapUrl );
|
||||
WebGUI.Map.setPointLocation( marker, latlng );
|
||||
} );
|
||||
}
|
||||
else {
|
||||
|
|
@ -94,6 +96,7 @@ WebGUI.Map.editPoint
|
|||
// Update marker info
|
||||
var point = YAHOO.lang.JSON.parse( o.responseText );
|
||||
marker.assetId = point.assetId;
|
||||
marker.title = point.title;
|
||||
GEvent.clearListeners( marker, "click" );
|
||||
GEvent.clearListeners( marker, "infowindowbeforeclose" );
|
||||
|
||||
|
|
@ -115,7 +118,7 @@ WebGUI.Map.editPoint
|
|||
editButton.type = "button";
|
||||
editButton.value = "Edit";
|
||||
GEvent.addDomListener( editButton, "click", function () {
|
||||
WebGUI.Map.editPoint( map, mgr, mapUrl, marker );
|
||||
WebGUI.Map.editPoint( map, mgr, marker );
|
||||
} );
|
||||
divButton.appendChild( editButton );
|
||||
|
||||
|
|
@ -124,16 +127,19 @@ WebGUI.Map.editPoint
|
|||
deleteButton.value = "Delete"; // Replace with i18n
|
||||
GEvent.addDomListener( deleteButton, "click", function () {
|
||||
if ( confirm("Are you sure you want to delete this point?") ) {
|
||||
WebGUI.Map.deletePoint( map, mgr, mapUrl, marker );
|
||||
WebGUI.Map.deletePoint( map, mgr, marker );
|
||||
}
|
||||
} );
|
||||
divButton.appendChild( deleteButton );
|
||||
}
|
||||
marker.bindInfoWindow( infoWin );
|
||||
GEvent.addListener( marker, "dragend", function (latlng) {
|
||||
WebGUI.Map.setPointLocation( marker, latlng, mapUrl );
|
||||
WebGUI.Map.setPointLocation( marker, latlng );
|
||||
} );
|
||||
WebGUI.Map.hideLoading();
|
||||
|
||||
WebGUI.Map.markers[map.assetId][marker.assetId] = marker;
|
||||
WebGUI.Map.updateSelectPoint( map );
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -145,21 +151,27 @@ WebGUI.Map.editPoint
|
|||
WebGUI.Map.showLoading();
|
||||
|
||||
// Get the form
|
||||
GDownloadUrl( mapUrl + '?func=ajaxEditPoint;assetId=' + assetId, callback );
|
||||
GDownloadUrl( map.url + '?func=ajaxEditPoint;assetId=' + assetId, callback );
|
||||
};
|
||||
|
||||
/**
|
||||
* WebGUI.Map.focusOn( assetId )
|
||||
* WebGUI.Map.focusOn( pointId )
|
||||
* Pan the appropriate map to view the appropriate map point
|
||||
*/
|
||||
WebGUI.Map.focusOn
|
||||
= function ( assetId ) {
|
||||
var marker = WebGUI.Map.markers[assetId];
|
||||
= function ( pointId ) {
|
||||
var marker;
|
||||
for ( var mapId in WebGUI.Map.markers ) {
|
||||
if ( WebGUI.Map.markers[mapId][pointId] ) {
|
||||
marker = WebGUI.Map.markers[mapId][pointId];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !marker ) return;
|
||||
var map = marker.map;
|
||||
var infoWin = marker.infoWin;
|
||||
if ( map.getZoom() < 5 ) {
|
||||
map.setZoom(6);
|
||||
if ( map.getZoom() <= 4 ) {
|
||||
map.setZoom(5);
|
||||
}
|
||||
map.panTo( marker.getLatLng() );
|
||||
marker.openInfoWindow( marker.infoWin );
|
||||
|
|
@ -171,11 +183,13 @@ WebGUI.Map.hideLoading
|
|||
};
|
||||
|
||||
/**
|
||||
* WebGUI.Map.preparePoints ( map, mgr, mapUrl, points )
|
||||
* WebGUI.Map.preparePoints ( map, mgr, points )
|
||||
* Prepare the points from WebGUI into Google Map GMarkers
|
||||
*/
|
||||
WebGUI.Map.preparePoints
|
||||
= function ( map, mgr, mapUrl, points ) {
|
||||
= function ( map, mgr, points ) {
|
||||
WebGUI.Map.markers[map.assetId] = {};
|
||||
|
||||
// Transform points into markers
|
||||
var markers = [];
|
||||
for ( var i = 0; i < points.length; i++ ) (function(i){ // Create closure for callbacks
|
||||
|
|
@ -186,6 +200,7 @@ WebGUI.Map.preparePoints
|
|||
draggable: point.canEdit
|
||||
} );
|
||||
marker.assetId = point.assetId;
|
||||
marker.title = point.title;
|
||||
marker.map = map;
|
||||
|
||||
// Create info window
|
||||
|
|
@ -201,7 +216,7 @@ WebGUI.Map.preparePoints
|
|||
editButton.type = "button";
|
||||
editButton.value = "Edit"; // Replace with i18n
|
||||
GEvent.addDomListener( editButton, "click", function () {
|
||||
WebGUI.Map.editPoint( map, mgr, mapUrl, marker );
|
||||
WebGUI.Map.editPoint( map, mgr, marker );
|
||||
} );
|
||||
divButton.appendChild( editButton );
|
||||
|
||||
|
|
@ -210,19 +225,19 @@ WebGUI.Map.preparePoints
|
|||
deleteButton.value = "Delete"; // Replace with i18n
|
||||
GEvent.addDomListener( deleteButton, "click", function () {
|
||||
if ( confirm("Are you sure you want to delete this point?") ) {
|
||||
WebGUI.Map.deletePoint( map, mgr, mapUrl, marker );
|
||||
WebGUI.Map.deletePoint( map, mgr, marker );
|
||||
}
|
||||
} );
|
||||
divButton.appendChild( deleteButton );
|
||||
|
||||
infoWin.appendChild( divButton );
|
||||
GEvent.addListener( marker, "dragend", function (latlng) {
|
||||
WebGUI.Map.setPointLocation( marker, latlng, mapUrl );
|
||||
WebGUI.Map.setPointLocation( marker, latlng );
|
||||
} );
|
||||
}
|
||||
|
||||
// Keep info
|
||||
WebGUI.Map.markers[point.assetId] = marker;
|
||||
WebGUI.Map.markers[map.assetId][point.assetId] = marker;
|
||||
|
||||
marker.bindInfoWindow( infoWin );
|
||||
|
||||
|
|
@ -254,12 +269,12 @@ WebGUI.Map.setCenter
|
|||
};
|
||||
|
||||
/**
|
||||
* WebGUI.Map.setPointLocation( marker, latlng, mapUrl, assetId )
|
||||
* WebGUI.Map.setPointLocation( marker, latlng )
|
||||
* Update the point's location in the database.
|
||||
*/
|
||||
WebGUI.Map.setPointLocation
|
||||
= function ( marker, latlng, mapUrl, assetId ) {
|
||||
var url = mapUrl + '?func=ajaxSetPointLocation'
|
||||
= function ( marker, latlng ) {
|
||||
var url = marker.map.url + '?func=ajaxSetPointLocation'
|
||||
+ ';assetId=' + marker.assetId
|
||||
+ ';latitude=' + latlng.lat()
|
||||
+ ';longitude=' + latlng.lng()
|
||||
|
|
@ -294,3 +309,38 @@ WebGUI.Map.showLoading
|
|||
|
||||
WebGUI.Map.loadingDialog.show();
|
||||
};
|
||||
|
||||
|
||||
WebGUI.Map.updateSelectPoint
|
||||
= function (map) {
|
||||
var select = document.getElementById( 'selectPoint_' + map.assetId );
|
||||
if ( !select) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear old points
|
||||
while ( select.options.length > 1 ) {
|
||||
select.length = 1;
|
||||
}
|
||||
|
||||
var markers = WebGUI.Map.markers[map.assetId];
|
||||
var sorted = [];
|
||||
for ( var pointId in markers ) {
|
||||
sorted.push( pointId );
|
||||
}
|
||||
|
||||
sorted.sort( function (a,b) {
|
||||
var ma = WebGUI.Map.markers[map.assetId][a];
|
||||
var mb = WebGUI.Map.markers[map.assetId][b];
|
||||
|
||||
if ( ma.title > mb.title ) { return 1; }
|
||||
else if ( ma.title < mb.title ) { return -1; }
|
||||
else { return 0; }
|
||||
} );
|
||||
|
||||
// Add new points
|
||||
for ( var i = 0; i < sorted.length; i++ ) {
|
||||
select.options[ select.options.length ]
|
||||
= new Option( markers[sorted[i]].title, sorted[i] );
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue