Thingy now requires at least 1 field per new Thing

This commit is contained in:
Kaleb Murphy 2008-08-22 21:37:37 +00:00
parent 3f4de3612f
commit 22acd6eb8d
3 changed files with 21 additions and 5 deletions

View file

@ -8,6 +8,7 @@
7.5.22
- fixed: Layout template now gets prepared correctly
- fixed: When user does not have permissions to search/edit a thing a proper error is shown.
- fixed: Thingy now requires at least 1 field for a new Thing.
7.5.21
- fixed: purchase detail screen shows incorrectly in Safari

View file

@ -1185,6 +1185,7 @@ before the form is submitted.
sub www_editThing {
my $self = shift;
my $warning = shift;
my $session = $self->session;
my ($tabForm, $output, %properties, $tab, %afterSave, %defaultView, $fields);
my ($fieldsHTML, $fieldsViewScreen, $fieldsSearchScreen);
@ -1563,8 +1564,9 @@ sub www_editThing {
-value => $properties{thingsPerPage},
);
$tab->raw($fieldsSearchScreen);
$output = $tabForm->print;
#if($warning){$output .= "<script> alert('$warning');</script>";}
if($warning){$output .= "$warning";}
$output .= $tabForm->print;
my $dialog = "<div id='addDialog'>\n"
."<div class='hd'>".$i18n->get('add field label')."</div>\n"
@ -1599,6 +1601,10 @@ sub www_editThingSave {
my $form = $self->session->form;
my ($thingId, $fields);
$thingId = $self->session->form->process("thingId");
$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');
$self->setCollateral("Thingy_things","thingId",{
thingId=>$thingId,
label=>$form->process("label"),
@ -1625,7 +1631,12 @@ sub www_editThingSave {
sortBy=>$form->process("sortBy"),
},0,1);
$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');
if($fields->rows < 1){
$self->session->log->warn("Thing failed to create because it had no fields");
my $i18n = WebGUI::International->new($self->session, "Asset_Thingy");
return $self->www_editThing($i18n->get("thing must have fields"));
}
while (my $field = $fields->hashRef) {
my $display = $self->session->form->process("display_".$field->{fieldId}) || 0;
my $viewScreenTitle = $self->session->form->process("viewScreenTitle_".$field->{fieldId}) || 0;

View file

@ -934,8 +934,12 @@ search has been done.|,
'no permission to search' => {
message => q|You do not have permissions to search this Thing.|,
lastUpdated => 1219424285,
}
},
'thing must have fields' => {
message => q|Error: You must assign fields to your new Thing.|,
lastUpdated => 1219424285,
},
};
1;