From 2dd57b27e8eb2b481e1f27bc897d884cbd4bf5f7 Mon Sep 17 00:00:00 2001 From: areeshatariq Date: Wed, 17 Jun 2020 19:19:59 +0500 Subject: [PATCH 01/13] Search form Template [WIP] --- cgi/search.pl | 26 ++++++ templates/search_form.tt.html | 150 ++++++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 templates/search_form.tt.html diff --git a/cgi/search.pl b/cgi/search.pl index a75b9f98b640b..75cdcf7b5ca2b 100755 --- a/cgi/search.pl +++ b/cgi/search.pl @@ -42,6 +42,28 @@ use Encode; use JSON::PP; use Log::Any qw($log); +use Template; +use Data::Dumper; + +# Initialize the Template module +my $tt = Template->new({ + INCLUDE_PATH => $data_root . '/templates', + INTERPOLATE => 1, + EVAL_PERL => 1, + STAT_TTL => 60, # cache templates in memory for 1 min before checking if the source changed + COMPILE_EXT => '.ttc', # compile templates to Perl code for much faster reload + COMPILE_DIR => $data_root . '/tmp/templates', +}); + +my $template_data_ref = { + + lang => \&lang, + +}; + +#my $criteria; + +my $html; if (0) { if (param('jqm')) { @@ -890,3 +912,7 @@ } } } + +#my $out; +$tt->process('search_form.tt.html', $template_data_ref, \$html || print "template error: " . $tt->error()); +print "Template Result, $html, are"; \ No newline at end of file diff --git a/templates/search_form.tt.html b/templates/search_form.tt.html new file mode 100644 index 0000000000000..32ec3a09805ac --- /dev/null +++ b/templates/search_form.tt.html @@ -0,0 +1,150 @@ +

Testing

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From f3e2611434e5f124c643199c23e29ee8b38722c1 Mon Sep 17 00:00:00 2001 From: areeshatariq Date: Thu, 18 Jun 2020 03:45:12 +0500 Subject: [PATCH 02/13] Search form templatization wip --- cgi/search.pl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cgi/search.pl b/cgi/search.pl index 75cdcf7b5ca2b..a91dba2286394 100755 --- a/cgi/search.pl +++ b/cgi/search.pl @@ -544,9 +544,11 @@ + HTML ; + $styles .= < .select2-results__options { max-height: 400px @@ -575,6 +577,8 @@ JS ; +$tt->process('search_form.tt.html', $template_data_ref, \$html || print "template error: " . $tt->error()); +print "HISH $html"; ${$request_ref->{content_ref}} .= $html; @@ -912,7 +916,7 @@ } } } - + #my $out; -$tt->process('search_form.tt.html', $template_data_ref, \$html || print "template error: " . $tt->error()); -print "Template Result, $html, are"; \ No newline at end of file +# $tt->process('search_form.tt.html', $template_data_ref, \$html || print "template error: " . $tt->error()); +# print "Template Result, $html, are"; From d598f9fc41859ec91c61acf165d0e2a98ba2ecb8 Mon Sep 17 00:00:00 2001 From: areeshatariq Date: Sat, 20 Jun 2020 06:30:18 +0500 Subject: [PATCH 03/13] Search Form Templating [WIP] --- cgi/search.pl | 52 ++++++++++++- templates/search_form.tt.html | 138 +++++++++++++++++++++------------- 2 files changed, 134 insertions(+), 56 deletions(-) diff --git a/cgi/search.pl b/cgi/search.pl index a91dba2286394..ea73ff544cf55 100755 --- a/cgi/search.pl +++ b/cgi/search.pl @@ -58,10 +58,11 @@ my $template_data_ref = { lang => \&lang, + popup_menu => \&popup_menu, }; -#my $criteria; +my $criteria; my $html; @@ -278,6 +279,17 @@ HTML ; + push @{$template_data_ref->{criteria}}, { + id => $i, + type_value => $search_tags[$i][0], + type_values => ['search_tag', @search_fields], + type_labels => \%search_fields_labels, + contain_value => $search_tags[$i][1], + contain_values => ["contains", "does_not_contain"], + contain_labels => {"contains" => lang("search_contains"), "does_not_contain" => lang("search_does_not_contain")}, + input_value => $search_tags[$i][2], + }; + $html .= popup_menu(-name=>"tagtype_$i", -id=>"tagtype_$i", -value=> $search_tags[$i][0], -values=>['search_tag', @search_fields], -labels=>\%search_fields_labels); $html .= <$label HTML ; + push @{$template_data_ref->{ingredients}}, { + tagtype => $tagtype, + search_ingredient_classes_without => $search_ingredient_classes_checked{$tagtype}{without}, + search_ingredient_classes_with => $search_ingredient_classes_checked{$tagtype}{with}, + search_ingredient_classes_indifferent => $search_ingredient_classes_checked{$tagtype}{indifferent}, + }; $html .= <{nutriments}}, { + id => $i, + value => $search_nutriments[$i][0], + values => ["", @sorted_axis_values], + labels => \%axis_labels, + compare_value => $search_nutriments[$i][1], + compare_values => ['lt','lte','gt','gte','eq'], + compare_labels => {'lt' => '<', 'lte' => "\N{U+2264}", 'gt' => '>', 'gte' => "\N{U+2265}", 'eq' => '='}, + input_value => $search_nutriments[$i][2], + + }; + $html .= popup_menu(-class=>"select2_field", -name=>"nutriment_$i", -id=>"nutriment_$i", -value=> $search_nutriments[$i][0], -values=>["", @sorted_axis_values], -labels=>\%axis_labels); $html .= < HTML ; + + push @{$template_data_ref->{results}}, { + id => $axis, + value => $graph_ref->{"axis_" . $axis}, + values => ["", @sorted_axis_values], + labels => \%axis_labels, + + }; + $html .= "" . popup_menu(-class=>"select2_field", -name=>"axis_$axis", -id=>"axis_$axis", -value=> $graph_ref->{"axis_" . $axis}, -values=>["", @sorted_axis_values], -labels=>\%axis_labels); @@ -496,6 +534,11 @@ HTML ; + push @{$template_data_ref->{search_series}}, { + series => $series, + checked => $checked, + + }; } @@ -577,8 +620,9 @@ JS ; -$tt->process('search_form.tt.html', $template_data_ref, \$html || print "template error: " . $tt->error()); -print "HISH $html"; + +$tt->process('search_form.tt.html', $template_data_ref, \$html); +$html .= "

" . $tt->error() . "

"; ${$request_ref->{content_ref}} .= $html; diff --git a/templates/search_form.tt.html b/templates/search_form.tt.html index 32ec3a09805ac..0d353cb238059 100644 --- a/templates/search_form.tt.html +++ b/templates/search_form.tt.html @@ -1,105 +1,126 @@ -

