Update view to separation of prep and cook time

This commit is contained in:
Chris 2018-10-01 22:08:12 +01:00
parent 87aa81fef4
commit 974cf8cbb1
3 changed files with 31 additions and 5 deletions

View File

@ -154,14 +154,29 @@ sub _generate_view {
pathinfo => [ $recipe -> {"id"} ]),
});
my $preptime = $recipe -> {"preptime"} ? $self -> {"template"} -> humanise_seconds($recipe -> {"preptime"} * 60)
: "{L_VIEW_NOTSET}";
my $cooktime = $recipe -> {"cooktime"} ? $self -> {"template"} -> humanise_seconds($recipe -> {"cooktime"} * 60)
: "{L_VIEW_NOTSET}";
my $totaltime = $recipe -> {"preptime"} + $recipe -> {"cooktime"};
my $timereq = $totaltime ? $self -> {"template"} -> humanise_seconds($totaltime * 60)
: "{L_VIEW_NOTSET}";
# Mark the recipe as viewed
$self -> {"system"} -> {"recipe"} -> set_viewed($rid, $self -> {"session"} -> get_session_userid());
$self -> log("recipe:view", "Recipe $rid viewed by user ".$self -> {"session"} -> get_session_userid());
# and build the page itself
my $body = $self -> {"template"} -> load_template("view/content.tem",
{
"%(name)s" => $title,
"%(source)s" => $source,
"%(yield)s" => $recipe -> {"yield"},
"%(timereq)s" => $recipe -> {"timereq"},
"%(timemins)s" => $self -> {"template"} -> humanise_seconds($recipe -> {"timemins"} * 60),
"%(prepinfo)s" => $recipe -> {"prepinfo"},
"%(preptime)s" => $preptime,
"%(cooktime)s" => $cooktime,
"%(timereq)s" => $timereq,
"%(temp)s" => $recipe -> {"temp"} ? $recipe -> {"temp"} : "",
"%(temptype)s" => $recipe -> {"temptype"} // "",
"%(type)s" => $recipe -> {"type"},

View File

@ -2,7 +2,10 @@ VIEW_NAME = Name
VIEW_SOURCE = Source
VIEW_YIELD = Yield
VIEW_PREPINFO = Prep info
VIEW_PREPTIME = Prep time
VIEW_COOKTIME = Cook time
VIEW_TIMEREQ = Time required
VIEW_NOTSET = Not set
VIEW_OVENTEMP = Oven preheat
VIEW_TYPE = Type
VIEW_STATUS = Status
@ -17,4 +20,4 @@ VIEW_CLONE = Clone
VIEW_DELETE = Delete
VIEW_ERROR_FATAL = View error
VIEW_ERROR_NORECIPE = No matching recipe found
VIEW_ERROR_NORECIPE = No matching recipe found

View File

@ -11,11 +11,19 @@
</div>
<div class="grid-x grid-margin-x">
<div class="cell medium-2 small-1 text-right title"><i class="fa fa-tasks hide-for-print hide-for-medium" aria-hidden="true"></i> <span class="show-for-medium">{L_VIEW_PREPINFO}</span></div>
<div class="cell medium-10 small-11 text-left">%(timereq)s</div>
<div class="cell medium-10 small-11 text-left">%(prepinfo)s</div>
</div>
<div class="grid-x grid-margin-x">
<div class="cell medium-2 small-1 text-right title"><i class="fa fa-clock hide-for-print hide-for-medium" aria-hidden="true"></i> <span class="show-for-medium">{L_VIEW_PREPTIME}</span></div>
<div class="cell medium-10 small-11 text-left">%(preptime)s</div>
</div>
<div class="grid-x grid-margin-x">
<div class="cell medium-2 small-1 text-right title"><i class="fa fa-clock hide-for-print hide-for-medium" aria-hidden="true"></i> <span class="show-for-medium">{L_VIEW_COOKTIME}</span></div>
<div class="cell medium-10 small-11 text-left">%(cooktime)s</div>
</div>
<div class="grid-x grid-margin-x">
<div class="cell medium-2 small-1 text-right title"><i class="fa fa-clock hide-for-print hide-for-medium" aria-hidden="true"></i> <span class="show-for-medium">{L_VIEW_TIMEREQ}</span></div>
<div class="cell medium-10 small-11 text-left">%(timemins)s</div>
<div class="cell medium-10 small-11 text-left">%(timereq)s</div>
</div>
<div class="grid-x grid-margin-x">
<div class="cell medium-2 small-1 text-right title"><i class="fa fa-thermometer-three-quarters hide-for-print hide-for-medium" aria-hidden="true"></i> <span class="show-for-medium">{L_VIEW_OVENTEMP}</span></div>