fixed 10640, 10639, 10625: Map point save HTML/JS

This commit is contained in:
Doug Bell 2009-08-20 18:51:39 +00:00
parent 2bbf81417b
commit a0d3eeaac8
7 changed files with 26 additions and 6 deletions

View file

@ -24,6 +24,9 @@
- fixed SMS/Email notification handling (Patrick Donelan, SDH Consulting)
- fixed #10624: map template problem with floats
- fixed #10793: Map->Add Point photo field missing
- fixed #10625: Map point no save button
- fixed #10639: Map: Can't edit or delete points
- fixed #10640: Map: points not working correctly
7.7.17
- fixed #10697: Story: Image crowds text

View file

@ -296,6 +296,10 @@ sub getTemplateVarsEditForm {
;
$var->{ form_footer } = WebGUI::Form::formFooter( $session );
$var->{ form_save } = WebGUI::Form::submit( $session, {
name => "save",
} );
# Stuff from this class's definition
my $definition = __PACKAGE__->definition($session)->[0]->{properties};
for my $key ( keys %{$definition} ) {

View file

@ -16,6 +16,7 @@ use strict;
use Tie::IxHash;
use WebGUI::International;
use WebGUI::Utility;
use HTML::Entities qw(encode_entities);
use base 'WebGUI::Asset::Wobject';
# To get an installer for your wobject, add the Installable AssetAspect
@ -520,6 +521,8 @@ sub www_ajaxEditPointSave {
my $form = $self->session->form;
my $i18n = WebGUI::International->new( $session, 'Asset_Map' );
# We're returning as HTML because application/json causes download pop-up
# and text/plain causes <pre>...</pre> in firefox
$session->http->setMimeType("text/html");
$session->log->preventDebugOutput;
@ -547,7 +550,8 @@ sub www_ajaxEditPointSave {
$asset->requestAutoCommit;
}
return JSON->new->encode($asset->getMapInfo);
# Encode entities because we're returning as HTML
return encode_entities( JSON->new->encode($asset->getMapInfo) );
}
#-------------------------------------------------------------------

View file

@ -51,8 +51,15 @@ WebGUI.Map.editPoint
// Callback should open the window with the form
var callback = function (text, code) {
marker.openInfoWindowHtml( text );
marker.infoWin.innerHTML = text;
var button = marker.infoWin.getElementsByTagName( "form" )[0].elements["save"];
marker.openInfoWindow( marker.infoWin );
YAHOO.util.Event.addListener( button, "click", function (e) {
// Closing the info window triggers infowindowbeforeclose
marker.closeInfoWindow();
YAHOO.util.Event.stopEvent(e);
return false;
} );
GEvent.addListener( marker, "infowindowbeforeclose", function () {
WebGUI.Map.editPointSave( map, mgr, mapUrl, marker );
});
@ -86,9 +93,11 @@ WebGUI.Map.editPointSave
GEvent.clearListeners( marker, "click" );
GEvent.clearListeners( marker, "infowindowbeforeclose" );
// Set the marker's title
marker.kh.title = point.title;
// I hate the google maps API.
// Decode HTML entities because JSON is being returned as text/html
// See WebGUI::Asset::Wobject::Map www_ajaxEditPointSave
var decoder = document.createElement( "textarea" );
decoder.innerHTML = point.content;
point.content = decoder.value;
var infoWin = document.createElement( "div" );
infoWin.innerHTML = point.content;