Testing

- +

[% lang('search_products') %]

+
- + - +

[% lang('search_tags') %]

+ - + [% END %] + - + - + [% FOREACH type IN nutriments %] +
+
+
+ [% popup_menu(class=>"select2_field", name=>"nutriment_${type.id}", id=>"nutriment_${type.id}", value=> type.value, values=> type.values, labels=> type.labels) %] +
+
+ [% popup_menu(name=>"nutriment_compare_${type.id}", id=>"nutriment_compare_${type.id}", value=> type.compare_value, values=> type.compare_values, labels=> type.compare_labels) %] +
+
+ +
+
+
+ [% END %] + - - + + - + [% FOREACH series IN search_series %] + [% IF series.series == 'nutrition_grades' %] + +
+

[% lang('or') %]

+ [% END %] + + + [% END %] +
+ + + + - + - - + +
From 81669db1e98187b578cbc6e56e58819ef1da4c2f Mon Sep 17 00:00:00 2001 From: areeshatariq Date: Mon, 22 Jun 2020 13:26:18 +0500 Subject: [PATCH 04/13] Search form templatization WIP --- cgi/search.pl | 18 ++++++++++++++++-- templates/search_form.tt.html | 8 ++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/cgi/search.pl b/cgi/search.pl index ea73ff544cf55..9cc213b1ce5dc 100755 --- a/cgi/search.pl +++ b/cgi/search.pl @@ -432,6 +432,19 @@ my $popup_size = popup_menu(-name=>"page_size", -id=>"page_size", -value=> $limit, -values=>[20, 50, 100, 250, 500, 1000]); + push @{$template_data_ref->{popup_sort}}, { + value => $sort_by, + values => ['unique_scans_n','product_name','created_t','last_modified_t','completeness'], + labels => {unique_scans_n=>lang("sort_popularity"), product_name=>lang("sort_product_name"), created_t=>lang("sort_created_t"), last_modified_t=>lang("sort_modified_t"), completeness=>lang("sort_completeness")}, + + }; + + push @{$template_data_ref->{popup_size}}, { + value => $limit, + values => [20, 50, 100, 250, 500, 1000], + + }; + $html .= < @@ -441,15 +454,16 @@
  • $Lang{search_list_choice}{$lc}

    - + $template_data_ref->{active_list} = $active_list;
    - $popup_sort +
    $popup_size +
    diff --git a/templates/search_form.tt.html b/templates/search_form.tt.html index 0d353cb238059..7039b82334288 100644 --- a/templates/search_form.tt.html +++ b/templates/search_form.tt.html @@ -70,7 +70,7 @@

    [% lang('search_nutriments') %]

    [% popup_menu(name=>"nutriment_compare_${type.id}", id=>"nutriment_compare_${type.id}", value=> type.compare_value, values=> type.compare_values, labels=> type.compare_labels) %]
    - +
    @@ -85,15 +85,15 @@

    [% lang('search_nutriments') %]

  • [% lang('search_list_choice') %]

    -
    +
    - [% type.popup_sort %] + [% popup_menu(name=>"sort_by", id=>"sort_by", value=>${popup_sort.value}, values=>${popup_sort.values}, labels=>${popup_sort.labels} ) %]
    - [% type.popup_size %] + [% popup_menu(name=>"page_size", id=>"page_size", value=>${popup_size.value}, values=>${popup_size.values}) %]
    From 9eb9991ba61bdf17e44866faa912166d41b7c20a Mon Sep 17 00:00:00 2001 From: areeshatariq Date: Mon, 22 Jun 2020 21:02:58 +0500 Subject: [PATCH 05/13] Search form html templatization --- cgi/search.pl | 265 ++-------------------------------- templates/search_form.tt.html | 14 +- 2 files changed, 19 insertions(+), 260 deletions(-) diff --git a/cgi/search.pl b/cgi/search.pl index 9cc213b1ce5dc..829ff229c430f 100755 --- a/cgi/search.pl +++ b/cgi/search.pl @@ -55,11 +55,13 @@ COMPILE_DIR => $data_root . '/tmp/templates', }); +# Passing values to the template my $template_data_ref = { lang => \&lang, popup_menu => \&popup_menu, - + start_form => \&start_form, + }; my $criteria; @@ -232,22 +234,6 @@ $active_graph = 'active'; } - # Display the search form - - my $html = start_form(-id=>"search_form", -action=>"/cgi/search.pl") ; - - $html .= < -
    - - -
    -
    - -

    $Lang{search_tags}{$lang}

    - -HTML -; my %search_fields_labels = (); foreach my $field (@search_fields) { @@ -265,20 +251,9 @@ } $search_fields_labels{search_tag} = lang("search_tag"); - $html .= < -HTML -; for (my $i = 0; ($i < $tags_n) or defined param("tagtype_$i") ; $i++) { - $html .= < -
    -
    -HTML -; - push @{$template_data_ref->{criteria}}, { id => $i, type_value => $search_tags[$i][0], @@ -290,77 +265,21 @@ input_value => $search_tags[$i][2], }; - $html .= popup_menu(-name=>"tagtype_$i", -id=>"tagtype_$i", -value=> $search_tags[$i][0], -values=>['search_tag', @search_fields], -labels=>\%search_fields_labels); - - $html .= < -
    -HTML -; - $html .= popup_menu(-name=>"tag_contains_$i", -id=>"tag_contains_$i", -value=> $search_tags[$i][1], -values=>["contains", "does_not_contain"], - -labels=>{"contains" => lang("search_contains"), "does_not_contain" => lang("search_does_not_contain")} ); - - $html .= < -
    - -
    -
    -
    -HTML -; } - $html .= < - -

    $Lang{search_ingredients}{$lang}

    - -
    -HTML -; - foreach my $tagtype (@search_ingredient_classes) { not defined $search_ingredient_classes{$tagtype} and $search_ingredient_classes{$tagtype} = 'indifferent'; - my $label = ucfirst(lang($tagtype . "_p")) ; - - $html .= < - -HTML -; push @{$template_data_ref->{ingredients}}, { tagtype => $tagtype, - search_ingredient_classes_without => $search_ingredient_classes_checked{$tagtype}{without}, - search_ingredient_classes_with => $search_ingredient_classes_checked{$tagtype}{with}, - search_ingredient_classes_indifferent => $search_ingredient_classes_checked{$tagtype}{indifferent}, + search_ingredient_classes_checked_without => $search_ingredient_classes_checked{$tagtype}{without}, + search_ingredient_classes_checked_with => $search_ingredient_classes_checked{$tagtype}{with}, + search_ingredient_classes_checked_indifferent => $search_ingredient_classes_checked{$tagtype}{indifferent}, }; - - $html .= < - - - - - -
    -HTML -; } - - $html .= < - -

    $Lang{search_nutriments}{$lang}

    -
    -HTML -; - - # Compute possible axis values my @axis_values = @{$nutriments_lists{$nutriment_table}}; @@ -382,13 +301,6 @@ for (my $i = 0; $i < $nutriments_n ; $i++) { - $html .= < -
    -
    -HTML -; - push @{$template_data_ref->{nutriments}}, { id => $i, value => $search_nutriments[$i][0], @@ -400,38 +312,11 @@ input_value => $search_nutriments[$i][2], }; - - $html .= popup_menu(-class=>"select2_field", -name=>"nutriment_$i", -id=>"nutriment_$i", -value=> $search_nutriments[$i][0], -values=>["", @sorted_axis_values], -labels=>\%axis_labels); - - $html .= < -
    -HTML -; - $html .= popup_menu(-name=>"nutriment_compare_$i", -id=>"nutriment_compare_$i", -value=> $search_nutriments[$i][1], -values=>['lt','lte','gt','gte','eq'], - -labels => {'lt' => '<', 'lte' => "\N{U+2264}", 'gt' => '>', 'gte' => "\N{U+2265}", 'eq' => '='} ); - - $html .= < -
    - -
    -
    -
    -HTML -; + } # Different types to display results - my $popup_sort = popup_menu(-name=>"sort_by", -id=>"sort_by", -value=> $sort_by, - -values=>['unique_scans_n','product_name','created_t','last_modified_t','completeness'], - -labels=>{unique_scans_n=>lang("sort_popularity"), product_name=>lang("sort_product_name"), - created_t=>lang("sort_created_t"), last_modified_t=>lang("sort_modified_t"), - completeness=>lang("sort_completeness")}); - - my $popup_size = popup_menu(-name=>"page_size", -id=>"page_size", -value=> $limit, -values=>[20, 50, 100, 250, 500, 1000]); - push @{$template_data_ref->{popup_sort}}, { value => $sort_by, values => ['unique_scans_n','product_name','created_t','last_modified_t','completeness'], @@ -445,60 +330,13 @@ }; - $html .= < - - - -
      -
    • -

      $Lang{search_list_choice}{$lc}

      -
      - $template_data_ref->{active_list} = $active_list; -
      -
      - - -
      -
      - - $popup_size - -
      -
      - - -
      -
    • -HTML -; + $template_data_ref->{active_list} = $active_list; + # Graphs and visualization - $html .= < -

      $Lang{search_graph_choice}{$lc}

      -
      - -
      $Lang{search_graph_note}{$lang}
      - - - - -

      $Lang{search_graph_instructions}{$lc}

      - -
      -HTML -; - - foreach my $axis ('x','y') { - $html .= < -HTML -; - push @{$template_data_ref->{results}}, { id => $axis, value => $graph_ref->{"axis_" . $axis}, @@ -507,24 +345,8 @@ }; - $html .= "" - . popup_menu(-class=>"select2_field", -name=>"axis_$axis", -id=>"axis_$axis", -value=> $graph_ref->{"axis_" . $axis}, -values=>["", @sorted_axis_values], -labels=>\%axis_labels); - - $html .= < -HTML -; } - $html .= < - -
      -
      -

      $Lang{search_series}{$lc}

      -HTML -; - foreach my $series (@search_series, "nutrition_grades") { next if $series eq 'default'; @@ -533,78 +355,13 @@ $checked = 'checked="checked"'; } - if ($series eq 'nutrition_grades') { - $html .= < -
      -

      $Lang{or}{$lc}

      -HTML -; - } - - $html .= < - - -HTML -; push @{$template_data_ref->{search_series}}, { series => $series, checked => $checked, - }; } - $html .= < -
      - - - -
      - - - - -
    • -

      $Lang{search_map_choice}{$lc}

      -
      - -
      $Lang{search_map_note}{$lc}
      - - - - - - -
      -
    • - - - -
    • -

      $Lang{search_download_choice}{$lc}

      -
      - -

      $Lang{search_download_results}{$lc}

      - - -
      - -
      - - - -
      -
    • -
    - - - -HTML -; - $styles .= < .select2-results__options { @@ -639,9 +396,7 @@ $html .= "

    " . $tt->error() . "

    "; ${$request_ref->{content_ref}} .= $html; - - $request_ref->{title} = lang("search_products"); - + display_new($request_ref); } diff --git a/templates/search_form.tt.html b/templates/search_form.tt.html index 7039b82334288..4e4c66c958d57 100644 --- a/templates/search_form.tt.html +++ b/templates/search_form.tt.html @@ -2,7 +2,7 @@

    [% lang('search_products') %]

    - + [% start_form(id=>"search_form", action=>"/cgi/search.pl") %]
    @@ -44,7 +44,7 @@

    [% lang('search_ingredients') %]

    - + @@ -89,11 +89,15 @@

    [% lang('search_nutriments') %]

    - [% popup_menu(name=>"sort_by", id=>"sort_by", value=>${popup_sort.value}, values=>${popup_sort.values}, labels=>${popup_sort.labels} ) %] + [% FOREACH popup IN popup_sort %] + [% popup_menu(name=>"sort_by", id=>"sort_by", value=>popup.value, values=>popup.values, labels=>popup.labels ) %] + [% END %]
    - [% popup_menu(name=>"page_size", id=>"page_size", value=>${popup_size.value}, values=>${popup_size.values}) %] + [% FOREACH popup IN popup_size %] + [% popup_menu(name=>"page_size", id=>"page_size", value=>popup.value, values=>popup.values) %] + [% END %]
    @@ -172,7 +176,7 @@

    [% lang('search_graph_choice') %]

    [% lang('search_download_results') %]

    -
    +

    From eb5baecf04783e033a74c14013598576cc2eea21 Mon Sep 17 00:00:00 2001 From: areeshatariq Date: Sun, 5 Jul 2020 06:29:05 +0500 Subject: [PATCH 06/13] Search Form WIP --- cgi/search.pl | 2 +- templates/search_form.tt.html | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/cgi/search.pl b/cgi/search.pl index 829ff229c430f..ff7dfccb26328 100755 --- a/cgi/search.pl +++ b/cgi/search.pl @@ -258,7 +258,7 @@ id => $i, type_value => $search_tags[$i][0], type_values => ['search_tag', @search_fields], - type_labels => \%search_fields_labels, + type_labels => %search_fields_labels, contain_value => $search_tags[$i][1], contain_values => ["contains", "does_not_contain"], contain_labels => {"contains" => lang("search_contains"), "does_not_contain" => lang("search_does_not_contain")}, diff --git a/templates/search_form.tt.html b/templates/search_form.tt.html index 4e4c66c958d57..b7105164a5f8a 100644 --- a/templates/search_form.tt.html +++ b/templates/search_form.tt.html @@ -1,8 +1,8 @@

    [% lang('search_products') %]

    - + - [% start_form(id=>"search_form", action=>"/cgi/search.pl") %] +
    @@ -21,9 +21,21 @@

    [% lang('search_tags') %]

    [% FOREACH type IN criteria %]
    +
    - [% popup_menu(name=>"tagtype_${type.id}", id=>"tagtype_${type.id}", value=> type.type_value, values=> type.type_values, labels=> type.type_labels) %] + + + + +
    +
    [% popup_menu(name=>"tag_contains_${type.id}", id=>"tag_contains_${type.id}", value=> type.contain_value, values=> type.contain_values, labels=> type.contain_labels) %]
    @@ -82,7 +94,7 @@

    [% lang('search_nutriments') %]

      - +
    • [% lang('search_list_choice') %]

      From 6e1c0283281d14572d4202f402ed2d64413984ac Mon Sep 17 00:00:00 2001 From: areeshatariq Date: Wed, 8 Jul 2020 13:20:18 +0500 Subject: [PATCH 07/13] popup_menu wip --- cgi/search.pl | 69 ++++++++++++++++++++++++++++++++--- templates/search_form.tt.html | 22 ++++++++--- 2 files changed, 80 insertions(+), 11 deletions(-) diff --git a/cgi/search.pl b/cgi/search.pl index ff7dfccb26328..178c11c264db1 100755 --- a/cgi/search.pl +++ b/cgi/search.pl @@ -218,7 +218,6 @@ } } - if ($action eq 'display') { my $active_list = 'active'; @@ -234,34 +233,91 @@ $active_graph = 'active'; } - + my %search_fields_labels = (); + my @type_array; + my @contains; foreach my $field (@search_fields) { if ((not defined $tags_fields{$field}) and (lang($field) ne '')) { $search_fields_labels{$field} = lc(lang($field)); + } else { if ($field eq 'creator') { $search_fields_labels{$field} = lang("users_p"); + # push (@type_array, { + # type_values => $field, + # type_labels => $search_fields_labels{$field}, + # }); } else { $search_fields_labels{$field} = lang($field . "_p"); + # push (@type_array, { + # type_values => $field, + # type_labels => $search_fields_labels{$field}, + # }); } } + push (@type_array, { + type_values => $field, + type_labels => $search_fields_labels{$field}, + }); + } $search_fields_labels{search_tag} = lang("search_tag"); + push (@type_array, { + type_values => "search", + type_labels => $search_fields_labels{search_tag}, + }); + + my @contain_values = ["contains", "does_not_contain"]; + my %contain_labels = (); + # my %contain_labels = {"contains" => lang("search_contains"), "does_not_contain" => lang("search_does_not_contain")}; + + # @contains = [ + # { + # 'contain_values' => "contains", + # 'contain_labels' => lang("search_contains"), + # }, + # { + # 'contain_values' => "does_not_contain", + # 'contain_labels' => lang("search_does_not_contain"), + # } + # ]; + + foreach my $value (@contain_values){ + $contain_labels{$value} = lang("search_" . $value); + push (@contains, { + contain_values => $value, + contain_labels => $contain_labels{$value}, + }); + } + + # foreach my $elem (@search_fields){ + # push (@type_array, { + # type_values => $elem, + # type_labels => $search_fields_labels{$elem}, + # }); + # } for (my $i = 0; ($i < $tags_n) or defined param("tagtype_$i") ; $i++) { + # push (@type_array, { + # type_values => ['search_tag', @search_fields], + # type_labels => \%search_fields_labels, + # }); + + push @{$template_data_ref->{criteria}}, { id => $i, type_value => $search_tags[$i][0], - type_values => ['search_tag', @search_fields], - type_labels => %search_fields_labels, + # type_values => ['search_tag', @search_fields], + # type_labels => %search_fields_labels, + type_arrays => \@type_array, contain_value => $search_tags[$i][1], - contain_values => ["contains", "does_not_contain"], - contain_labels => {"contains" => lang("search_contains"), "does_not_contain" => lang("search_does_not_contain")}, + contain_array => \@contains, + # contain_labels => {"contains" => lang("search_contains"), "does_not_contain" => lang("search_does_not_contain")}, input_value => $search_tags[$i][2], }; @@ -393,6 +449,7 @@ $tt->process('search_form.tt.html', $template_data_ref, \$html); +$html .= "
      " . Dumper($template_data_ref) . "
      "; $html .= "

      " . $tt->error() . "

      "; ${$request_ref->{content_ref}} .= $html; diff --git a/templates/search_form.tt.html b/templates/search_form.tt.html index b7105164a5f8a..a7bd1ed6cf065 100644 --- a/templates/search_form.tt.html +++ b/templates/search_form.tt.html @@ -27,18 +27,30 @@

      [% lang('search_tags') %]

      - [% popup_menu(name=>"tag_contains_${type.id}", id=>"tag_contains_${type.id}", value=> type.contain_value, values=> type.contain_values, labels=> type.contain_labels) %] + + + [%FOREACH value in type.contain_array %] + [% IF value.type_labels == 'contains' %] + + [% ELSE %] + + [% END %] + [% END %] +
      +
      From e9292019c8cbd99d2f2b72c17052f501bb0b9280 Mon Sep 17 00:00:00 2001 From: areeshatariq Date: Thu, 16 Jul 2020 20:54:07 +0500 Subject: [PATCH 08/13] Search Form Templatization --- cgi/search.pl | 176 +++++++++++++++++++--------------- templates/search_form.tt.html | 73 +++++++++----- 2 files changed, 148 insertions(+), 101 deletions(-) diff --git a/cgi/search.pl b/cgi/search.pl index 178c11c264db1..22a3c2a466bef 100755 --- a/cgi/search.pl +++ b/cgi/search.pl @@ -57,11 +57,7 @@ # Passing values to the template my $template_data_ref = { - lang => \&lang, - popup_menu => \&popup_menu, - start_form => \&start_form, - }; my $criteria; @@ -245,32 +241,24 @@ else { if ($field eq 'creator') { $search_fields_labels{$field} = lang("users_p"); - # push (@type_array, { - # type_values => $field, - # type_labels => $search_fields_labels{$field}, - # }); } else { $search_fields_labels{$field} = lang($field . "_p"); - # push (@type_array, { - # type_values => $field, - # type_labels => $search_fields_labels{$field}, - # }); } } push (@type_array, { type_values => $field, type_labels => $search_fields_labels{$field}, }); - } + $search_fields_labels{search_tag} = lang("search_tag"); push (@type_array, { type_values => "search", type_labels => $search_fields_labels{search_tag}, }); - my @contain_values = ["contains", "does_not_contain"]; + my @contain_values = ("contains", "does_not_contain"); my %contain_labels = (); # my %contain_labels = {"contains" => lang("search_contains"), "does_not_contain" => lang("search_does_not_contain")}; @@ -286,34 +274,19 @@ # ]; foreach my $value (@contain_values){ - $contain_labels{$value} = lang("search_" . $value); + # push(@{ $contain_labels{$value} }, lang("search_" . $value)); + my $new_label = lang("search_" . $value); push (@contains, { contain_values => $value, - contain_labels => $contain_labels{$value}, + contain_labels => $new_label, }); } - - # foreach my $elem (@search_fields){ - # push (@type_array, { - # type_values => $elem, - # type_labels => $search_fields_labels{$elem}, - # }); - # } - for (my $i = 0; ($i < $tags_n) or defined param("tagtype_$i") ; $i++) { - - # push (@type_array, { - # type_values => ['search_tag', @search_fields], - # type_labels => \%search_fields_labels, - # }); - push @{$template_data_ref->{criteria}}, { id => $i, type_value => $search_tags[$i][0], - # type_values => ['search_tag', @search_fields], - # type_labels => %search_fields_labels, type_arrays => \@type_array, contain_value => $search_tags[$i][1], contain_array => \@contains, @@ -346,62 +319,116 @@ } push @axis_values, "additives_n", "ingredients_n", "known_ingredients_n", "unknown_ingredients_n"; push @axis_values, "fruits-vegetables-nuts-estimate-from-ingredients"; - $axis_labels{additives_n} = lang("number_of_additives"); - $axis_labels{ingredients_n} = lang("ingredients_n_s"); - $axis_labels{known_ingredients_n} = lang("known_ingredients_n_s"); - $axis_labels{unknown_ingredients_n} = lang("unknown_ingredients_n_s"); - $axis_labels{search_nutriment} = lang("search_nutriment"); - $axis_labels{products_n} = lang("number_of_products"); - my @sorted_axis_values = sort({ lc($axis_labels{$a}) cmp lc($axis_labels{$b}) } @axis_values); - + my @result_array; + + foreach my $entry (@sorted_axis_values) { + if ($entry ne ("additives_n") && $entry ne ("ingredients_n") && $entry ne ("known_ingredients_n") && $entry ne ("unknown_ingredients_n") && $entry ne ("search_nutriment") && $entry ne ("products_n")) { + my $sorted_labels = ucfirst($Nutriments{$entry}{$lc} || $Nutriments{$entry}{en}); + push (@result_array, { + values => $entry, + label => $sorted_labels, + }); + } + } + push (@result_array, { + values => "additives_n", + label => lang("number_of_additives"), + }); + push (@result_array, { + values => "ingredients_n", + label => lang("ingredients_n_s"), + }); + push (@result_array, { + values => "known_ingredients_n", + label => lang("known_ingredients_n_s"), + }); + push (@result_array, { + values => "unknown_ingredients_n", + label => lang("unknown_ingredients_n_s"), + }); + push (@result_array, { + values => "products_n", + label => lang("number_of_products"), + }); + + $template_data_ref->{result_array} = \@result_array; + my @axis_array = ('x','y'); + my @resultant_array; + foreach my $axis (@axis_array) { + push (@resultant_array, { + id => $axis, + results => \@result_array, + }); + } + $template_data_ref->{resultant_array} = \@resultant_array; + + my @nutriments = ( + { + 'values' => "lt", + 'label' => '<', + }, + { + 'values' => "lte", + 'label' => "\N{U+2264}", + }, + { + 'values' => "gt", + 'label' => '<', + }, + { + 'values' => "gte", + 'label' => "\N{U+2265}", + }, + { + 'values' => "eq", + 'label' => '=', + }, + ); + for (my $i = 0; $i < $nutriments_n ; $i++) { push @{$template_data_ref->{nutriments}}, { id => $i, - value => $search_nutriments[$i][0], - values => ["", @sorted_axis_values], - labels => \%axis_labels, - compare_value => $search_nutriments[$i][1], - compare_values => ['lt','lte','gt','gte','eq'], - compare_labels => {'lt' => '<', 'lte' => "\N{U+2264}", 'gt' => '>', 'gte' => "\N{U+2265}", 'eq' => '='}, + nutriment_values => \@result_array, + nutriment_array => \@nutriments, input_value => $search_nutriments[$i][2], - }; } # Different types to display results - push @{$template_data_ref->{popup_sort}}, { - value => $sort_by, - values => ['unique_scans_n','product_name','created_t','last_modified_t','completeness'], - labels => {unique_scans_n=>lang("sort_popularity"), product_name=>lang("sort_product_name"), created_t=>lang("sort_created_t"), last_modified_t=>lang("sort_modified_t"), completeness=>lang("sort_completeness")}, - - }; - - push @{$template_data_ref->{popup_size}}, { - value => $limit, - values => [20, 50, 100, 250, 500, 1000], - - }; + my @sort_array = ( + { + 'values' => "unique_scans_n", + 'label' => lang("sort_popularity"), + }, + { + 'values' => "product_name", + 'label' => lang("sort_product_name"), + }, + { + 'values' => "created_t", + 'label' => lang("sort_created_t"), + }, + { + 'values' => "last_modified_t", + 'label' => lang("sort_modified_t"), + }, + { + 'values' => "completeness", + 'label' => lang("sort_completeness"), + }, + ); + + push @{$template_data_ref->{sort_array}}, @sort_array; + push @{$template_data_ref->{sort_by}}, $sort_by; + + my @size_array =(20, 50, 100, 250, 500, 1000); + push @{$template_data_ref->{size_array}}, @size_array; $template_data_ref->{active_list} = $active_list; - - - # Graphs and visualization - - foreach my $axis ('x','y') { - - push @{$template_data_ref->{results}}, { - id => $axis, - value => $graph_ref->{"axis_" . $axis}, - values => ["", @sorted_axis_values], - labels => \%axis_labels, - - }; - - } foreach my $series (@search_series, "nutrition_grades") { @@ -449,7 +476,6 @@ $tt->process('search_form.tt.html', $template_data_ref, \$html); -$html .= "
      " . Dumper($template_data_ref) . "
      "; $html .= "

      " . $tt->error() . "

      "; ${$request_ref->{content_ref}} .= $html; diff --git a/templates/search_form.tt.html b/templates/search_form.tt.html index a7bd1ed6cf065..3685427dd88cf 100644 --- a/templates/search_form.tt.html +++ b/templates/search_form.tt.html @@ -2,7 +2,6 @@

      [% lang('search_products') %]

      -
      @@ -23,30 +22,29 @@

      [% lang('search_tags') %]

      - - - +
      - - - [%FOREACH value in type.contain_array %] - [% IF value.type_labels == 'contains' %] + +
      @@ -64,8 +62,8 @@

      [% lang('search_tags') %]

      [% lang('search_ingredients') %]

      - [% FOREACH type IN ingredients %] + [% FOREACH type IN ingredients %]
      @@ -75,7 +73,6 @@

      [% lang('search_ingredients') %]

      - [% END %]
      @@ -88,10 +85,22 @@

      [% lang('search_nutriments') %]

      - [% popup_menu(class=>"select2_field", name=>"nutriment_${type.id}", id=>"nutriment_${type.id}", value=> type.value, values=> type.values, labels=> type.labels) %] +
      - [% popup_menu(name=>"nutriment_compare_${type.id}", id=>"nutriment_compare_${type.id}", value=> type.compare_value, values=> type.compare_values, labels=> type.compare_labels) %] +
      @@ -113,15 +122,27 @@

      [% lang('search_nutriments') %]

      - [% FOREACH popup IN popup_sort %] - [% popup_menu(name=>"sort_by", id=>"sort_by", value=>popup.value, values=>popup.values, labels=>popup.labels ) %] - [% END %] +
      - [% FOREACH popup IN popup_size %] - [% popup_menu(name=>"page_size", id=>"page_size", value=>popup.value, values=>popup.values) %] - [% END %] +
      @@ -143,15 +164,15 @@

      [% lang('search_graph_choice') %]

      [% lang('search_graph_instructions') %]

      - [% FOREACH type IN results %] + [% FOREACH type IN resultant_array %]
      - - - [% popup_menu(class=>"select2_field", name=>"axis_${type.id}", id=>"axis_${type.id}", value=> type.value, values=> type.values, labels=> type.labels) %] - +
      - [% END %]
      From d0f8fb85be192c089e546c2c0233fa2550ae8eac Mon Sep 17 00:00:00 2001 From: areeshatariq Date: Mon, 3 Aug 2020 04:16:39 +0500 Subject: [PATCH 09/13] Removed commented code --- cgi/search.pl | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/cgi/search.pl b/cgi/search.pl index 22a3c2a466bef..c5aa51b122ff2 100755 --- a/cgi/search.pl +++ b/cgi/search.pl @@ -260,21 +260,8 @@ my @contain_values = ("contains", "does_not_contain"); my %contain_labels = (); - # my %contain_labels = {"contains" => lang("search_contains"), "does_not_contain" => lang("search_does_not_contain")}; - - # @contains = [ - # { - # 'contain_values' => "contains", - # 'contain_labels' => lang("search_contains"), - # }, - # { - # 'contain_values' => "does_not_contain", - # 'contain_labels' => lang("search_does_not_contain"), - # } - # ]; foreach my $value (@contain_values){ - # push(@{ $contain_labels{$value} }, lang("search_" . $value)); my $new_label = lang("search_" . $value); push (@contains, { contain_values => $value, @@ -290,7 +277,6 @@ type_arrays => \@type_array, contain_value => $search_tags[$i][1], contain_array => \@contains, - # contain_labels => {"contains" => lang("search_contains"), "does_not_contain" => lang("search_does_not_contain")}, input_value => $search_tags[$i][2], }; From 1efa1b88ab6dfede639134da2c68d1e100e9bda4 Mon Sep 17 00:00:00 2001 From: Areesha Tariq Date: Mon, 3 Aug 2020 04:23:38 +0500 Subject: [PATCH 10/13] Search Form Templatization (#3858) * Search Form WIP * popup_menu wip * Search Form Templatization * Removed commented code --- cgi/search.pl | 177 +++++++++++++++++++++++----------- templates/search_form.tt.html | 87 +++++++++++++---- 2 files changed, 189 insertions(+), 75 deletions(-) diff --git a/cgi/search.pl b/cgi/search.pl index 829ff229c430f..c5aa51b122ff2 100755 --- a/cgi/search.pl +++ b/cgi/search.pl @@ -57,11 +57,7 @@ # Passing values to the template my $template_data_ref = { - lang => \&lang, - popup_menu => \&popup_menu, - start_form => \&start_form, - }; my $criteria; @@ -218,7 +214,6 @@ } } - if ($action eq 'display') { my $active_list = 'active'; @@ -234,11 +229,14 @@ $active_graph = 'active'; } - + my %search_fields_labels = (); + my @type_array; + my @contains; foreach my $field (@search_fields) { if ((not defined $tags_fields{$field}) and (lang($field) ne '')) { $search_fields_labels{$field} = lc(lang($field)); + } else { if ($field eq 'creator') { @@ -248,20 +246,37 @@ $search_fields_labels{$field} = lang($field . "_p"); } } + push (@type_array, { + type_values => $field, + type_labels => $search_fields_labels{$field}, + }); } - $search_fields_labels{search_tag} = lang("search_tag"); + $search_fields_labels{search_tag} = lang("search_tag"); + push (@type_array, { + type_values => "search", + type_labels => $search_fields_labels{search_tag}, + }); + + my @contain_values = ("contains", "does_not_contain"); + my %contain_labels = (); + + foreach my $value (@contain_values){ + my $new_label = lang("search_" . $value); + push (@contains, { + contain_values => $value, + contain_labels => $new_label, + }); + } for (my $i = 0; ($i < $tags_n) or defined param("tagtype_$i") ; $i++) { - + push @{$template_data_ref->{criteria}}, { id => $i, type_value => $search_tags[$i][0], - type_values => ['search_tag', @search_fields], - type_labels => \%search_fields_labels, + type_arrays => \@type_array, contain_value => $search_tags[$i][1], - contain_values => ["contains", "does_not_contain"], - contain_labels => {"contains" => lang("search_contains"), "does_not_contain" => lang("search_does_not_contain")}, + contain_array => \@contains, input_value => $search_tags[$i][2], }; @@ -290,62 +305,116 @@ } push @axis_values, "additives_n", "ingredients_n", "known_ingredients_n", "unknown_ingredients_n"; push @axis_values, "fruits-vegetables-nuts-estimate-from-ingredients"; - $axis_labels{additives_n} = lang("number_of_additives"); - $axis_labels{ingredients_n} = lang("ingredients_n_s"); - $axis_labels{known_ingredients_n} = lang("known_ingredients_n_s"); - $axis_labels{unknown_ingredients_n} = lang("unknown_ingredients_n_s"); - $axis_labels{search_nutriment} = lang("search_nutriment"); - $axis_labels{products_n} = lang("number_of_products"); - my @sorted_axis_values = sort({ lc($axis_labels{$a}) cmp lc($axis_labels{$b}) } @axis_values); - + my @result_array; + + foreach my $entry (@sorted_axis_values) { + if ($entry ne ("additives_n") && $entry ne ("ingredients_n") && $entry ne ("known_ingredients_n") && $entry ne ("unknown_ingredients_n") && $entry ne ("search_nutriment") && $entry ne ("products_n")) { + my $sorted_labels = ucfirst($Nutriments{$entry}{$lc} || $Nutriments{$entry}{en}); + push (@result_array, { + values => $entry, + label => $sorted_labels, + }); + } + } + push (@result_array, { + values => "additives_n", + label => lang("number_of_additives"), + }); + push (@result_array, { + values => "ingredients_n", + label => lang("ingredients_n_s"), + }); + push (@result_array, { + values => "known_ingredients_n", + label => lang("known_ingredients_n_s"), + }); + push (@result_array, { + values => "unknown_ingredients_n", + label => lang("unknown_ingredients_n_s"), + }); + push (@result_array, { + values => "products_n", + label => lang("number_of_products"), + }); + + $template_data_ref->{result_array} = \@result_array; + my @axis_array = ('x','y'); + my @resultant_array; + foreach my $axis (@axis_array) { + push (@resultant_array, { + id => $axis, + results => \@result_array, + }); + } + $template_data_ref->{resultant_array} = \@resultant_array; + + my @nutriments = ( + { + 'values' => "lt", + 'label' => '<', + }, + { + 'values' => "lte", + 'label' => "\N{U+2264}", + }, + { + 'values' => "gt", + 'label' => '<', + }, + { + 'values' => "gte", + 'label' => "\N{U+2265}", + }, + { + 'values' => "eq", + 'label' => '=', + }, + ); + for (my $i = 0; $i < $nutriments_n ; $i++) { push @{$template_data_ref->{nutriments}}, { id => $i, - value => $search_nutriments[$i][0], - values => ["", @sorted_axis_values], - labels => \%axis_labels, - compare_value => $search_nutriments[$i][1], - compare_values => ['lt','lte','gt','gte','eq'], - compare_labels => {'lt' => '<', 'lte' => "\N{U+2264}", 'gt' => '>', 'gte' => "\N{U+2265}", 'eq' => '='}, + nutriment_values => \@result_array, + nutriment_array => \@nutriments, input_value => $search_nutriments[$i][2], - }; } # Different types to display results - push @{$template_data_ref->{popup_sort}}, { - value => $sort_by, - values => ['unique_scans_n','product_name','created_t','last_modified_t','completeness'], - labels => {unique_scans_n=>lang("sort_popularity"), product_name=>lang("sort_product_name"), created_t=>lang("sort_created_t"), last_modified_t=>lang("sort_modified_t"), completeness=>lang("sort_completeness")}, - - }; - - push @{$template_data_ref->{popup_size}}, { - value => $limit, - values => [20, 50, 100, 250, 500, 1000], - - }; + my @sort_array = ( + { + 'values' => "unique_scans_n", + 'label' => lang("sort_popularity"), + }, + { + 'values' => "product_name", + 'label' => lang("sort_product_name"), + }, + { + 'values' => "created_t", + 'label' => lang("sort_created_t"), + }, + { + 'values' => "last_modified_t", + 'label' => lang("sort_modified_t"), + }, + { + 'values' => "completeness", + 'label' => lang("sort_completeness"), + }, + ); + + push @{$template_data_ref->{sort_array}}, @sort_array; + push @{$template_data_ref->{sort_by}}, $sort_by; + + my @size_array =(20, 50, 100, 250, 500, 1000); + push @{$template_data_ref->{size_array}}, @size_array; $template_data_ref->{active_list} = $active_list; - - - # Graphs and visualization - - foreach my $axis ('x','y') { - - push @{$template_data_ref->{results}}, { - id => $axis, - value => $graph_ref->{"axis_" . $axis}, - values => ["", @sorted_axis_values], - labels => \%axis_labels, - - }; - - } foreach my $series (@search_series, "nutrition_grades") { diff --git a/templates/search_form.tt.html b/templates/search_form.tt.html index 4e4c66c958d57..3685427dd88cf 100644 --- a/templates/search_form.tt.html +++ b/templates/search_form.tt.html @@ -1,8 +1,7 @@

      [% lang('search_products') %]

      - + - [% start_form(id=>"search_form", action=>"/cgi/search.pl") %]
      @@ -21,12 +20,35 @@

      [% lang('search_tags') %]

      [% FOREACH type IN criteria %]
      +
      - [% popup_menu(name=>"tagtype_${type.id}", id=>"tagtype_${type.id}", value=> type.type_value, values=> type.type_values, labels=> type.type_labels) %] + + +
      +
      - [% popup_menu(name=>"tag_contains_${type.id}", id=>"tag_contains_${type.id}", value=> type.contain_value, values=> type.contain_values, labels=> type.contain_labels) %] + +
      +
      @@ -40,8 +62,8 @@

      [% lang('search_tags') %]

      [% lang('search_ingredients') %]

      - [% FOREACH type IN ingredients %] + [% FOREACH type IN ingredients %]
      @@ -51,7 +73,6 @@

      [% lang('search_ingredients') %]

      - [% END %]
      @@ -64,10 +85,22 @@

      [% lang('search_nutriments') %]

      - [% popup_menu(class=>"select2_field", name=>"nutriment_${type.id}", id=>"nutriment_${type.id}", value=> type.value, values=> type.values, labels=> type.labels) %] +
      - [% popup_menu(name=>"nutriment_compare_${type.id}", id=>"nutriment_compare_${type.id}", value=> type.compare_value, values=> type.compare_values, labels=> type.compare_labels) %] +
      @@ -82,22 +115,34 @@

      [% lang('search_nutriments') %]

        - +
      • [% lang('search_list_choice') %]

        - [% FOREACH popup IN popup_sort %] - [% popup_menu(name=>"sort_by", id=>"sort_by", value=>popup.value, values=>popup.values, labels=>popup.labels ) %] - [% END %] +
        - [% FOREACH popup IN popup_size %] - [% popup_menu(name=>"page_size", id=>"page_size", value=>popup.value, values=>popup.values) %] - [% END %] +
        @@ -119,15 +164,15 @@

        [% lang('search_graph_choice') %]

        [% lang('search_graph_instructions') %]

        - [% FOREACH type IN results %] + [% FOREACH type IN resultant_array %]
        - - - [% popup_menu(class=>"select2_field", name=>"axis_${type.id}", id=>"axis_${type.id}", value=> type.value, values=> type.values, labels=> type.labels) %] - +
        - [% END %]
        From e6ceb557b7dd94f32a3c04c97cc6b8cd89b7b015 Mon Sep 17 00:00:00 2001 From: Areesha Tariq Date: Mon, 3 Aug 2020 06:51:56 +0500 Subject: [PATCH 11/13] Fixed minor issue --- cgi/search.pl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cgi/search.pl b/cgi/search.pl index c5aa51b122ff2..faabf7fd54aed 100755 --- a/cgi/search.pl +++ b/cgi/search.pl @@ -798,7 +798,3 @@ } } } - -#my $out; -# $tt->process('search_form.tt.html', $template_data_ref, \$html || print "template error: " . $tt->error()); -# print "Template Result, $html, are"; From 5117c4d411d7a7421d79085aba1fe2571f01ecea Mon Sep 17 00:00:00 2001 From: areeshatariq Date: Tue, 4 Aug 2020 22:47:53 +0500 Subject: [PATCH 12/13] Fixed selected values issue and other minor issues --- cgi/search.pl | 70 +++++++++++++++++------------------ templates/search_form.tt.html | 42 ++++++++++----------- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/cgi/search.pl b/cgi/search.pl index c5aa51b122ff2..1816dff8848f9 100755 --- a/cgi/search.pl +++ b/cgi/search.pl @@ -231,7 +231,7 @@ my %search_fields_labels = (); - my @type_array; + my @type_options; my @contains; foreach my $field (@search_fields) { if ((not defined $tags_fields{$field}) and (lang($field) ne '')) { @@ -246,16 +246,16 @@ $search_fields_labels{$field} = lang($field . "_p"); } } - push (@type_array, { - type_values => $field, - type_labels => $search_fields_labels{$field}, + push (@type_options, { + value => $field, + label => $search_fields_labels{$field}, }); } $search_fields_labels{search_tag} = lang("search_tag"); - push (@type_array, { - type_values => "search", - type_labels => $search_fields_labels{search_tag}, + push (@type_options, { + value => "search", + label => $search_fields_labels{search_tag}, }); my @contain_values = ("contains", "does_not_contain"); @@ -264,8 +264,8 @@ foreach my $value (@contain_values){ my $new_label = lang("search_" . $value); push (@contains, { - contain_values => $value, - contain_labels => $new_label, + value => $value, + label => $new_label, }); } @@ -273,10 +273,10 @@ push @{$template_data_ref->{criteria}}, { id => $i, - type_value => $search_tags[$i][0], - type_arrays => \@type_array, - contain_value => $search_tags[$i][1], - contain_array => \@contains, + selected_type_value => $search_tags[$i][0], + type_options => \@type_options, + selected_contain_value => $search_tags[$i][1], + contain_options => \@contains, input_value => $search_tags[$i][2], }; @@ -312,29 +312,29 @@ if ($entry ne ("additives_n") && $entry ne ("ingredients_n") && $entry ne ("known_ingredients_n") && $entry ne ("unknown_ingredients_n") && $entry ne ("search_nutriment") && $entry ne ("products_n")) { my $sorted_labels = ucfirst($Nutriments{$entry}{$lc} || $Nutriments{$entry}{en}); push (@result_array, { - values => $entry, + value => $entry, label => $sorted_labels, }); } } push (@result_array, { - values => "additives_n", + value => "additives_n", label => lang("number_of_additives"), }); push (@result_array, { - values => "ingredients_n", + value => "ingredients_n", label => lang("ingredients_n_s"), }); push (@result_array, { - values => "known_ingredients_n", + value => "known_ingredients_n", label => lang("known_ingredients_n_s"), }); push (@result_array, { - values => "unknown_ingredients_n", + value => "unknown_ingredients_n", label => lang("unknown_ingredients_n_s"), }); push (@result_array, { - values => "products_n", + value => "products_n", label => lang("number_of_products"), }); @@ -344,30 +344,30 @@ foreach my $axis (@axis_array) { push (@resultant_array, { id => $axis, - results => \@result_array, + result_options => \@result_array, }); } - $template_data_ref->{resultant_array} = \@resultant_array; + $template_data_ref->{resultant_options} = \@resultant_array; my @nutriments = ( { - 'values' => "lt", + 'value' => "lt", 'label' => '<', }, { - 'values' => "lte", + 'value' => "lte", 'label' => "\N{U+2264}", }, { - 'values' => "gt", + 'value' => "gt", 'label' => '<', }, { - 'values' => "gte", + 'value' => "gte", 'label' => "\N{U+2265}", }, { - 'values' => "eq", + 'value' => "eq", 'label' => '=', }, ); @@ -376,8 +376,8 @@ push @{$template_data_ref->{nutriments}}, { id => $i, - nutriment_values => \@result_array, - nutriment_array => \@nutriments, + nutriments_options => \@result_array, + nutriment_options => \@nutriments, input_value => $search_nutriments[$i][2], }; @@ -387,32 +387,32 @@ my @sort_array = ( { - 'values' => "unique_scans_n", + 'value' => "unique_scans_n", 'label' => lang("sort_popularity"), }, { - 'values' => "product_name", + 'value' => "product_name", 'label' => lang("sort_product_name"), }, { - 'values' => "created_t", + 'value' => "created_t", 'label' => lang("sort_created_t"), }, { - 'values' => "last_modified_t", + 'value' => "last_modified_t", 'label' => lang("sort_modified_t"), }, { - 'values' => "completeness", + 'value' => "completeness", 'label' => lang("sort_completeness"), }, ); - push @{$template_data_ref->{sort_array}}, @sort_array; + push @{$template_data_ref->{sort_options}}, @sort_array; push @{$template_data_ref->{sort_by}}, $sort_by; my @size_array =(20, 50, 100, 250, 500, 1000); - push @{$template_data_ref->{size_array}}, @size_array; + push @{$template_data_ref->{size_options}}, @size_array; $template_data_ref->{active_list} = $active_list; diff --git a/templates/search_form.tt.html b/templates/search_form.tt.html index 3685427dd88cf..7989b837305e0 100644 --- a/templates/search_form.tt.html +++ b/templates/search_form.tt.html @@ -24,11 +24,11 @@

        [% lang('search_tags') %]

        - [% FOREACH value IN type.contain_array %] - [% IF value.contain_labels == 'contains' %] - + [% FOREACH value IN type.contain_options %] + [% IF value.value == type.selected_contain_value %] + [% ELSE %] - + [% END %] [% END %] @@ -86,18 +86,18 @@

        [% lang('search_nutriments') %]

        @@ -123,11 +123,11 @@

        [% lang('search_nutriments') %]

        @@ -135,7 +135,7 @@

        [% lang('search_nutriments') %]

        - [% FOREACH axistype IN type.results %] - + [% FOREACH axistype IN type.result_options %] + [% END %]
        From b6b0684e7b96905c0661f43a2aaac38ae8507f86 Mon Sep 17 00:00:00 2001 From: Areesha Tariq Date: Tue, 4 Aug 2020 23:04:17 +0500 Subject: [PATCH 13/13] selected_sort_by_value fix --- templates/search_form.tt.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/search_form.tt.html b/templates/search_form.tt.html index 2ae8e657b2c69..0fca728722046 100644 --- a/templates/search_form.tt.html +++ b/templates/search_form.tt.html @@ -124,7 +124,7 @@

        [% lang('search_nutriments') %]