Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show information about current revision if not latest #2070

Merged
merged 8 commits into from
Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 63 additions & 3 deletions lib/ProductOpener/Display.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6727,7 +6727,6 @@ HTML
}



# my @fields = qw(generic_name quantity packaging br brands br categories br labels origins br manufacturing_places br emb_codes link purchase_places stores countries);
my @fields = @ProductOpener::Config::display_fields;

Expand Down Expand Up @@ -6797,8 +6796,10 @@ $Lang{warning_gs1_company_prefix}{$lc}
HTML
;
}

if (not has_tag($product_ref, "states", "en:complete")) {
if (defined $rev) {
$html .= display_rev_info($code, $rev);
}
elsif (not has_tag($product_ref, "states", "en:complete")) {

$html .= <<HTML
<div data-alert class="alert-box info" id="warning_not_complete" style="display: block;">
Expand Down Expand Up @@ -9010,7 +9011,66 @@ HTML

display_structured_response($request_ref);
}
sub display_rev_info {
my $code = shift;
my $rev = shift;

my $html = '';

my $path = product_path($code);
my $changes_ref = retrieve("$data_root/products/$path/changes.sto");
if (not defined $changes_ref) {
return '';
}
my $change_ref = $changes_ref->[$rev-1];

my $date = display_date_tag($change_ref->{t});
my $userid = get_change_userid_or_uuid($change_ref);
my $user = display_tag_link("editors", $userid);
my $previous_link = '';
if ($rev > 1) {
$previous_link = '/product/' . $code . '?rev='. ($rev - 1);
}
my $next_link = '';
if ($rev < scalar @$changes_ref) {
$next_link = '/product/' . $code . '?rev=' . ($rev + 1);
}

my $comment = $change_ref->{comment};
$comment = lang($comment) if $comment eq 'product_created';

$comment =~ s/^Modification :\s+//;
if ($comment eq 'Modification :') {
$comment = '';
}
$comment =~ s/\new image \d+( -)?//;
if ($comment ne '') {
$comment = "<p> ${\lang('edit_comment')}: $comment</p>";
}


$html .= <<"HTML"
<div id='rev_summary' class='panel callout'>
<h4 class='rev_warning'>${\lang('rev_warning')}</h4>
<p>
${\lang('rev_number')} <span class='rev_nb'>$change_ref->{rev}</span> -
<time datetime='$change_ref->{t}'>$date</time> -
${\lang('rev_contributor')} <a href='/contributor/$userid' class='rev_contributor'>$user</a>
</p>
$comment
HTML
;
if ($previous_link ne '') {
$html .= "<span style='margin-right: 2em;'><a href='$previous_link'>← ${\lang('rev_previous')}</a></span>";
}
$html .= "<span><a href='/product/$code'>${\lang('rev_latest')}</a></span>";
if ($next_link ne '') {
$html .= "<span style='margin-left: 2em;'><a href='$next_link'>${\lang('rev_next')} →</a></span>";
}
$html .="</div>";
return $html;

}
sub display_product_history($$) {

my $code = shift;
Expand Down
23 changes: 23 additions & 0 deletions po/common/common.pot
Original file line number Diff line number Diff line change
Expand Up @@ -3448,6 +3448,29 @@ msgctxt "ingredients_analysis"
msgid "Ingredients analysis"
msgstr ""

msgctxt "rev_warning"
msgid "You are viewing an old version of this product page!"
msgstr "You are viewing an old version of this product page!"

msgctxt "rev_number"
msgid "Revision number: "
msgstr "Revision number: "

msgctxt "rev_contributor"
msgid "Edited by: "
msgstr "Edited by: "

msgctxt "rev_previous"
msgid "Previous version"
msgstr "Previous version"

msgctxt "rev_next"
msgid "Next version"
msgstr "Next version"

msgctxt "rev_latest"
msgid "Latest version"
msgstr "Latest version"
msgctxt "ingredients_analysis_disclaimer"
msgid "The analysis is based solely on the ingredients listed and does not take into account processing methods."
msgstr ""
Expand Down
24 changes: 24 additions & 0 deletions po/common/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -3275,6 +3275,30 @@ msgctxt "cancel"
msgid "Cancel"
msgstr "Cancel"

msgctxt "rev_warning"
msgid "You are viewing an old version of this product page!"
msgstr "You are viewing an old version of this product page!"

msgctxt "rev_number"
msgid "Revision number: "
msgstr "Revision number: "

msgctxt "rev_contributor"
msgid "Edited by: "
msgstr "Edited by: "

msgctxt "rev_previous"
msgid "Previous version"
msgstr "Previous version"

msgctxt "rev_next"
msgid "Next version"
msgstr "Next version"

msgctxt "rev_latest"
msgid "Latest version"
msgstr "Latest version"

msgctxt "ingredients_analysis_p"
msgid "ingredients analysis"
msgstr "ingredients analysis"
Expand Down