Allow for File and Image subclasses to be handled gracefully by the Thingy.
This commit is contained in:
parent
648ea286ea
commit
3e0da41f0a
3 changed files with 38 additions and 12 deletions
|
|
@ -13,6 +13,7 @@
|
||||||
- fixed #12007: Hardcoded js in cart view ( Martin Kamerbeek / Oqapi )
|
- fixed #12007: Hardcoded js in cart view ( Martin Kamerbeek / Oqapi )
|
||||||
- fixed #12010: Related URLs are not copied for events created through recurrence
|
- fixed #12010: Related URLs are not copied for events created through recurrence
|
||||||
- fixed #12012: WebGUI Account system does not present login to visitors for proper redirect
|
- fixed #12012: WebGUI Account system does not present login to visitors for proper redirect
|
||||||
|
- fixed #12015: Thingy: Custom 'File' form fields get deleted upon save
|
||||||
|
|
||||||
7.10.6
|
7.10.6
|
||||||
- fixed #11974: Toolbar icons unclickable in Webkit using HTML5
|
- fixed #11974: Toolbar icons unclickable in Webkit using HTML5
|
||||||
|
|
|
||||||
|
|
@ -454,7 +454,7 @@ sub copyThingData {
|
||||||
my @storage_field_ids = ();
|
my @storage_field_ids = ();
|
||||||
##Check to see if any of them are File or Image
|
##Check to see if any of them are File or Image
|
||||||
foreach my $field (@{ $fields }) {
|
foreach my $field (@{ $fields }) {
|
||||||
if ($field->{fieldType} eq 'File' or $field->{fieldType} eq 'Image') {
|
if ($self->field_isa($field->{fieldType}, 'WebGUI::Form::File')) {
|
||||||
push @storage_field_ids, $field->{fieldId};
|
push @storage_field_ids, $field->{fieldId};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -512,7 +512,7 @@ sub deleteThingData {
|
||||||
my @storage_field_ids = ();
|
my @storage_field_ids = ();
|
||||||
##Check to see if any of them are File or Image
|
##Check to see if any of them are File or Image
|
||||||
foreach my $field (@{ $fields }) {
|
foreach my $field (@{ $fields }) {
|
||||||
if ($field->{fieldType} eq 'File' or $field->{fieldType} eq 'Image') {
|
if ($self->field_isa($field->{fieldType}, 'WebGUI::Form::File')) {
|
||||||
push @storage_field_ids, $field->{fieldId};
|
push @storage_field_ids, $field->{fieldId};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -610,7 +610,7 @@ sub editThingDataSave {
|
||||||
$fieldType = "" if ($fieldType =~ m/^otherThing/x);
|
$fieldType = "" if ($fieldType =~ m/^otherThing/x);
|
||||||
# Modify the defaultValue for certain field types. For most types we want to use
|
# Modify the defaultValue for certain field types. For most types we want to use
|
||||||
# the default in the database, for these we want the last known value for this thingData
|
# the default in the database, for these we want the last known value for this thingData
|
||||||
if ( $fieldType eq "File" || $fieldType eq "Image" ) {
|
if ($self->field_isa($fieldType, 'WebGUI::Form::File')) {
|
||||||
$field->{ defaultValue } = $thingData{ "field_" . $field->{ fieldId } };
|
$field->{ defaultValue } = $thingData{ "field_" . $field->{ fieldId } };
|
||||||
}
|
}
|
||||||
$fieldValue = $thingData->{$fieldName} || $session->form->process($fieldName,$fieldType,$field->{defaultValue},$field);
|
$fieldValue = $thingData->{$fieldName} || $session->form->process($fieldName,$fieldType,$field->{defaultValue},$field);
|
||||||
|
|
@ -674,6 +674,32 @@ sub exportAssetData {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 field_isa ( $fieldType, $isa )
|
||||||
|
|
||||||
|
Builds a form field and does an isa check on it.
|
||||||
|
|
||||||
|
=head2 $fieldType
|
||||||
|
|
||||||
|
This is the type of a field to build. It will have 'WebGUI::Form' prepended to it to form
|
||||||
|
a complete classname.
|
||||||
|
|
||||||
|
=head2 $isa
|
||||||
|
|
||||||
|
This is the class name to check against.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub field_isa {
|
||||||
|
my $self = shift;
|
||||||
|
my $session = $self->session;
|
||||||
|
my $fieldType = shift;
|
||||||
|
my $isa = shift;
|
||||||
|
my $control = eval { WebGUI::Pluggable::instanciate("WebGUI::Form::".$fieldType, "new", [ $session, () ]) };
|
||||||
|
return ($control && $control->isa($isa));
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 _getDbDataType ( fieldType )
|
=head2 _getDbDataType ( fieldType )
|
||||||
|
|
||||||
returns the database data type for a field based on the fieldType.
|
returns the database data type for a field based on the fieldType.
|
||||||
|
|
@ -1853,12 +1879,12 @@ sub www_editThing {
|
||||||
$fields = $self->session->db->read('select * from Thingy_fields where assetId = '.$self->session->db->quote($self->get("assetId")).' and thingId = '.$self->session->db->quote($thingId).' order by sequenceNumber');
|
$fields = $self->session->db->read('select * from Thingy_fields where assetId = '.$self->session->db->quote($self->get("assetId")).' and thingId = '.$self->session->db->quote($thingId).' order by sequenceNumber');
|
||||||
while (my $field = $fields->hashRef) {
|
while (my $field = $fields->hashRef) {
|
||||||
my $formElement;
|
my $formElement;
|
||||||
if ($field->{fieldType} eq "File"){
|
if ($self->field_isa($field->{fieldType}, 'WebGUI::Form::Image')) {
|
||||||
$formElement = "<input type='file' name='file'>";
|
|
||||||
}
|
|
||||||
if ($field->{fieldType} eq "Image"){
|
|
||||||
$formElement = "<input type='file' name='image'>";
|
$formElement = "<input type='file' name='image'>";
|
||||||
}
|
}
|
||||||
|
elsif ($self->field_isa($field->{fieldType}, 'WebGUI::Form::File')) {
|
||||||
|
$formElement = "<input type='file' name='file'>";
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
$formElement = $self->getFormElement($field);
|
$formElement = $self->getFormElement($field);
|
||||||
}
|
}
|
||||||
|
|
@ -2301,12 +2327,12 @@ sub www_editFieldSave {
|
||||||
$newFieldId = $self->setCollateral("Thingy_fields","fieldId",\%properties,1,1,"thingId",$thingId);
|
$newFieldId = $self->setCollateral("Thingy_fields","fieldId",\%properties,1,1,"thingId",$thingId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($properties{fieldType} eq "File"){
|
if ($self->field_isa($properties{fieldType}, 'WebGUI::Form::Image')) {
|
||||||
$formElement = "<input type='file' name='file'>";
|
|
||||||
}
|
|
||||||
elsif ($properties{fieldType} eq "Image"){
|
|
||||||
$formElement = "<input type='file' name='image'>";
|
$formElement = "<input type='file' name='image'>";
|
||||||
}
|
}
|
||||||
|
elsif ($self->field_isa($properties{fieldType}, 'WebGUI::Form::File')) {
|
||||||
|
$formElement = "<input type='file' name='file'>";
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
$formElement = $self->getFormElement(\%properties);
|
$formElement = $self->getFormElement(\%properties);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -436,7 +436,6 @@ $session->request->setup_body({
|
||||||
$session->user({userId => '3'});
|
$session->user({userId => '3'});
|
||||||
$session->http->setStatus(200);
|
$session->http->setStatus(200);
|
||||||
my $json = $thingy->www_editThingDataSaveViaAjax();
|
my $json = $thingy->www_editThingDataSaveViaAjax();
|
||||||
diag "json: ".$json;
|
|
||||||
is $json, '{}', 'www_editThingDataSaveViaAjax: Empty JSON hash';
|
is $json, '{}', 'www_editThingDataSaveViaAjax: Empty JSON hash';
|
||||||
is $session->http->getStatus, 200, '... http status=200';
|
is $session->http->getStatus, 200, '... http status=200';
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue