fix Map/MapPoint editing
This commit is contained in:
parent
d86381d440
commit
4bcd1e3976
3 changed files with 169 additions and 12 deletions
|
|
@ -273,15 +273,13 @@ sub getTemplateVarsEditForm {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
# Stuff from this class's definition
|
# Stuff from this class's definition
|
||||||
my $definition = __PACKAGE__->definition($session)->[0]->{properties};
|
foreach my $key ( $self->getProperties ) {
|
||||||
for my $key ( keys %{$definition} ) {
|
my $fieldHash = $self->getFieldData( $key );
|
||||||
next if $definition->{$key}->{noFormPost};
|
next if $fieldHash->{noFormPost};
|
||||||
next if $key eq 'latitude'
|
next if $key eq 'latitude'
|
||||||
|| $key eq 'longitude';
|
|| $key eq 'longitude';
|
||||||
$definition->{$key}->{name} = $key;
|
|
||||||
$definition->{$key}->{value} = $self->$key;
|
|
||||||
$var->{ "form_$key" }
|
$var->{ "form_$key" }
|
||||||
= WebGUI::Form::dynamicField( $session, %{$definition->{$key}} );
|
= WebGUI::Form::dynamicField( $session, $fieldHash );
|
||||||
}
|
}
|
||||||
|
|
||||||
# Stuff from Asset
|
# Stuff from Asset
|
||||||
|
|
@ -325,9 +323,8 @@ sub processAjaxEditForm {
|
||||||
my $prop = {};
|
my $prop = {};
|
||||||
|
|
||||||
# Stuff from this class's definition
|
# Stuff from this class's definition
|
||||||
my $definition = __PACKAGE__->definition($session)->[0]->{properties};
|
for my $key ( $self->getProperties ) {
|
||||||
for my $key ( keys %{$definition} ) {
|
my $field = $self->getFieldData( $key );
|
||||||
my $field = $definition->{$key};
|
|
||||||
next if $field->{noFormPost};
|
next if $field->{noFormPost};
|
||||||
$prop->{$key}
|
$prop->{$key}
|
||||||
= $form->get($key,$field->{fieldType},$field->{defaultValue},$field);
|
= $form->get($key,$field->{fieldType},$field->{defaultValue},$field);
|
||||||
|
|
|
||||||
|
|
@ -549,9 +549,10 @@ sub www_ajaxEditPointSave {
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$asset = WebGUI::Asset->newById( $session, $assetId );
|
eval { $asset = WebGUI::Asset->newById( $session, $assetId ) };
|
||||||
return JSON->new->encode({message => $i18n->get("error edit unauthorized")})
|
if ( $@ || !$asset || !$asset->canEdit ) {
|
||||||
unless $asset && $asset->canEdit;
|
return JSON->new->encode({message => $i18n->get("error edit unauthorized")});
|
||||||
|
}
|
||||||
$asset = $asset->addRevision;
|
$asset = $asset->addRevision;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Try::Tiny;
|
use Try::Tiny;
|
||||||
use File::Spec::Functions qw(catfile);
|
use File::Spec::Functions qw(catfile);
|
||||||
|
use JSON;
|
||||||
|
|
||||||
use WebGUI::Paths;
|
use WebGUI::Paths;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
|
|
@ -249,6 +250,164 @@ my $DT_NOW = DateTime->now;
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
'WebGUI::Asset::Wobject::DataForm' => [
|
||||||
|
{
|
||||||
|
title => 'Data Form',
|
||||||
|
isHidden => 1,
|
||||||
|
defaultView => 0,
|
||||||
|
useCaptcha => 1,
|
||||||
|
templateId => 'PBtmpl0000000000000141', # Default dataform
|
||||||
|
fieldConfiguration => JSON->new->encode( [
|
||||||
|
{
|
||||||
|
name => "from",
|
||||||
|
label => 'From',
|
||||||
|
status => "required",
|
||||||
|
type => "email",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name => 'subject',
|
||||||
|
label => 'Subject',
|
||||||
|
status => 'required',
|
||||||
|
type => 'text',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name => 'date',
|
||||||
|
label => 'Date',
|
||||||
|
status => 'editable',
|
||||||
|
type => 'date',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name => 'body',
|
||||||
|
label => 'Body',
|
||||||
|
status => 'editable',
|
||||||
|
type => 'textarea',
|
||||||
|
},
|
||||||
|
] ),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title => 'Data Form (list)',
|
||||||
|
defaultView => 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title => 'Data Form (tabbed)',
|
||||||
|
defaultView => 0,
|
||||||
|
templateId => 'PBtmpl0000000000000116', # Tab form
|
||||||
|
fieldConfiguration => JSON->new->encode( [
|
||||||
|
{
|
||||||
|
name => "from",
|
||||||
|
label => 'From',
|
||||||
|
status => "required",
|
||||||
|
type => "email",
|
||||||
|
tabId => 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name => 'subject',
|
||||||
|
label => 'Subject',
|
||||||
|
status => 'required',
|
||||||
|
type => 'text',
|
||||||
|
tabId => 'one',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name => 'date',
|
||||||
|
label => 'Date',
|
||||||
|
status => 'editable',
|
||||||
|
type => 'date',
|
||||||
|
tabId => 'one',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name => 'body',
|
||||||
|
label => 'Body',
|
||||||
|
status => 'editable',
|
||||||
|
type => 'textarea',
|
||||||
|
tabId => 'two',
|
||||||
|
},
|
||||||
|
] ),
|
||||||
|
tabConfiguration => JSON->new->encode( [
|
||||||
|
{
|
||||||
|
tabId => 'one',
|
||||||
|
label => "One",
|
||||||
|
subtext => "The oneth page",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
tabId => 'two',
|
||||||
|
label => 'Two',
|
||||||
|
subtext => 'The twoth page',
|
||||||
|
},
|
||||||
|
] ),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'WebGUI::Asset::Wobject::DataTable' => [
|
||||||
|
{
|
||||||
|
title => 'DataTable (YUI)',
|
||||||
|
isHidden => 1,
|
||||||
|
templateId => '3rjnBVJRO6ZSkxlFkYh_ug',
|
||||||
|
data => JSON->new->encode( {
|
||||||
|
columns => [
|
||||||
|
{
|
||||||
|
key => 'ID',
|
||||||
|
formatter => 'text',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key => 'Name',
|
||||||
|
formatter => 'text',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key => 'URL',
|
||||||
|
formatter => 'link',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
rows => [
|
||||||
|
{
|
||||||
|
ID => '1',
|
||||||
|
Name => 'WebGUI',
|
||||||
|
URL => 'http://webgui.org',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID => '2',
|
||||||
|
Name => 'Plain Black Corp.',
|
||||||
|
URL => 'http://plainblack.com',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
} ),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title => 'DataTable (HTML)',
|
||||||
|
templateId => 'TuYPpHx7TUyk08639Pc8Bg',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'WebGUI::Asset::Wobject::Map' => [
|
||||||
|
{
|
||||||
|
title => 'Map',
|
||||||
|
mapApiKey => 'ABQIAAAAxadBCYjK6rRsw7rJkBgiEBT7g5bZECU_gqoByQmzcFSTeCxKshSKEU-GQYssxXNgQ1qkA3XtjOGYog',
|
||||||
|
# Key only works for "localhost:5000"
|
||||||
|
startLatitude => '43.068888',
|
||||||
|
startLongitude => '-89.384251',
|
||||||
|
startZoom => '6',
|
||||||
|
_children => [
|
||||||
|
{
|
||||||
|
className => 'WebGUI::Asset::MapPoint',
|
||||||
|
title => 'Lake Poygan',
|
||||||
|
latitude => '44.166445',
|
||||||
|
longitude => '-88.791504',
|
||||||
|
description => 'I have never heard of this place before',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
className => 'WebGUI::Asset::MapPoint',
|
||||||
|
title => 'Chicago',
|
||||||
|
latitude => '41.885921',
|
||||||
|
longitude => '-87.670898',
|
||||||
|
description => 'Best pizza in the world',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
className => 'WebGUI::Asset::MapPoint',
|
||||||
|
title => 'Dubuque',
|
||||||
|
latitude => '42.569264',
|
||||||
|
longitude => '-90.725098',
|
||||||
|
description => 'At the corner of three states',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
sub getPropertySets {
|
sub getPropertySets {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue