Fix bugs in how Thingy handles displaying dates to the user in view and search modes.
This commit is contained in:
parent
eceeff448a
commit
536ac6cdc7
2 changed files with 48 additions and 25 deletions
|
|
@ -892,10 +892,10 @@ sub getFieldValue {
|
||||||
my $processedValue = $value;
|
my $processedValue = $value;
|
||||||
my $dbh = $self->session->db->dbh;
|
my $dbh = $self->session->db->dbh;
|
||||||
|
|
||||||
if ($field->{fieldType} eq "date"){
|
if (lc $field->{fieldType} eq "date"){
|
||||||
$processedValue = $self->session->datetime->epochToHuman($value,$dateFormat);
|
$processedValue = $self->session->datetime->epochToHuman($value,$dateFormat);
|
||||||
}
|
}
|
||||||
elsif ($field->{fieldType} eq "dateTime"){
|
elsif (lc $field->{fieldType} eq "datetime"){
|
||||||
$processedValue = $self->session->datetime->epochToHuman($value,$dateTimeFormat);
|
$processedValue = $self->session->datetime->epochToHuman($value,$dateTimeFormat);
|
||||||
}
|
}
|
||||||
# TODO: The otherThing field type is probably also handled by getFormPlugin, so the elsif below can probably be
|
# TODO: The otherThing field type is probably also handled by getFormPlugin, so the elsif below can probably be
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use lib "$FindBin::Bin/../../lib";
|
||||||
|
|
||||||
use WebGUI::Test;
|
use WebGUI::Test;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use Test::More tests => 26; # increment this value for each test you create
|
use Test::More tests => 28; # increment this value for each test you create
|
||||||
use Test::Deep;
|
use Test::Deep;
|
||||||
use JSON;
|
use JSON;
|
||||||
use WebGUI::Asset::Wobject::Thingy;
|
use WebGUI::Asset::Wobject::Thingy;
|
||||||
|
|
@ -373,28 +373,51 @@ is($table, undef, '... drops thing specific table');
|
||||||
#
|
#
|
||||||
#################################################################
|
#################################################################
|
||||||
|
|
||||||
%otherThingProperties = %thingProperties;
|
{
|
||||||
$otherThingProperties{'groupIdView'} = 3;
|
my %newThingProperties = %thingProperties;
|
||||||
$otherThingId = $thingy->addThing(\%otherThingProperties, 0);
|
$newThingProperties{'groupIdView'} = 3;
|
||||||
%otherFieldProperties = %fieldProperties;
|
my $newThingId = $thingy->addThing(\%newThingProperties, 0);
|
||||||
$otherFieldProperties{thingId} = $otherThingId;
|
my %newFieldProperties = %fieldProperties;
|
||||||
$otherFieldId = $thingy->addField(\%otherFieldProperties, 0);
|
$newFieldProperties{thingId} = $newThingId;
|
||||||
$thingy->editThingDataSave($otherThingId, 'new', {"field_".$otherFieldId => 'value 1'} );
|
my $newFieldId = $thingy->addField(\%newFieldProperties, 0);
|
||||||
$thingy->editThingDataSave($otherThingId, 'new', {"field_".$otherFieldId => 'value 2'} );
|
$thingy->editThingDataSave($newThingId, 'new', {"field_".$newFieldId => 'value 1'} );
|
||||||
$thingy->editThingDataSave($otherThingId, 'new', {"field_".$otherFieldId => 'value 3'} );
|
$thingy->editThingDataSave($newThingId, 'new', {"field_".$newFieldId => 'value 2'} );
|
||||||
|
$thingy->editThingDataSave($newThingId, 'new', {"field_".$newFieldId => 'value 3'} );
|
||||||
|
|
||||||
my $andy = WebGUI::User->create($session);
|
my $andy = WebGUI::User->create($session);
|
||||||
WebGUI::Test->usersToDelete($andy);
|
WebGUI::Test->usersToDelete($andy);
|
||||||
$session->user({userId => $andy->userId});
|
$session->user({userId => $andy->userId});
|
||||||
|
|
||||||
my $form = $thingy->getFormPlugin({
|
my $form = $thingy->getFormPlugin({
|
||||||
name => 'fakeFormForTesting',
|
name => 'fakeFormForTesting',
|
||||||
fieldType => 'otherThing_'.$otherThingId,
|
fieldType => 'otherThing_'.$newThingId,
|
||||||
fieldInOtherThingId => $otherFieldId,
|
fieldInOtherThingId => $newFieldId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cmp_deeply(
|
||||||
|
$form->get('options'),
|
||||||
|
{},
|
||||||
|
'getFormPlugin: form has no data since the user does not have viewing privileges'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#################################################################
|
||||||
|
#
|
||||||
|
# getFieldValue
|
||||||
|
#
|
||||||
|
#################################################################
|
||||||
|
{
|
||||||
|
my %newThingProperties = %thingProperties;
|
||||||
|
my $newThingId = $thingy->addThing(\%newThingProperties, 0);
|
||||||
|
my %newFieldProperties = %fieldProperties;
|
||||||
|
$newFieldProperties{thingId} = $newThingId;
|
||||||
|
$newFieldProperties{fieldType} = 'Date';
|
||||||
|
|
||||||
|
my $date = $thingy->getFieldValue(WebGUI::Test->webguiBirthday, \%newFieldProperties);
|
||||||
|
like($date, qr{\d+/\d+/\d+}, "getFieldValue: Date field type returns data in user's format");
|
||||||
|
|
||||||
|
$newFieldProperties{fieldType} = 'DateTime';
|
||||||
|
my $datetime = $thingy->getFieldValue(WebGUI::Test->webguiBirthday, \%newFieldProperties);
|
||||||
|
like($datetime, qr{^\d+/\d+/\d+\s+\d+:\d+}, "... DateTime field also returns data in user's format");
|
||||||
|
}
|
||||||
|
|
||||||
cmp_deeply(
|
|
||||||
$form->get('options'),
|
|
||||||
{},
|
|
||||||
'getFormPlugin: form has no data since the user does not have viewing privileges'
|
|
||||||
);
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue