diff --git a/.env.example b/.env.example
index 542983f36..9b9f93878 100644
--- a/.env.example
+++ b/.env.example
@@ -30,4 +30,3 @@ API_ISO3_ATTRIBUTE=XXXXXXXXXX
API_COUNTRY_NAME_ATTRIBUTE=XXXXXXXXXX
API_JRC_COUNTRY_AREA_ATTRIBUTE=XXXXXXXXXX
API_JRC_TERR_AREA_ATTRIBUTE=XXXXXXXXXX
-
diff --git a/app/assets/stylesheets/base/_base.scss b/app/assets/stylesheets/base/_base.scss
index ec5450711..8bc0c5581 100644
--- a/app/assets/stylesheets/base/_base.scss
+++ b/app/assets/stylesheets/base/_base.scss
@@ -42,6 +42,10 @@ h3 {
&.h3-big-white { @include h-big; color: $white; }
}
+
+h4 {
+ @include h4;
+}
p,a {
color: inherit;
diff --git a/app/assets/stylesheets/base/_buttons.scss b/app/assets/stylesheets/base/_buttons.scss
index 69f3cb862..83c1a8b9b 100644
--- a/app/assets/stylesheets/base/_buttons.scss
+++ b/app/assets/stylesheets/base/_buttons.scss
@@ -3,10 +3,8 @@
//--------------------------------------------------
$height-small: rem-calc(46);
$height-medium: rem-calc(56);
-
$padding-small: rem-calc(20);
$padding-medium: rem-calc(27);
-
//--------------------------------------------------
// base mixins
//--------------------------------------------------
@@ -14,9 +12,7 @@ $padding-medium: rem-calc(27);
border: none;
padding: 0;
}
-
@mixin button-basic {
- @include responsive(font-size, rem-calc(16), rem-calc(18), rem-calc(18));
background-color: transparent;
border: none;
color: inherit;
@@ -24,80 +20,74 @@ $padding-medium: rem-calc(27);
font-family: $body-font;
padding: 0;
text-decoration: none;
-
&:hover { text-decoration: none; }
}
-
-@mixin button-disabled { cursor: disabled; }
-
+@mixin button-font {
+ @include responsive(font-size, rem-calc(16), rem-calc(18), rem-calc(18));
+}
+@mixin button-disabled {
+ cursor: not-allowed;
+ opacity: .2;
+}
@mixin button-height {
@include responsive(height, $height-small, $height-medium, $height-medium);
-
display: inline-flex;
align-items: center;
}
-
-@mixin button-padding {
+@mixin button-padding($size: default) {
@include responsive(padding-right, $padding-small, $padding-medium, $padding-medium);
@include responsive(padding-left, $padding-small, $padding-medium, $padding-medium);
}
-
@mixin button-radius {
border-radius: $button-radius;
}
-
-
//--------------------------------------------------
// shared mixins
//--------------------------------------------------
@mixin button-block ($bg: $purple, $text: $white) {
@include button-basic;
@include button-height;
+ @include button-font;
@include button-padding;
@include button-radius;
background-color: $bg;
color: $text;
}
-
@mixin button-download {
@include button-basic;
@include button-height;
@include button-radius;
@include flex-center;
background-color: $primary;
+ font-size: rem-calc(18);
padding: 0 $padding-medium;
-
&::after {
@include icon-download-black;
content: '';
margin-left: rem-calc(10);
-
display: inline-block;
}
}
-
@mixin button-with-icon {
@include button-basic;
+ @include button-font;
@include flex;
@include flex-v-center;
-
&::after {
content: '';
margin-left: rem-calc(10);
-
display: inline-block;
}
}
-
-@mixin button-outline ($colour: $black, $border-size: 2px) {
+@mixin button-outline ($colour: $black) {
@include button-basic;
+ @include button-font;
@include button-height;
@include button-padding;
@include button-radius;
border: solid $border-size $colour;
color: $colour;
}
-
//--------------------------------------------------
// mixins for classes
//--------------------------------------------------
@@ -109,140 +99,106 @@ $padding-medium: rem-calc(27);
@include button-basic;
@include icon-cross;
}
-
@mixin button-download-trigger {
@include button-download;
}
-
@mixin button-download-trigger-small {
@include button-download;
@include responsive(padding, 0, 0 $padding-medium, 0 $padding-medium);
@include responsive(width, $height-small, auto, auto);
-
&::after {
@include responsive(margin-left, 0, rem-calc(10), rem-calc(10));
}
-
.download__trigger-text {
@include responsive(display, none, initial, initial);
}
}
-
@mixin button-dropdown {
@include button-with-icon;
&::after { @include icon-chevron-black-down; }
}
-
@mixin button-dropdown-up {
@include button-with-icon;
&::after { @include icon-chevron-black-up; }
}
-
-@mixin button-dropdown-filter {
- @include button-dropdown;
- @include button-outline($black, 1px);
-
- @include breakpoint-down($medium) {
- font-size: rem-calc(16);
- padding: rem-calc(1 11);
- height: rem-calc(34);
- }
-
- &:after {
- @include breakpoint-down($medium) { display: none; }
- }
-}
-
@mixin button-filter-trigger {
@include button-with-icon;
@include button-outline;
@include breakpoint-down($small) { padding: rem-calc(0 12); }
-
&::after {
@include icon-filters;
@include breakpoint-down($small) { margin: 0; }
}
-
.button__text { @include responsive(display, none, inline, inline); }
}
-
-@mixin button-link {
- @include button-basic;
- font-size: rem-calc(18);
-
- &:hover { text-decoration: underline;}
-}
-
@mixin button-map-trigger {
@include button-with-icon;
@include button-outline;
&::after { @include icon-pin-outline; }
}
-
@mixin button-next { @include button-basic; }
@mixin button-prev { @include button-basic; }
-
@mixin button-search {
@include button-basic;
+ @include button-font;
@include button-radius;
background-color: $primary;
width: rem-calc(47); height: rem-calc(47);
-
&:before {
@include icon-search-white;
content: '';
margin: 0 auto;
}
}
-
+@mixin button-tab-rounded($size: default) {
+ @include button-basic;
+ border: solid transparent 1px;
+ border-radius: rem-calc(20);
+ @if $size == 'small' {
+ font-size: rem-calc(14);
+ padding: rem-calc(6 16);
+ } @else {
+ @include text-tabs-fake;
+ padding: rem-calc(5 26);
+ }
+ &:hover,
+ .active { border-color: $primary; }
+ &.active {
+ background-color: $primary;
+ color: $white;
+ }
+}
//--------------------------------------------------
// classes
//--------------------------------------------------
.button {
&--accent { @include button-block; }
-
&--all {
@include button-with-icon;
@include flex-no-shrink;
-
&::after { @include icon-circle-chevron-black; }
}
-
&--download {
@include button-with-icon;
-
&::after {
@include icon-download;
display: inline-block;
}
}
-
&--external {
@include button-with-icon;
@include button-block;
font-weight: $bold;
-
&::after { @include icon-arrow-external-white; }
}
-
&--link-external {
@include button-with-icon;
-
&::after {
@include icon-arrow-external;
display: inline-block;
}
}
-
- &--link { @include button-link; }
-
- &--link-bold {
- @include button-link;
- font-weight: $bold;
- }
-
&--outline-black { @include button-outline($black); }
&--outline-white { @include button-outline($white); }
-
&--primary { @include button-block; }
-}
\ No newline at end of file
+}
diff --git a/app/assets/stylesheets/base/mixins/_icons.scss b/app/assets/stylesheets/base/mixins/_icons.scss
index e7753c5fa..55572508a 100644
--- a/app/assets/stylesheets/base/mixins/_icons.scss
+++ b/app/assets/stylesheets/base/mixins/_icons.scss
@@ -200,6 +200,10 @@ $icon-search-width: rem-calc(21);
@include icon-image('pin-outline.svg', rem-calc(14), rem-calc(20));
}
+@mixin icon-placeholder-image() {
+ @include icon-basic;
+ @include icon-image('image.svg', rem-calc(114), rem-calc(91));
+}
@mixin icon-region() { @include icon-earth(); }
@mixin icon-search() {
diff --git a/app/assets/stylesheets/base/mixins/_layout.scss b/app/assets/stylesheets/base/mixins/_layout.scss
index 1a15f82c3..463293380 100644
--- a/app/assets/stylesheets/base/mixins/_layout.scss
+++ b/app/assets/stylesheets/base/mixins/_layout.scss
@@ -7,7 +7,8 @@
@mixin container-medium {
@include container;
- @include breakpoint($large){ width: $site-width-medium-desktop; }
+ @include breakpoint($small){ max-width: $site-width-medium-desktop; }
+ @include breakpoint($medium){ width: $site-width-medium-desktop; }
}
@mixin gutters($sides:'both', $type:'padding') {
diff --git a/app/assets/stylesheets/base/mixins/_text.scss b/app/assets/stylesheets/base/mixins/_text.scss
index 6ae1beeb9..47a8ec3c7 100644
--- a/app/assets/stylesheets/base/mixins/_text.scss
+++ b/app/assets/stylesheets/base/mixins/_text.scss
@@ -61,6 +61,7 @@
@mixin h4 {
@include text-2;
@include responsive(font-size, rem-calc(18), rem-calc(18), rem-calc(16));
+ margin: 1.5em 0 .8em 0;
}
@mixin h-big {
diff --git a/app/assets/stylesheets/components/_filters.scss b/app/assets/stylesheets/components/_filters.scss
index 439f052b0..64f01b10e 100644
--- a/app/assets/stylesheets/components/_filters.scss
+++ b/app/assets/stylesheets/components/_filters.scss
@@ -1,7 +1,84 @@
//--------------------------------------------------
// classes
//--------------------------------------------------
+
.filters {
@import './filters/filters-pame';
@import './filters/filters-sidebar';
-}
\ No newline at end of file
+}
+
+.filter {
+ &__pane {
+ @include responsive(background-color, $grey-xlight, transparent, transparent);
+ @include responsive(top, 0, unset, unset);
+ @include responsive(left, 0, unset, unset);
+ width: 100%; height: 100vh;
+
+ position: fixed;
+ top: 0;
+ bottom: 0;
+ z-index: $z-100;
+
+ @include breakpoint($small) {
+ border-right: solid 1px $grey;
+ margin-right: rem-calc(24);
+ height: 100%;
+
+ position: initial;
+ top: unset;
+ bottom: unset;
+ }
+ }
+
+ &__pane-view {
+ @include flex;
+ @include flex-center;
+ background-color: $grey-xdark;
+ color: $white;
+ font-size: rem-calc(20);
+ font-weight: $bold;
+ width: 100%; height: rem-calc(63);
+
+ position: absolute;
+ bottom: 0;
+
+ @include breakpoint($small) { display: none; }
+ }
+
+ &__pane-topbar {
+ @include flex;
+ @include flex-v-center;
+ border-bottom: solid 1px $grey;
+ padding-right: rem-calc(24);
+ padding-left: rem-calc(24);
+ width: 100%; height: calc(#{$filters-title-height}px);
+
+ @include breakpoint($small) { display: none; }
+ }
+
+ &__pane-title { font-size: rem-calc(18); }
+
+ &__filter-groups {
+ @include responsive(overflow, scroll, initial, initial);
+ @include responsive(padding, rem-calc(24 22), rem-calc(24 22 24 0), rem-calc(24 22 24 0));
+ @include responsive(height, calc(100vh - #{$filters-title-height}px - #{$filters-button-close}px), 100%, 100%);
+ width: 100%;
+ }
+
+ &__group {
+ margin-bottom: rem-calc(24);
+ }
+
+ &__options {
+ @include text-filter;
+ overflow-y: scroll;
+ max-height: rem-calc(250);
+ }
+
+ &__trigger {
+ @include button-filter-trigger;
+
+ &.disabled { @include button-disabled; }
+ }
+>>>>>>> refresh
+}
diff --git a/app/assets/stylesheets/components/_footer.scss b/app/assets/stylesheets/components/_footer.scss
index 4d601a404..66f66b751 100644
--- a/app/assets/stylesheets/components/_footer.scss
+++ b/app/assets/stylesheets/components/_footer.scss
@@ -10,7 +10,7 @@
&__col {
@include responsive(margin, rem-calc(0 0 34 0), rem-calc(0 0 30 0), rem-calc(0 30));
- &:first-child() {
+ &:first-child {
@include responsive(display, none, none, block);
margin-left: 0;
}
@@ -24,7 +24,7 @@
@include responsive(width, 100%, 46%, auto);
}
- &:last-child() {
+ &:last-child {
@include text-small;
@include responsive(width, auto, auto, rem-calc(186));
color: white;
@@ -43,7 +43,7 @@
&__link-partner {
text-decoration: none;
- &:first-child() { margin-right: rem-calc(24); }
+ &:first-child { margin-right: rem-calc(24); }
}
&__logo-partner {
diff --git a/app/assets/stylesheets/components/_map.scss b/app/assets/stylesheets/components/_map.scss
index 23e54192d..2130af6a2 100644
--- a/app/assets/stylesheets/components/_map.scss
+++ b/app/assets/stylesheets/components/_map.scss
@@ -13,6 +13,10 @@
&__trigger {
@include button-map-trigger;
margin-right: rem-calc(16);
+
+ @include breakpoint-down($small) { display: none; }
+
+ &.disabled { @include button-disabled; }
}
&--search {
diff --git a/app/assets/stylesheets/components/_search.scss b/app/assets/stylesheets/components/_search.scss
index 6f403294e..0f42dd855 100644
--- a/app/assets/stylesheets/components/_search.scss
+++ b/app/assets/stylesheets/components/_search.scss
@@ -20,6 +20,9 @@ $search-input-size-desktop: 547px; //px
&--pa {
height: 0;
+ position: relative; //make sure the dropdown sits on top of map
+ z-index: 1; //make sure the dropdown sits on top of map
+
.search {
&__container {
@include flex;
diff --git a/app/assets/stylesheets/components/_tabs.scss b/app/assets/stylesheets/components/_tabs.scss
index 585562899..01f6fe13b 100644
--- a/app/assets/stylesheets/components/_tabs.scss
+++ b/app/assets/stylesheets/components/_tabs.scss
@@ -1,11 +1,40 @@
//--------------------------------------------------
// variables
//--------------------------------------------------
+//--------------------------------------------------
+// mixins for tabs
+//--------------------------------------------------
+@mixin tabs-horizontal-scroll {
+ @include flex;
+ overflow-x: scroll;
+
+ @include breakpoint($medium){
+ overflow-x: initial;
+
+ flex-wrap: wrap;
+ }
+}
+
+@mixin tabs-rounded {
+ @include ul-unstyled;
+ @include tabs-horizontal-scroll;
+ margin: rem-calc(26 0);
+
+ @include breakpoint($small) { margin: rem-calc(26 0 32 0); }
+ @include breakpoint($medium) { margin: rem-calc(30 0 10 0); }
+ .tab {
+ &__trigger {
+ @include button-tab-rounded;
+ @include flex-no-shrink;
+ margin: rem-calc(0 10);
+ }
+ }
+}
//--------------------------------------------------
-// mixins
+// mixins for tab
//--------------------------------------------------
-@mixin tab-trigger {
+@mixin tab-trigger-underlined {
@include text-tabs-fake;
border-bottom: solid transparent 2px;
cursor: pointer;
@@ -23,49 +52,88 @@
//--------------------------------------------------
// classes
//--------------------------------------------------
+.tabs {
//--------------------------------------------------
// tabs hero
//--------------------------------------------------
-.tabs--hero {
- .tabs__scrollable {
- overflow-x: scroll;
+ &--hero {
+ .tabs__triggers {
+ @include ul-unstyled;
+ @include ul-inline;
+ @include tabs-horizontal-scroll;
- transform: translateY(-100%);
- }
+ transform: translateY(-100%);
+ }
- .tabs__triggers {
- @include ul-unstyled;
- @include ul-inline;
- width: fit-content;
+ .tab {
+ &__trigger { @include tab-trigger-underlined; }
- display: flex;
- }
+ &__target {
+ display: none;
- .tab__target {
- display: none;
+ &.active { display: block; }
+ }
+ }
+ }
+//--------------------------------------------------
+// tabs search main
+//--------------------------------------------------
+&--search-main {
+ @include tabs-rounded;
- &.active { display: block; }
+ .tab {
+ &__trigger {
+ &:first-child { margin-left: 0; }
+ }
}
+}
+//--------------------------------------------------
+// tabs search areas
+//--------------------------------------------------
+&--search-areas {
+ @include tabs-rounded;
- .tab__trigger {
- @include tab-trigger;
+ @include breakpoint($small) { justify-content: center; }
- &.active { color: $primary; }
+ .tab {
+ &__trigger {
+ &:first-child { margin-left: 0; }
+ }
}
}
+
//--------------------------------------------------
-// tabs fake
+// tabs small
//--------------------------------------------------
-.tabs--fake {
- @include flex;
- @include ul-unstyled;
- @include responsive(flex-wrap, nowrap, nowrap, wrap);
- @include responsive(overflow-x, scroll, scroll, initial);
- @include responsive(margin, rem-calc(26 0), rem-calc(26 0 32 0), rem-calc(30 0 10 0));
-
- .tab__trigger {
- @include flex-no-shrink;
- @include tab-trigger;
- @include responsive(margin-bottom, 0, 0, rem-calc(10));
+ &--rounded-small {
+ @include ul-unstyled;
+ margin: rem-calc(0 0 10 0);
+
+ .tab {
+ &__trigger {
+ @include button-tab-rounded(small);
+ margin: rem-calc(0 4);
+ display: inline-block;
+ }
+ }
}
-}
+//--------------------------------------------------
+// tabs underlined
+//--------------------------------------------------
+ &--underlined {
+ @include tabs-horizontal-scroll;
+ @include ul-unstyled;
+ margin: rem-calc(26 0);
+
+ @include breakpoint($small){ margin: rem-calc(26 0 32 0); }
+ @include breakpoint($medium){ margin: rem-calc(30 0 10 0); }
+
+ .tab {
+ &__trigger {
+ @include flex-no-shrink;
+ @include tab-trigger-underlined;
+ @include breakpoint($medium){ margin-bottom: rem-calc(10); }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/assets/stylesheets/components/cards/cards/_cards-articles.scss b/app/assets/stylesheets/components/cards/cards/_cards-articles.scss
index 4e60f8478..60cc5b996 100644
--- a/app/assets/stylesheets/components/cards/cards/_cards-articles.scss
+++ b/app/assets/stylesheets/components/cards/cards/_cards-articles.scss
@@ -28,15 +28,7 @@
&__summary { margin: 0 }
&__image {
- @include flex-center;
- background-color: $grey-light;
- background-position: center;
- background-size: cover;
- width: 100%; height: rem-calc(265);
- }
-
- &__icon {
- // @include icon-placeholder-image;
+ @include image-placeholder();
}
}
-}
\ No newline at end of file
+}
diff --git a/app/assets/stylesheets/components/cards/cards/_cards-search-results-areas.scss b/app/assets/stylesheets/components/cards/cards/_cards-search-results-areas.scss
index 8b738bd3a..97b5bdbfd 100644
--- a/app/assets/stylesheets/components/cards/cards/_cards-search-results-areas.scss
+++ b/app/assets/stylesheets/components/cards/cards/_cards-search-results-areas.scss
@@ -1,15 +1,12 @@
//--------------------------------------------------
// variables
//--------------------------------------------------
-$card-search-results-areas-flag-size: rem-calc(60);
+$card-search-results-areas-width: 100%;
+$card-search-results-areas-height: rem-calc(155);
//--------------------------------------------------
// mixins
//--------------------------------------------------
-@mixin card-search-results-areas-flag-size {
- width: $card-search-results-areas-flag-size;
- height: $card-search-results-areas-flag-size;
-}
//--------------------------------------------------
// classes
@@ -44,28 +41,18 @@ $card-search-results-areas-flag-size: rem-calc(60);
}
&__image {
- width: 100%; height: rem-calc(114);
+ background-position: center;
+ background-size: cover;
+ width: $card-search-results-areas-width; height: $card-search-results-areas-height;
+ }
+
+ &__image-placeholder {
+ @include image-placeholder($card-search-results-areas-width, $card-search-results-areas-height);
}
&__title {
@include text-card-title;
margin: rem-calc(12 0 2 0);
}
-
- &__icon--region-large {
- @include icon-region;
- }
-
- &__icon--flag-large {
- @include icon-flag;
- }
-
- &__groups {
- margin-top: auto;
- }
-
- &__group {
- margin: rem-calc(10 0);
- }
}
-}
\ No newline at end of file
+}
diff --git a/app/assets/stylesheets/components/cards/cards/_cards-search-results.scss b/app/assets/stylesheets/components/cards/cards/_cards-search-results.scss
index 44b0f9f34..c488d18c9 100644
--- a/app/assets/stylesheets/components/cards/cards/_cards-search-results.scss
+++ b/app/assets/stylesheets/components/cards/cards/_cards-search-results.scss
@@ -1,4 +1,9 @@
//--------------------------------------------------
+// variables
+//--------------------------------------------------
+$search-results-image-width: rem-calc(165);
+$search-results-image-height: rem-calc(130);
+//--------------------------------------------------
// classes
//--------------------------------------------------
&--search-results {
@@ -12,7 +17,7 @@
}
&__content {
- width: rem-calc(550);
+ @include breakpoint($small) { width: calc(100% - #{$search-results-image-width} - 20px); }
}
&__summary {
@@ -24,7 +29,17 @@
}
&__image {
- width: rem-calc(165); height: rem-calc(130);
+ background-position: center;
+ background-size: cover;
+ width: $search-results-image-width; height: $search-results-image-height;
+
+ display: none;
+
+ @include breakpoint($small) { display: block; }
+ }
+
+ &__image-placeholder {
+ @include image-placeholder($search-results-image-width, $search-results-image-height);
}
}
}
\ No newline at end of file
diff --git a/app/assets/stylesheets/components/charts/_chart-column.scss b/app/assets/stylesheets/components/charts/_chart-column.scss
index 29e9cec13..fb3976a8d 100644
--- a/app/assets/stylesheets/components/charts/_chart-column.scss
+++ b/app/assets/stylesheets/components/charts/_chart-column.scss
@@ -15,7 +15,7 @@ $chart-column-width: 9%;
margin-left: $chart-column-margin;
width: $chart-column-width;
- &:first-child() { margin-left: 0; }
+ &:first-child { margin-left: 0; }
}
.chart__bar {
diff --git a/app/assets/stylesheets/components/form/_checkbox.scss b/app/assets/stylesheets/components/form/_checkbox.scss
index 6151cd674..0fdbd5003 100644
--- a/app/assets/stylesheets/components/form/_checkbox.scss
+++ b/app/assets/stylesheets/components/form/_checkbox.scss
@@ -24,13 +24,31 @@
@include input-hidden;
&:checked + .checkbox__input-fake {
- @include input-custom-checkbox-selected();
+ // @include input-custom-checkbox-selected();
+ background-color: $primary;
}
&:focus + .checkbox__input-fake { @include input-custom-focus; }
}
&__input-fake {
- @include input-custom-checkbox(rem-calc(20));
+ // @include input-custom-checkbox(rem-calc(20));
+ background-color: $white;
+ border-radius: $radius-global;
+ width: 100%; height: calc(100% - 5px);
+
+ position: absolute;
+ top: 0;
+ left: 0;
+ z-index: 0;
+ }
+
+ &__text {
+ min-height: rem-calc(34);
+ margin-bottom: rem-calc(5);
+ padding: rem-calc(10 6);
+
+ display: block;
+ z-index: 1;
}
}
\ No newline at end of file
diff --git a/app/assets/stylesheets/components/form/_input.scss b/app/assets/stylesheets/components/form/_input.scss
index 1da8d0e50..1a479d01e 100644
--- a/app/assets/stylesheets/components/form/_input.scss
+++ b/app/assets/stylesheets/components/form/_input.scss
@@ -2,4 +2,13 @@ input {
@include input-basic;
@include input-text;
height: rem-calc(47);
+}
+
+//--------------------------------------------------
+// classes
+//--------------------------------------------------
+.input--search {
+ width: 100%;
+
+
}
\ No newline at end of file
diff --git a/app/assets/stylesheets/components/search/_search-autocomplete.scss b/app/assets/stylesheets/components/search/_search-autocomplete.scss
index 9db6a2242..3d2259033 100644
--- a/app/assets/stylesheets/components/search/_search-autocomplete.scss
+++ b/app/assets/stylesheets/components/search/_search-autocomplete.scss
@@ -2,21 +2,29 @@
// variables
//--------------------------------------------------
$search-autocomplete-border: solid 2px $grey;
-$search-autocomplete-height-mobile: rem-calc(75);
+$search-autocomplete-height-mobile: rem-calc(46);
$search-autocomplete-height-tablet: rem-calc(75);
$search-autocomplete-width-tablet: rem-calc(760);
$search-autocomplete-border-radius: calc(#{$search-autocomplete-height-tablet}/2);
$search-autocomplete-select-width: rem-calc(222);
+
//--------------------------------------------------
// classes
//--------------------------------------------------
&--autocomplete {
- @include responsive(width, 100%, $search-autocomplete-width-tablet, $search-autocomplete-width-tablet);
+ margin: 0 auto;
+ width: 100%;
position: relative;
z-index: 1;
- .search__bar & { margin: rem-calc(0 120 0 20); }
+ @include breakpoint($small) { width: $search-autocomplete-width-tablet; }
+
+ .search__bar & {
+ margin: rem-calc(0 20 0 20);
+
+ @include breakpoint($small) { margin: rem-calc(0 120 0 20); }
+ }
.search {
@@ -24,58 +32,61 @@ $search-autocomplete-select-width: rem-calc(222);
&__search {
&--active {
- .search__search-input {
+ .search__search-input {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
}
}
- &__search-input {
- @include input-plain;
- @include input-basic;
- @include input-text;
- @include responsive(height, $search-autocomplete-height-mobile, $search-autocomplete-height-tablet, $search-autocomplete-height-tablet);
- border: $search-autocomplete-border;
- border-radius: $search-autocomplete-border-radius;
- padding-right: rem-calc(200);
- padding-left: rem-calc(60);
- width: 100%;
-
- .search__bar & { @include responsive(height, rem-calc(49), rem-calc(49), rem-calc(49)); }
-
- &::-ms-clear { display: none; }
+ &__search-input {
+ @include input-plain;
+ @include input-basic;
+ @include input-text;
+ border: $search-autocomplete-border;
+ border-radius: $search-autocomplete-border-radius;
+ padding-right: rem-calc(20);
+ padding-left: rem-calc(60);
+ width: 100%; height: $search-autocomplete-height-mobile;
+
+ @include breakpoint($small) { height: $search-autocomplete-height-tablet; }
+
+ .search__bar & {
+ height: rem-calc(49);
}
- &__search-icon {
- @include icon-search;
+ &::-ms-clear { display: none; }
+ }
- position: absolute;
- top: 50%;
- left: rem-calc(16);
+ &__search-icon {
+ @include icon-search;
- transform: translateY(-50%);
- }
+ position: absolute;
+ top: 50%;
+ left: rem-calc(16);
- &__search-icon--delete {
- @include button-close;
+ transform: translateY(-50%);
+ }
- position: absolute;
- top: 50%;
- right: calc(#{$search-autocomplete-select-width} + 16px);
+ &__search-icon--delete {
+ @include button-close;
- transform: translateY(-50%) scale(.7);
- }
+ position: absolute;
+ top: 50%;
+ right: rem-calc(26);
+
+ transform: translateY(-50%) scale(.7);
+ }
&__dropdown {
@include input-basic;
- @include ul-unstyled;
background-color: $white;
border: $search-autocomplete-border;
border-bottom-left-radius: $search-autocomplete-border-radius;
border-bottom-right-radius: $search-autocomplete-border-radius;
- padding: rem-calc(50 0 34 0);
- width: 100%;
+ overflow-y: scroll;
+ padding: rem-calc(36 0 34 0);
+ width: 100%;
position: absolute;
top: 50%;
@@ -83,19 +94,26 @@ $search-autocomplete-select-width: rem-calc(222);
z-index: -1;
}
- &__li {
-
- }
+ &__ul {
+ @include ul-unstyled;
+ overflow-y: scroll;
+ padding-top: rem-calc(14);
+ max-height: rem-calc(240);
+ }
+
+ &__li {
- &__a {
- @include input-text;
- padding: rem-calc(10 40);
- text-decoration: none;
- width: 100%;
+ }
- display: block;
+ &__a {
+ @include input-text;
+ padding: rem-calc(10 40);
+ text-decoration: none;
+ width: 100%;
- &:hover { background-color: $grey-light; }
- }
- }
-}
\ No newline at end of file
+ display: block;
+
+ &:hover { background-color: $grey-light; }
+ }
+ }
+ }
\ No newline at end of file
diff --git a/app/assets/stylesheets/components/search/_search-results-areas.scss b/app/assets/stylesheets/components/search/_search-results-areas.scss
index cba5211f4..0ed4282c5 100644
--- a/app/assets/stylesheets/components/search/_search-results-areas.scss
+++ b/app/assets/stylesheets/components/search/_search-results-areas.scss
@@ -20,41 +20,49 @@
padding: rem-calc(20 0);
}
- &__bar-content {
- @include container;
- @include site-width;
- @include flex;
- @include flex-v-center;
- }
+ &__bar-content {
+ @include container;
+ @include site-width;
+ @include flex;
+ @include flex-v-center;
+ }
&__main {
@include container;
- @include flex;
@include site-width;
+
+ @include breakpoint($small) { display: flex; }
+ }
+
+ &__filters {
+ @include flex-no-shrink;
+ @include responsive(padding-right, 0, rem-calc(24), rem-calc(24));
+ @include responsive(width, 0, 33%, 25%);
}
- &__filters {
- @include flex-no-shrink;
- @include responsive(padding-right, 0, rem-calc(24), rem-calc(24));
- @include responsive(width, 0, 33%, 25%);
- }
+ &__results {
+ @include flex-grow;
+ min-height: rem-calc(300);
- &__results {
- @include flex-grow;
- }
+ @include breakpoint($small) { min-height: rem-calc(600); }
+ }
- &__results-none {
- font-size: rem-calc(20);
- font-weight: $bold;
- padding: rem-calc(30 0);
- text-align: center;
- }
+ &__results-none {
+ font-size: rem-calc(20);
+ font-weight: $bold;
+ padding: rem-calc(30 0);
+ text-align: center;
+ }
- &__results-bar {
- @include flex;
- @include flex-h-between;
- @include flex-v-center;
- }
+ &__results-bar {
+ @include flex;
+ @include flex-h-between;
+ @include flex-v-center;
+ }
+
+ &__spinner {
+ padding-top: rem-calc(55);
+ }
&__map {
@include container;
diff --git a/app/assets/stylesheets/components/search/_search-results.scss b/app/assets/stylesheets/components/search/_search-results.scss
index cb7a6d3f4..76512765d 100644
--- a/app/assets/stylesheets/components/search/_search-results.scss
+++ b/app/assets/stylesheets/components/search/_search-results.scss
@@ -15,6 +15,7 @@
@include text-tabs-fake;
font-weight: bold;
color: $grey;
+ margin: rem-calc(24 0 24 0);
}
}
}
\ No newline at end of file
diff --git a/app/assets/stylesheets/helpers/_helpers.scss b/app/assets/stylesheets/helpers/_helpers.scss
index 367d3cff5..9e9bdf9cb 100644
--- a/app/assets/stylesheets/helpers/_helpers.scss
+++ b/app/assets/stylesheets/helpers/_helpers.scss
@@ -3,6 +3,7 @@
@import './beautify-scrollbar';
@import './border-and-shadows';
@import './form-fields';
+@import './images';
@mixin limit_lines($number, $line-height: 1.25) {
overflow-y: hidden;
@@ -103,6 +104,7 @@
}
.margin-space--right { margin-right: rem-calc(14); }
+.margin-space--bottom { margin-bottom: rem-calc(14); }
.margin-space--left { margin-left: rem-calc(14); }
.no-padding { padding: 0; }
diff --git a/app/assets/stylesheets/helpers/_images.scss b/app/assets/stylesheets/helpers/_images.scss
new file mode 100644
index 000000000..923d196fd
--- /dev/null
+++ b/app/assets/stylesheets/helpers/_images.scss
@@ -0,0 +1,25 @@
+//--------------------------------------------------
+// variables
+//--------------------------------------------------
+
+
+//--------------------------------------------------
+// mixins
+//--------------------------------------------------
+@mixin image-placeholder($width: 100%, $height: rem-calc(265)) {
+ @include flex-center;
+ background-color: $grey-light;
+ background-position: center;
+ background-size: cover;
+ width: $width; height: $height;
+
+ &::after {
+ @include icon-placeholder-image;
+ width: 30%;
+ content: '';
+ }
+}
+
+//--------------------------------------------------
+// classes
+//--------------------------------------------------
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index f5c702a8e..7eb99c2e2 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -9,6 +9,8 @@ class PageNotFound < StandardError; end;
before_action :set_locale
before_action :load_cms_content
before_action :check_for_pdf
+ #Temporary fix for development. To test if it is required on staging/production
+ before_action :set_host_for_local_storage
after_action :store_location
def set_cms_site
@@ -117,4 +119,9 @@ def store_location
session[:previous_url] = request.fullpath
end
end
+
+ def set_host_for_local_storage
+ Rails.application.routes.default_url_options[:host] = request.base_url if Rails.application.config.active_storage.service == :local
+ #ActiveStorage::Current.host = request.base_url if Rails.application.config.active_storage.service == :local
+ end
end
diff --git a/app/controllers/concerns/filterable.rb b/app/controllers/concerns/filterable.rb
deleted file mode 100644
index 6a516b86a..000000000
--- a/app/controllers/concerns/filterable.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-module Concerns::Filterable
- extend ActiveSupport::Concern
-
- included do
- private
-
- def load_filters
- @area_type = search_params[:area_type]
- @search_area_types = [
- {
- id: @area_type,
- title: I18n.t("global.area-types.#{@area_type}"),
- placeholder: I18n.t("global.placeholder.search-#{@area_type}")
- }
- ].to_json
-
- @filter_groups = [
- {
- title: I18n.t('global.search.view-by'),
- filters: [
- {
- id: 'geo_type',
- name: 'geo_type',
- options: [
- { id: 'all', title: I18n.t('global.search.view-group-geo-type.options')[0] },
- { id: 'regions', title: I18n.t('global.search.view-group-geo-type.options')[1] },
- { id: 'countries', title: I18n.t('global.search.view-group-geo-type.options')[2] },
- { id: 'sites', title: I18n.t('global.area-types.wdpa') } ## OR I18n.t('global.area-types.oecm')
- ],
- type: 'radio'
- }
- ]
- },
- {
- title: I18n.t('global.search.filter-by'),
- filters: [
- {
- id: 'is_type',
- name: 'is_type',
- options: [
- { id: 'all', title: I18n.t('global.search.filter-group-type.options')[0] },
- { id: 'terrestrial', title: I18n.t('global.search.filter-group-type.options')[1] },
- { id: 'marine', title: I18n.t('global.search.filter-group-type.options')[2] }
- ],
- title: I18n.t('global.search.filter-group-type.title'),
- type: 'radio'
- },
- {
- id: 'designation',
- options: objs_for(Designation),
- title: I18n.t('global.search.filter-group-designation.title'),
- type: 'checkbox'
- },
- {
- id: 'governance',
- options: objs_for(Governance),
- title: I18n.t('global.search.filter-group-governance.title'),
- type: 'checkbox'
- },
- {
- id: 'iucn_category',
- options: objs_for(IucnCategory),
- title: I18n.t('global.search.filter-group-iucn-category.title'),
- type: 'checkbox'
- }
- ]
- }
- ].to_json
- end
-
- def objs_for(model)
- model.all.map { |obj| { id: obj.name, title: obj.name } }
- end
- end
-end
diff --git a/app/controllers/concerns/searchable.rb b/app/controllers/concerns/searchable.rb
index fa640bf5b..53682b902 100644
--- a/app/controllers/concerns/searchable.rb
+++ b/app/controllers/concerns/searchable.rb
@@ -5,52 +5,157 @@ module Concerns::Searchable
private
def ignore_empty_query
- @query = params['search_term'] rescue nil
- redirect_to :root if @query.blank? && filters.empty?
+ return render json: {} if search_params[:search_term].blank?
end
def load_search
+ @query = search_params[:search_term]
begin
@search = Search.search(@query, search_options, search_index)
rescue => e
Rails.logger.warn("error in search controller: #{e.message}")
@search = nil
end
-
- @main_filter = params[:main]
end
+ DEFAULT_PAGE = 1.freeze
+ DEFAULT_SIZE = 9.freeze
def search_options
options = {filters: filters}
- options[:page] = params['requested_page'].to_i if params['requested_page'].present?
- options[:size] = params['items_per_page'].to_i if params['items_per_page'].present?
+ requested_page = search_params[:requested_page].try(:to_i) || DEFAULT_PAGE
+ items_per_page = search_params[:items_per_page].try(:to_i) || DEFAULT_SIZE
+ options[:page] = requested_page
+ options[:size] = items_per_page
options
end
+ INDEX_BY_TYPE = {
+ 'site' => Search::PA_INDEX,
+ 'country' => Search::COUNTRY_INDEX,
+ 'region' => Search::REGION_INDEX,
+ 'all' => Search::DEFAULT_INDEX_NAME,
+ 'areas' => Search::PA_INDEX
+ }.freeze
def search_index
- controller_name.include?('area') ? Search::AREAS_INDEX_NAME : Search::DEFAULT_INDEX_NAME
+ _index = INDEX_BY_TYPE[parsed_filters['ancestor']] if parsed_filters
+ return _index if _index
+
+ INDEX_BY_TYPE[search_params[:geo_type]] || Search::DEFAULT_INDEX_NAME
end
- AREA_TYPES = %w(wdpa oecm).freeze
- def check_area_type
- redirect_to :root unless AREA_TYPES.include?(params[:area_type].downcase)
+ DB_TYPES = %w(wdpa oecm all).freeze
+ def check_db_type
+ return unless params[:db_type]
+ redirect_to :root unless DB_TYPES.include?(params[:db_type].downcase)
+ end
+
+ def load_search_from_query_string
+ @query = search_params[:search_term]
+ begin
+ if search_params[:filters].present?
+ @search = Search.search(@query, {}, search_index)
+ load_filters
+ @search = Search.search(@query, search_options, search_index)
+ else
+ @search = Search.search(@query, search_options, search_index)
+ end
+ rescue => e
+ Rails.logger.warn("error in search controller: #{e.message}")
+ @search = nil
+ end
end
+ #
+ # Retrieves the filters from params if present,
+ # and sanitizes them from escaped string format
+ #
def filters
- return '' unless params['filters'].present?
+ return '' unless search_params[:filters].present?
+ return '' if %w(country region).include?(search_params[:geo_type])
_filters = sanitise_filters
- _filters.symbolize_keys.slice(*Search::ALLOWED_FILTERS)
+ _filters.to_hash.symbolize_keys.slice(*Search::ALLOWED_FILTERS)
end
def sanitise_filters
- _filters = JSON.parse(params['filters'])
- #TODO green list filter to be added
- is_type = _filters.delete('is_type')
- return _filters if is_type == 'all' || !is_type
+ _filters = sanitise_location_filter(parsed_filters)
+ _filters = sanitise_db_type_filter(_filters)
+ _filters = sanitise_type_filter(_filters)
+ _filters = sanitise_ancestor_filter(_filters)
+ sanitise_special_status_filter(_filters)
+ end
+
+ #{'location' => {'type' => 'country', 'options' => ['Italy']}}
+ def sanitise_location_filter(filters)
+ if filters['location'].present? && filters['location']['options'].present?
+ filters[filters['location']['type'].to_sym] = filters['location']['options']
+ end
+
+ filters
+ end
+
+ def sanitise_db_type_filter(filters)
+ db_type = filters.delete('db_type')
+ db_type = db_type && db_type.reject { |i| i == 'all' }
+ return filters if db_type.blank? || db_type.length != 1
+
+ filters[:is_oecm] = true if db_type.first == 'oecm'
+ filters
+ end
+
+ def sanitise_type_filter(filters)
+ # ['marine', 'terrestrial', 'all']
+ is_type = filters.delete('is_type')
+ return filters if !is_type || is_type.include?('all') || is_type.length != 1
+
+ filters[:marine] = is_type.first == 'marine'
+ filters
+ end
+
+ FAKE_CATEGORIES = %w(all areas).freeze
+ def sanitise_ancestor_filter(filters)
+ ancestor = filters.delete('ancestor')
+
+ return filters if ancestor.blank? || FAKE_CATEGORIES.include?(ancestor)
+
+ filters['ancestor'] = ancestor.to_i
+
+ filters
+ end
+
+ def sanitise_special_status_filter(filters)
+ # ['has_parcc_info', 'is_green_list']
+ special_status = filters.delete('special_status')
+ return filters unless special_status
+
+ special_status.map do |status|
+ filters[status.to_sym] = true
+ end
+
+ filters
+ end
+
+ def load_filters
+ return if @filter_groups
+
+ @db_type = parsed_filters.present? && parsed_filters[:db_type].try(:first)
+ _db_type_id = @db_type || 'all'
+ @query ||= search_params[:search_term]
+ @search_db_types = [
+ {
+ id: _db_type_id,
+ title: I18n.t("global.area-types.#{_db_type_id}"),
+ placeholder: I18n.t("global.placeholder.search-#{_db_type_id}")
+ }
+ ].to_json
+
+ @filter_groups = @search ? Search::FiltersSerializer.new(@search).serialize : []
+ end
- _filters[:marine] = is_type == 'marine'
+ def parsed_filters
+ return @parsed_filters if @parsed_filters
- _filters
+ _filters = search_params[:filters]
+ @parsed_filters = _filters.is_a?(String) ? JSON.parse(_filters) : _filters
end
end
end
diff --git a/app/controllers/country_controller.rb b/app/controllers/country_controller.rb
index 01d05d4b1..ac06abcea 100644
--- a/app/controllers/country_controller.rb
+++ b/app/controllers/country_controller.rb
@@ -25,7 +25,9 @@ def show
@total_pame = @country.protected_areas.with_pame_evaluations.count
@total_wdpa = @country.protected_areas.count
- # #TODO need adding
+ #@wdpa = [] #get_wdpa TODO ??
+
+ ##TODO need adding
# protected_national_report: statistic_presenter.percentage_nr_marine_cover,
# national_report_version: statistic_presenter.nr_version,
diff --git a/app/controllers/green_list_controller.rb b/app/controllers/green_list_controller.rb
index 0c36cc9b4..c429c3385 100644
--- a/app/controllers/green_list_controller.rb
+++ b/app/controllers/green_list_controller.rb
@@ -10,6 +10,10 @@ def index
@pas_km = ProtectedArea.green_list_total_km
@pas_percent = ProtectedArea.green_list_protected_percentage
@pas_total = ProtectedArea.green_list_areas.count
+ @filters = {
+ db_type: ['wdpa'],
+ special_status: ['is_green_list']
+ }
end
def show
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index b0a5c1a46..347c98705 100644
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -1,17 +1,15 @@
class HomeController < ApplicationController
def index
- home_yml = I18n.t('home')
-
@pa_coverage_percentage = 9999 #TODO Total PA coverage in %
- @search_area_types = [
- { id: 'wdpa', title: I18n.t('global.area-types.wdpa'), placeholder: I18n.t('global.placeholder.search-wdpa') },
- { id: 'oecm', title: I18n.t('global.area-types.oecm'), placeholder: I18n.t('global.placeholder.search-oecms') }
- ].to_json
+ @config_search_areas = {
+ id: 'all',
+ placeholder: I18n.t('global.placeholder.search-oecm-wdpa')
+ }.to_json
@pas_title = home_yml[:pas][:title]
@pas_button = home_yml[:pas][:button]
- @pas_levels = home_yml[:pas][:levels]
+ @pas_levels = levels
@site_facts = [
{
@@ -76,4 +74,20 @@ def index
@carousel_slides = HomeCarouselSlide.all.select{|slide| slide.published }
end
+
+ private
+
+ def levels
+ _levels = home_yml[:pas][:levels]
+ _levels.map do |level|
+ geo_type = level.delete(:geo_type)
+ level[:url] = search_areas_path({geo_type: geo_type, filters: {db_type: ['wdpa']}})
+ level
+ end
+ end
+
+ def home_yml
+ @home_yml ||= I18n.t('home')
+ end
+
end
\ No newline at end of file
diff --git a/app/controllers/marine_controller.rb b/app/controllers/marine_controller.rb
index d16f6ddc9..e019020f2 100644
--- a/app/controllers/marine_controller.rb
+++ b/app/controllers/marine_controller.rb
@@ -27,6 +27,7 @@ def index
@pas_km = @marine_statistics['total_ocean_area_protected']
@pas_percent = @marine_statistics['total_ocean_pa_coverage_percentage']
@pas_total = @marine_statistics['total_marine_protected_areas']
+ @filters = { db_type: ['wdpa'], is_marine: true }
end
def download_designations
diff --git a/app/controllers/oecm_controller.rb b/app/controllers/oecm_controller.rb
index 755c68279..1afd7a616 100644
--- a/app/controllers/oecm_controller.rb
+++ b/app/controllers/oecm_controller.rb
@@ -2,11 +2,13 @@ class OecmController < ApplicationController
def index
@oecm_coverage_percentage = 10 ##TODO FERDI - percentage of the world covered by OECMs
- @search_area_types = [
- { id: 'oecm', title: I18n.t('global.area-types.wdpa'), placeholder: I18n.t('global.placeholder.search-oecms') }
- ].to_json
+ @config_search_areas = {
+ id: 'oecm',
+ placeholder: I18n.t('global.placeholder.search-oecm')
+ }.to_json
@tabs = get_tabs(3).to_json
+ @filters = { db_type: ['oecm'] }
end
private
diff --git a/app/controllers/search_areas_controller.rb b/app/controllers/search_areas_controller.rb
index c3a15cab1..dbe3a77a2 100644
--- a/app/controllers/search_areas_controller.rb
+++ b/app/controllers/search_areas_controller.rb
@@ -1,30 +1,47 @@
class SearchAreasController < ApplicationController
include Concerns::Searchable
- include Concerns::Filterable
after_action :enable_caching
- before_action :check_area_type, only: [:index, :search_results]
- before_action :ignore_empty_query, only: [:search_results]
+ before_action :check_db_type, only: [:index, :search_results]
before_action :load_search, only: [:search_results]
+ before_action :load_search_from_query_string, only: [:index]
before_action :load_filters, only: [:index, :search_results]
+ TABS = %w(region country site).freeze
def index
- @query = search_params[:search_term]
+ placeholder = @db_type ? @db_type : 'oecm-wdpa'
+
+ @config_search_areas = {
+ id: @db_type || 'all',
+ placeholder: I18n.t("global.placeholder.search-#{placeholder}")
+ }.to_json
+
+ @tabs = []
+
+ TABS.each do |tab|
+ @tabs << { id: tab, title: I18n.t("search.geo-types.#{tab}") }
+ end
+
+ geo_type = search_params[:geo_type] || 'site'
+ @filters = @db_type ? { db_type: @db_type } : {}
+ @results = Search::AreasSerializer.new(@search, geo_type).serialize
end
def search_results
- @query = search_params[:search_term]
- @area_type = search_params[:area_type]
geo_type = search_params[:geo_type]
@results = Search::AreasSerializer.new(@search, geo_type).serialize
- render json: @results
+ render json: { areas: @results, filters: @filter_groups }.to_json
end
private
def search_params
- params.permit(:search_term, :filters, :area_type, :geo_type, :items_per_page, :requested_page)
+ params.permit(
+ :search_term, :geo_type, :items_per_page, :requested_page, :filters,
+ filters: [db_type: [], is_type: [], special_status: [], designation: [], governance: [],
+ location: [:type, options: []]]
+ )
end
end
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index a4af9a763..49def77af 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -2,21 +2,32 @@ class SearchController < ApplicationController
include Concerns::Searchable
after_action :enable_caching
- before_action :ignore_empty_query, only: [:search_results, :search_results_areas]
- before_action :load_search, only: [:search_results, :search_results_areas]
+ before_action :ignore_empty_query, only: [ :search_results]
+ before_action :load_search, only: [:search_results]
def index
- @categories = [{ id: -1, title: 'All' }]
- Comfy::Cms::Page.root.children.map do |c|
- @categories << { id: c.id, title: c.label }
+ categories = I18n.t('search.categories')
+ cms_root_pages = Comfy::Cms::Page.root.children
+ @categories = []
+
+ categories.map do |category|
+ cms_page = cms_root_pages.find_by(slug: category)
+ if cms_page
+ @categories << { id: cms_page.id.to_s, title: cms_page.label}
+ else
+ @categories << { id: category, title: category.capitalize }
+ end
end
- @categories = @categories.to_json
@query = search_params[:search_term]
end
def search_results
- @results = Search::FullSerializer.new(@search, {page: search_params[:requested_page]}).serialize
+ _options = {
+ page: search_params[:requested_page],
+ per_page: search_params[:items_per_page]
+ }
+ @results = Search::FullSerializer.new(@search, _options).serialize
render json: @results
end
@@ -26,7 +37,7 @@ def map
end
def autocomplete
- @results = Autocompletion.lookup search_params[:search_term]
+ @results = Autocompletion.lookup(search_params[:search_term], search_params[:type])
render json: @results
end
@@ -34,6 +45,6 @@ def autocomplete
private
def search_params
- params.permit(:search_term, :type, :requested_page, :items_per_page)
+ params.permit(:search_term, :type, :requested_page, :items_per_page, :filters)
end
end
diff --git a/app/controllers/search_wdpa_controller.rb b/app/controllers/search_wdpa_controller.rb
deleted file mode 100644
index c27983083..000000000
--- a/app/controllers/search_wdpa_controller.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-class SearchWdpaController < ApplicationController
- include Concerns::Searchable
- include Concerns::Filterable
-
- before_action :ignore_empty_query, only: [:index]
- before_action :load_search, only: [:index]
- before_action :load_filters, only: [:index]
-
- def index
- @search_area_types = [
- { id: 'wdpa', title: I18n.t('global.area-types.wdpa'), placeholder: I18n.t('global.placeholder.search-wdpa') }
- ].to_json
-
- @results = Search::AreasSerializer.new(@search).serialize
- @query = params['search_term']
-
- render json: @results
- end
-
- private
-
- def search_params
- params.permit(:search_term, :filters)
- end
-end
diff --git a/app/controllers/wdpa_controller.rb b/app/controllers/wdpa_controller.rb
index 27127b156..09e5cd7cb 100644
--- a/app/controllers/wdpa_controller.rb
+++ b/app/controllers/wdpa_controller.rb
@@ -2,10 +2,12 @@ class WdpaController < ApplicationController
def index
@pa_coverage_percentage = 20 ##TODO FERDI - percentage of the world covered by PAs
- @search_area_types = [
- { id: 'wdpa', title: I18n.t('global.area-types.wdpa'), placeholder: I18n.t('global.placeholder.search-wdpa') }
- ].to_json
+ @config_search_areas = {
+ id: 'wdpa',
+ placeholder: I18n.t('global.placeholder.search-wdpa')
+ }.to_json
+ @filters = { db_type: ['wdpa'] }
@tabs = get_tabs(3).to_json
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index be87e398a..acf9a040b 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -47,6 +47,10 @@ def cover_placeholder klass
PLACEHOLDERS[klass]
end
+ def tiles_path(params)
+ Rails.application.routes.url_helpers.tiles_path(params)
+ end
+
def cover_data(image_params, item_class)
placeholder = cover_placeholder(item_class)
{
@@ -56,11 +60,13 @@ def cover_data(image_params, item_class)
}
end
- def protected_area_cover protected_area
+ def protected_area_cover(protected_area, with_tag: true)
version = Rails.application.secrets.mapbox[:version]
image_params = {id: protected_area.wdpa_id, type: "protected_area", version: version}
data = cover_data(image_params, protected_area.class)
+ return tiles_path(image_params) unless with_tag
+
image_tag(
cover_placeholder(protected_area.class),
{
@@ -70,18 +76,22 @@ def protected_area_cover protected_area
)
end
- def country_cover country
+ def country_cover(country, with_tag: true)
version = Rails.application.secrets.mapbox[:version]
image_params = {id: country.iso, type: "country", version: version}
data = cover_data(image_params, country.class)
+ return tiles_path(image_params) unless with_tag
+
image_tag(
cover_placeholder(country.class),
{alt: country.name}.merge(data)
)
end
- def region_cover region
+ def region_cover(region, with_tag: true)
+ return tiles_path(image_params) unless with_tag
+
image_tag(
cover_placeholder(region.class),
alt: region.name
diff --git a/app/helpers/home_helper.rb b/app/helpers/home_helper.rb
index a2311ab5d..b6b01439b 100644
--- a/app/helpers/home_helper.rb
+++ b/app/helpers/home_helper.rb
@@ -9,8 +9,17 @@ def pas_categories
{
image: cms_fragment_render(:theme_image, cms_page),
title: category[:title],
- url: 'filtered wdpa page' ##TODO filtered WDPA results page
+ url: search_areas_path(filters: get_filters(category[:filter]))
}
end
end
+
+ def get_filters(filter)
+ if filter == 'is_green_list'
+ { special_status: [filter] }
+ else
+ { is_type: [filter] }
+ end.merge(db_type: ['wdpa'])
+ end
+
end
diff --git a/app/javascript/components/card/CardSearchResult.vue b/app/javascript/components/card/CardSearchResult.vue
index f1f9e1215..aea73de59 100644
--- a/app/javascript/components/card/CardSearchResult.vue
+++ b/app/javascript/components/card/CardSearchResult.vue
@@ -2,7 +2,7 @@