Fix parsing
This commit is contained in:
parent
fec097e552
commit
48794959c4
@ -28,6 +28,7 @@ use JSON;
|
|||||||
# How many ingredient rows should appear in the empty form?
|
# How many ingredient rows should appear in the empty form?
|
||||||
use constant DEFAULT_INGREDIENT_COUNT => 5;
|
use constant DEFAULT_INGREDIENT_COUNT => 5;
|
||||||
|
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# Page generation support functions
|
# Page generation support functions
|
||||||
@ -266,9 +267,9 @@ sub _validate_ingredient {
|
|||||||
my $ingdata = shift;
|
my $ingdata = shift;
|
||||||
my ($error, $errors) = ("", "");
|
my ($error, $errors) = ("", "");
|
||||||
|
|
||||||
# Do nothing unless something has been set for the quantity and name
|
# Do nothing unless something has been set for the name
|
||||||
return ""
|
return ""
|
||||||
unless($ingdata -> {"quantity"} && $ingdata -> {"name"});
|
unless($ingdata -> {"name"});
|
||||||
|
|
||||||
# Start accumulating ingredient data here
|
# Start accumulating ingredient data here
|
||||||
my $ingredient = {
|
my $ingredient = {
|
||||||
@ -277,11 +278,13 @@ sub _validate_ingredient {
|
|||||||
};
|
};
|
||||||
|
|
||||||
# Quantity valid?
|
# Quantity valid?
|
||||||
if($ingdata -> {"quantity"} =~ /^\d+(\.\d+)?$/) {
|
if($ingdata -> {"quantity"}) {
|
||||||
$ingredient -> {"quantity"} = $ingdata -> {"quantity"};
|
if($ingdata -> {"quantity"} =~ /$self->{formats}->{quantity}/) {
|
||||||
} else {
|
$ingredient -> {"quantity"} = $ingdata -> {"quantity"};
|
||||||
$errors .= $self -> {"template"} -> load_template("error/error_item.tem",
|
} else {
|
||||||
{ "%(error)s" => "{L_ERR_BADQUANTITY}" });
|
$errors .= $self -> {"template"} -> load_template("error/error_item.tem",
|
||||||
|
{ "%(error)s" => "{L_ERR_BADQUANTITY}" });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Name valid?
|
# Name valid?
|
||||||
@ -353,6 +356,7 @@ sub _validate_ingredients {
|
|||||||
$errors .= $self -> _validate_ingredient($args, $ingred);
|
$errors .= $self -> _validate_ingredient($args, $ingred);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
print STDERR "Out: ",Dumper($args -> {"ingredients"})."\n";
|
||||||
|
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
@ -401,10 +405,10 @@ sub _validate_recipe {
|
|||||||
if($error);
|
if($error);
|
||||||
|
|
||||||
# <label>{L_RECIPE_PREPINFO}
|
# <label>{L_RECIPE_PREPINFO}
|
||||||
($args -> {"timereq"}, $error) = $self -> validate_string("timereq", { required => 0,
|
($args -> {"prepinfo"}, $error) = $self -> validate_string("prepinfo", { required => 0,
|
||||||
default => "",
|
default => "",
|
||||||
maxlen => 255,
|
maxlen => 255,
|
||||||
nicename => "{L_RECIPE_PREPINFO}"
|
nicename => "{L_RECIPE_PREPINFO}"
|
||||||
});
|
});
|
||||||
$errors .= $self -> {"template"} -> load_template("error/error_item.tem", { "%(error)s" => $error })
|
$errors .= $self -> {"template"} -> load_template("error/error_item.tem", { "%(error)s" => $error })
|
||||||
if($error);
|
if($error);
|
||||||
@ -454,7 +458,7 @@ sub _validate_recipe {
|
|||||||
|
|
||||||
|
|
||||||
# <label>{L_RECIPE_TYPE}
|
# <label>{L_RECIPE_TYPE}
|
||||||
my $types = $self -> {"system"} -> {"entities"} -> {"types"} -> as_options();
|
my $types = $self -> {"system"} -> {"entities"} -> {"types"} -> as_options(1);
|
||||||
($args -> {"type"}, $error) = $self -> validate_options("type", { required => 1,
|
($args -> {"type"}, $error) = $self -> validate_options("type", { required => 1,
|
||||||
source => $types,
|
source => $types,
|
||||||
nicename => "{L_RECIPE_TYPE}"
|
nicename => "{L_RECIPE_TYPE}"
|
||||||
@ -464,7 +468,7 @@ sub _validate_recipe {
|
|||||||
|
|
||||||
|
|
||||||
# <label>{L_RECIPE_STATUS}
|
# <label>{L_RECIPE_STATUS}
|
||||||
my $states = $self -> {"system"} -> {"entities"} -> {"states"} -> as_options(0, visible => {value => 1});
|
my $states = $self -> {"system"} -> {"entities"} -> {"states"} -> as_options(1, visible => {value => 1});
|
||||||
($args -> {"status"}, $error) = $self -> validate_options("status", { required => 1,
|
($args -> {"status"}, $error) = $self -> validate_options("status", { required => 1,
|
||||||
source => $states,
|
source => $states,
|
||||||
nicename => "{L_RECIPE_STATUS}"
|
nicename => "{L_RECIPE_STATUS}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user