From cc2070f1dedfd3d98e27aadadfe511c591b68810 Mon Sep 17 00:00:00 2001 From: Ben Tregenna Date: Thu, 9 Apr 2020 14:12:17 +0100 Subject: [PATCH 001/109] Updated db and yarn --- db | 2 +- yarn.lock | 139 ++++-------------------------------------------------- 2 files changed, 10 insertions(+), 131 deletions(-) diff --git a/db b/db index 2a5852e93..4c5c922f2 160000 --- a/db +++ b/db @@ -1 +1 @@ -Subproject commit 2a5852e93ff823eb1f1537e0c10badf35fed8fce +Subproject commit 4c5c922f2acf107805ff6170ae5571ddc3cbe8da diff --git a/yarn.lock b/yarn.lock index d8c61421a..11baff6a9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2534,7 +2534,7 @@ debug@=3.1.0: dependencies: ms "2.0.0" -debug@^3.0.0, debug@^3.1.1, debug@^3.2.5, debug@^3.2.6: +debug@^3.0.0, debug@^3.1.1, debug@^3.2.5: version "3.2.6" resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== @@ -2570,11 +2570,6 @@ deep-equal@^1.0.1: object-keys "^1.1.1" regexp.prototype.flags "^1.2.0" -deep-extend@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" - integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== - default-gateway@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/default-gateway/-/default-gateway-4.2.0.tgz#167104c7500c2115f6dd69b0a536bb8ed720552b" @@ -2658,11 +2653,6 @@ detect-file@^1.0.0: resolved "https://registry.yarnpkg.com/detect-file/-/detect-file-1.0.0.tgz#f0d66d03672a825cb1b73bdb3fe62310c8e552b7" integrity sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc= -detect-libc@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" - integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= - detect-node@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.0.4.tgz#014ee8f8f669c5c58023da64b8179c083a28c46c" @@ -3288,13 +3278,6 @@ from@^0.1.7: resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe" integrity sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4= -fs-minipass@^1.2.5: - version "1.2.7" - resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7" - integrity sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA== - dependencies: - minipass "^2.6.0" - fs-minipass@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-2.1.0.tgz#7f5036fdbf12c63c169190cbe4199c852271f9fb" @@ -3726,7 +3709,7 @@ https-browserify@^1.0.0: resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM= -iconv-lite@0.4, iconv-lite@0.4.24, iconv-lite@^0.4.4: +iconv-lite@0.4, iconv-lite@0.4.24: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== @@ -3750,13 +3733,6 @@ iferr@^0.1.5: resolved "https://registry.yarnpkg.com/iferr/-/iferr-0.1.5.tgz#c60eed69e6d8fdb6b3104a1fcbca1c192dc5b501" integrity sha1-xg7taebY/bazEEofy8ocGS3FtQE= -ignore-walk@^3.0.1: - version "3.0.3" - resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.3.tgz#017e2447184bfeade7c238e4aefdd1e8f95b1e37" - integrity sha512-m7o6xuOaT1aqheYHKf8W6J5pYH85ZI9w077erOzLje3JsB1gkafkAhHHY19dqjulgIZHFm32Cp5uNZgcQqdJKw== - dependencies: - minimatch "^3.0.4" - import-cwd@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/import-cwd/-/import-cwd-2.1.0.tgz#aa6cf36e722761285cb371ec6519f53e2435b0a9" @@ -3850,7 +3826,7 @@ inherits@2.0.3: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= -ini@^1.3.4, ini@^1.3.5, ini@~1.3.0: +ini@^1.3.4, ini@^1.3.5: version "1.3.5" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== @@ -4720,14 +4696,6 @@ minipass-pipeline@^1.2.2: dependencies: minipass "^3.0.0" -minipass@^2.6.0, minipass@^2.8.6, minipass@^2.9.0: - version "2.9.0" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.9.0.tgz#e713762e7d3e32fed803115cf93e04bca9fcc9a6" - integrity sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg== - dependencies: - safe-buffer "^5.1.2" - yallist "^3.0.0" - minipass@^3.0.0, minipass@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.1.1.tgz#7607ce778472a185ad6d89082aa2070f79cedcd5" @@ -4735,13 +4703,6 @@ minipass@^3.0.0, minipass@^3.1.1: dependencies: yallist "^4.0.0" -minizlib@^1.2.1: - version "1.3.3" - resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.3.3.tgz#2290de96818a34c29551c8a8d301216bd65a861d" - integrity sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q== - dependencies: - minipass "^2.9.0" - mississippi@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/mississippi/-/mississippi-3.0.0.tgz#ea0a3291f97e0b5e8776b363d5f0a12d94c67022" @@ -4835,15 +4796,6 @@ nanomatch@^1.2.9: snapdragon "^0.8.1" to-regex "^3.0.1" -needle@^2.2.1: - version "2.3.2" - resolved "https://registry.yarnpkg.com/needle/-/needle-2.3.2.tgz#3342dea100b7160960a450dc8c22160ac712a528" - integrity sha512-DUzITvPVDUy6vczKKYTnWc/pBZ0EnjMJnQ3y+Jo5zfKFimJs7S3HFCxCRZYB9FUZcrzUQr3WsmvZgddMEIZv6w== - dependencies: - debug "^3.2.6" - iconv-lite "^0.4.4" - sax "^1.2.4" - negotiator@0.6.2: version "0.6.2" resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb" @@ -4911,22 +4863,6 @@ node-libs-browser@^2.2.1: util "^0.11.0" vm-browserify "^1.0.1" -node-pre-gyp@*: - version "0.14.0" - resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.14.0.tgz#9a0596533b877289bcad4e143982ca3d904ddc83" - integrity sha512-+CvDC7ZttU/sSt9rFjix/P05iS43qHCOOGzcr3Ry99bXG7VX953+vFyEuph/tfqoYu8dttBkE86JSKBO2OzcxA== - dependencies: - detect-libc "^1.0.2" - mkdirp "^0.5.1" - needle "^2.2.1" - nopt "^4.0.1" - npm-packlist "^1.1.6" - npmlog "^4.0.2" - rc "^1.2.7" - rimraf "^2.6.1" - semver "^5.3.0" - tar "^4.4.2" - node-releases@^1.1.49: version "1.1.49" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.49.tgz#67ba5a3fac2319262675ef864ed56798bb33b93e" @@ -4964,14 +4900,6 @@ node-sass@^4.13.0: dependencies: abbrev "1" -nopt@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d" - integrity sha1-0NRoWv1UFRk8jHUFYC0NF81kR00= - dependencies: - abbrev "1" - osenv "^0.1.4" - normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: version "2.5.0" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" @@ -5014,27 +4942,6 @@ normalize-url@^3.0.0: resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-3.3.0.tgz#b2e1c4dc4f7c6d57743df733a4f5978d18650559" integrity sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg== -npm-bundled@^1.0.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.1.1.tgz#1edd570865a94cdb1bc8220775e29466c9fb234b" - integrity sha512-gqkfgGePhTpAEgUsGEgcq1rqPXA+tv/aVBlgEzfXwA1yiUJF7xtEt3CtVwOjNYQOVknDk0F20w58Fnm3EtG0fA== - dependencies: - npm-normalize-package-bin "^1.0.1" - -npm-normalize-package-bin@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/npm-normalize-package-bin/-/npm-normalize-package-bin-1.0.1.tgz#6e79a41f23fd235c0623218228da7d9c23b8f6e2" - integrity sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA== - -npm-packlist@^1.1.6: - version "1.4.8" - resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.4.8.tgz#56ee6cc135b9f98ad3d51c1c95da22bbb9b2ef3e" - integrity sha512-5+AZgwru5IevF5ZdnFglB5wNlHG1AOOuw28WhUq8/8emhBmLv6jX5by4WJCh7lW0uSYZYS6DXqIsyZVIXRZU9A== - dependencies: - ignore-walk "^3.0.1" - npm-bundled "^1.0.1" - npm-normalize-package-bin "^1.0.1" - npm-run-path@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" @@ -5042,7 +4949,7 @@ npm-run-path@^2.0.0: dependencies: path-key "^2.0.0" -"npmlog@0 || 1 || 2 || 3 || 4", npmlog@^4.0.0, npmlog@^4.0.2: +"npmlog@0 || 1 || 2 || 3 || 4", npmlog@^4.0.0: version "4.1.2" resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" integrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg== @@ -5222,7 +5129,7 @@ os-tmpdir@^1.0.0: resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= -osenv@0, osenv@^0.1.4: +osenv@0: version "0.1.5" resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.5.tgz#85cdfafaeb28e8677f416e287592b5f3f49ea410" integrity sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g== @@ -6332,16 +6239,6 @@ raw-body@2.4.0: iconv-lite "0.4.24" unpipe "1.0.0" -rc@^1.2.7: - version "1.2.8" - resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" - integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== - dependencies: - deep-extend "^0.6.0" - ini "~1.3.0" - minimist "^1.2.0" - strip-json-comments "~2.0.1" - read-cache@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/read-cache/-/read-cache-1.0.0.tgz#e664ef31161166c9751cdbe8dbcf86b5fb58f774" @@ -6594,7 +6491,7 @@ rgba-regex@^1.0.0: resolved "https://registry.yarnpkg.com/rgba-regex/-/rgba-regex-1.0.0.tgz#43374e2e2ca0968b0ef1523460b7d730ff22eeb3" integrity sha1-QzdOLiyglosO8VI0YLfXMP8i7rM= -rimraf@2, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.3, rimraf@^2.7.1: +rimraf@2, rimraf@^2.5.4, rimraf@^2.6.3, rimraf@^2.7.1: version "2.7.1" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== @@ -6674,7 +6571,7 @@ save@^2.4.0: lodash.assign "^4.2.0" mingo "1" -sax@^1.2.4, sax@~1.2.4: +sax@~1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== @@ -6721,7 +6618,7 @@ selfsigned@^1.10.7: dependencies: node-forge "0.9.0" -"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0: +"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -7224,11 +7121,6 @@ strip-indent@^1.0.1: dependencies: get-stdin "^4.0.1" -strip-json-comments@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" - integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= - style-loader@^1.0.0: version "1.1.3" resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-1.1.3.tgz#9e826e69c683c4d9bf9db924f85e9abb30d5e200" @@ -7305,19 +7197,6 @@ tar@^2.0.0: fstream "^1.0.12" inherits "2" -tar@^4.4.2: - version "4.4.13" - resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.13.tgz#43b364bc52888d555298637b10d60790254ab525" - integrity sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA== - dependencies: - chownr "^1.1.1" - fs-minipass "^1.2.5" - minipass "^2.8.6" - minizlib "^1.2.1" - mkdirp "^0.5.0" - safe-buffer "^5.1.2" - yallist "^3.0.3" - terser-webpack-plugin@^1.4.3: version "1.4.3" resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-1.4.3.tgz#5ecaf2dbdc5fb99745fd06791f46fc9ddb1c9a7c" @@ -7975,7 +7854,7 @@ yallist@^2.1.2: resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= -yallist@^3.0.0, yallist@^3.0.2, yallist@^3.0.3: +yallist@^3.0.2: version "3.1.1" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== From 52358b8d9c7cb99b62e398751c6a7b5d372b998d Mon Sep 17 00:00:00 2001 From: stacytalbot Date: Tue, 5 May 2020 11:46:39 +0100 Subject: [PATCH 002/109] Update autocomplete to only take 1 idea and remove multiple types --- .../stylesheets/components/_search.scss | 3 + .../search/_search-autocomplete.scss | 2 +- app/controllers/home_controller.rb | 8 +- app/controllers/oecm_controller.rb | 7 +- app/controllers/search_wdpa_controller.rb | 7 +- app/controllers/wdpa_controller.rb | 7 +- .../components/search/SearchAreas.vue | 12 +-- .../components/search/SearchAreasHome.vue | 20 +++-- .../search/SearchAreasInputAutocomplete.vue | 77 +++---------------- app/views/home/index.html.erb | 3 +- app/views/oecm/index.html.erb | 5 +- .../partials/search/_protected-areas.html.erb | 2 +- .../_tabs-thematic-area-database.html.erb | 2 +- app/views/search_areas/index.html.erb | 2 +- app/views/wdpa/index.html.erb | 5 +- config/locales/global/en.yml | 3 +- 16 files changed, 57 insertions(+), 108 deletions(-) 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/search/_search-autocomplete.scss b/app/assets/stylesheets/components/search/_search-autocomplete.scss index 9db6a2242..132e6ec7f 100644 --- a/app/assets/stylesheets/components/search/_search-autocomplete.scss +++ b/app/assets/stylesheets/components/search/_search-autocomplete.scss @@ -62,7 +62,7 @@ $search-autocomplete-select-width: rem-calc(222); position: absolute; top: 50%; - right: calc(#{$search-autocomplete-select-width} + 16px); + right: rem-calc(26); transform: translateY(-50%) scale(.7); } diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 63e6bd58b..b88e24c9e 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -4,10 +4,10 @@ def index @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] diff --git a/app/controllers/oecm_controller.rb b/app/controllers/oecm_controller.rb index 755c68279..1d5680eb9 100644 --- a/app/controllers/oecm_controller.rb +++ b/app/controllers/oecm_controller.rb @@ -2,9 +2,10 @@ 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 end diff --git a/app/controllers/search_wdpa_controller.rb b/app/controllers/search_wdpa_controller.rb index c27983083..ece14a1ca 100644 --- a/app/controllers/search_wdpa_controller.rb +++ b/app/controllers/search_wdpa_controller.rb @@ -7,9 +7,10 @@ class SearchWdpaController < ApplicationController 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 + @config_search_areas = { + id: 'all', + placeholder: I18n.t('global.placeholder.search-wdpa') + }.to_json @results = Search::AreasSerializer.new(@search).serialize @query = params['search_term'] diff --git a/app/controllers/wdpa_controller.rb b/app/controllers/wdpa_controller.rb index 27127b156..b4f906665 100644 --- a/app/controllers/wdpa_controller.rb +++ b/app/controllers/wdpa_controller.rb @@ -2,9 +2,10 @@ 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 @tabs = get_tabs(3).to_json end diff --git a/app/javascript/components/search/SearchAreas.vue b/app/javascript/components/search/SearchAreas.vue index df264a399..83a995fcf 100644 --- a/app/javascript/components/search/SearchAreas.vue +++ b/app/javascript/components/search/SearchAreas.vue @@ -8,9 +8,9 @@ /> @@ -80,9 +80,9 @@ export default { mixins: [ mixinAxiosHelpers ], props: { - autocompleteAreaTypes: { - type: Array, // [ { name: String, options: [ { id: Number, name: String } ] } ] - required: true + configAutocomplete: { + required: true, + type: Object // { id: String, placeholder: String } }, endpointAutocomplete: { type: String, @@ -136,7 +136,6 @@ export default { data () { return { activeFilterOptions: [], - areaType: '', currentPage: 0, defaultPage: 1, isFilterPaneActive: false, @@ -168,7 +167,6 @@ export default { ajaxSubmission () { let data = { params: { - area_type: this.areaType, filters: this.activeFilterOptions, items_per_page: 3, search_term: this.searchTerm @@ -226,7 +224,6 @@ export default { updateSearchTerm (searchParams) { this.resetFilters() this.$eventHub.$emit('reset-pagination') - this.areaType = searchParams.type this.searchTerm = searchParams.search_term this.ajaxSubmission() }, @@ -236,7 +233,6 @@ export default { let data = { params: { - area_type: this.areaType, filters: this.activeFilterOptions, geo_type: paginationParams.geoType, items_per_page: this.items_per_page, diff --git a/app/javascript/components/search/SearchAreasHome.vue b/app/javascript/components/search/SearchAreasHome.vue index 0bb55afe0..0305314f6 100644 --- a/app/javascript/components/search/SearchAreasHome.vue +++ b/app/javascript/components/search/SearchAreasHome.vue @@ -1,8 +1,8 @@ @@ -83,23 +56,21 @@ export default { ], props: { + config: { + required: true, + type: Object // { id: String, placeholder: String } + }, endpoint: { required: true, type: String }, - prePopulatedSearchTerm: String, - types: { - required: true, - type: Array // [ { id: String, title: String, placeholder: String } ] } ] - } + prePopulatedSearchTerm: String }, data () { return { autocomplete: [], // [ { title: String, url: String } ] - searchTerm: '', - typeDropdownActive: false, - selectedTypeIndex: 0, + searchTerm: '' } }, @@ -107,24 +78,12 @@ export default { hasAutocompleteOptions () { return this.autocomplete.length > 0 }, - hasMultipleTypes () { - return this.types.length > 1 - }, searchParams () { return { - type: this.selectedTypeId, - search_term: this.searchTerm + search_term: this.searchTerm, + type: this.config.id } }, - selectedPlaceholder () { - return this.types[this.selectedTypeIndex].placeholder - }, - selectedTypeId () { - return this.types[this.selectedTypeIndex].id - }, - selectedTypeTitle () { - return this.types[this.selectedTypeIndex].title - }, showResetIcon () { return this.searchTerm.length != 0 } @@ -132,9 +91,6 @@ export default { mounted () { if(this.prePopulatedSearchTerm) { this.searchTerm = this.prePopulatedSearchTerm } - // this.addTabFromSearchListener() - // this.addArrowKeyListeners() - // this.addTabForwardFromResetListener() }, methods: { @@ -157,21 +113,6 @@ export default { }) }, - updateType (type, index) { - this.selectedTypeIndex = index - this.type = type.id - this.placeholder = type.placeholder - this.toggleTypes() - this.resetSearchTerm() - this.resetAutocomplete() - }, - - toggleTypes () { - if(!this.hasMultipleTypes) { return false } - - this.typeDropdownActive = !this.typeDropdownActive - }, - resetSearchTerm () { this.searchTerm = '' this.resetAutocomplete() diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 7b7b4e7e3..1c32dea59 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -4,7 +4,8 @@ hero_stat_text: t('home.hero.stat-text') } %> -<%= render "partials/search/protected-areas" %> + +<%= render "partials/search/protected-areas", locals: { config: @config_search_areas } %>

<%= @pas_title %>

diff --git a/app/views/oecm/index.html.erb b/app/views/oecm/index.html.erb index d93b856a6..9d55386af 100644 --- a/app/views/oecm/index.html.erb +++ b/app/views/oecm/index.html.erb @@ -13,7 +13,10 @@ %>
- <%= render partial: "partials/tabs/tabs-thematic-area-database", locals: { tabs: @tabs } %> + <%= render partial: "partials/tabs/tabs-thematic-area-database", locals: { + config_search: @config_search_areas, + tabs: @tabs + } %>
diff --git a/app/views/partials/search/_protected-areas.html.erb b/app/views/partials/search/_protected-areas.html.erb index 03e981456..917dee65f 100644 --- a/app/views/partials/search/_protected-areas.html.erb +++ b/app/views/partials/search/_protected-areas.html.erb @@ -1,7 +1,7 @@
diff --git a/app/views/partials/tabs/_tabs-thematic-area-database.html.erb b/app/views/partials/tabs/_tabs-thematic-area-database.html.erb index 231777eaf..0368187d0 100644 --- a/app/views/partials/tabs/_tabs-thematic-area-database.html.erb +++ b/app/views/partials/tabs/_tabs-thematic-area-database.html.erb @@ -9,7 +9,7 @@
- <%= render "partials/search/protected-areas" %> + <%= render partial: "partials/search/protected-areas", locals: { config: config_search } %>
diff --git a/app/views/search_areas/index.html.erb b/app/views/search_areas/index.html.erb index 9f03bb8f6..f51397296 100644 --- a/app/views/search_areas/index.html.erb +++ b/app/views/search_areas/index.html.erb @@ -3,7 +3,7 @@
- <%= render partial: "partials/tabs/tabs-thematic-area-database", locals: { tabs: @tabs } %> + <%= render partial: "partials/tabs/tabs-thematic-area-database", locals: { + config_search: @config_search_areas, + tabs: @tabs + } %>
diff --git a/config/locales/global/en.yml b/config/locales/global/en.yml index 6b576fb69..95a467a78 100644 --- a/config/locales/global/en.yml +++ b/config/locales/global/en.yml @@ -24,7 +24,8 @@ en: email: "Email: %{email}" visit: "Visit: %{link}" placeholder: - search-oecms: Search for OECMs... + search-oecm-wdpa: Search for a protected area or OECM... + search-oecm: Search for an OECM... search-wdpa: Search for a protected area... search-site: Search... search: From 0f2fc9cfa5ecd7b2f58cce977c7ee3bbd2812d11 Mon Sep 17 00:00:00 2001 From: stacytalbot Date: Tue, 5 May 2020 12:03:26 +0100 Subject: [PATCH 003/109] Fix up missing variable --- app/controllers/search_areas_controller.rb | 5 +++++ app/controllers/search_wdpa_controller.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/search_areas_controller.rb b/app/controllers/search_areas_controller.rb index c3a15cab1..f512a3226 100644 --- a/app/controllers/search_areas_controller.rb +++ b/app/controllers/search_areas_controller.rb @@ -10,6 +10,11 @@ class SearchAreasController < ApplicationController before_action :load_filters, only: [:index, :search_results] def index + @config_search_areas = { + id: 'all', + placeholder: I18n.t('global.placeholder.search-oecm-wdpa') + }.to_json + @query = search_params[:search_term] end diff --git a/app/controllers/search_wdpa_controller.rb b/app/controllers/search_wdpa_controller.rb index ece14a1ca..98ceef6ae 100644 --- a/app/controllers/search_wdpa_controller.rb +++ b/app/controllers/search_wdpa_controller.rb @@ -9,7 +9,7 @@ class SearchWdpaController < ApplicationController def index @config_search_areas = { id: 'all', - placeholder: I18n.t('global.placeholder.search-wdpa') + placeholder: I18n.t('global.placeholder.search-oecm-wdpa') }.to_json @results = Search::AreasSerializer.new(@search).serialize From 53dd82f439e5bcfae8ec2bdc604490b0154c9ca4 Mon Sep 17 00:00:00 2001 From: Ferdinando Primerano Date: Thu, 7 May 2020 13:14:02 +0100 Subject: [PATCH 004/109] Refactor autocomplete to use ElasticSearch and without limit --- lib/modules/autocompletion.rb | 37 +++++++++++++++-------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/lib/modules/autocompletion.rb b/lib/modules/autocompletion.rb index 40ffa3b91..aa3f5fe5b 100644 --- a/lib/modules/autocompletion.rb +++ b/lib/modules/autocompletion.rb @@ -1,34 +1,29 @@ module Autocompletion - AUTOCOMPLETION_KEY = "autocompletion" + AUTOCOMPLETION_KEY = "autocompletion".freeze + IDENTIFIER_FIELDS = { + 'protected_area' => :wdpa_id, + 'country' => :iso_3 + }.freeze - def self.lookup term - limit = {limit: [0, 5]} + def self.lookup(term, search_index=Search::PA_INDEX) + search = Search.search(term.downcase, {}, search_index) - $redis.zrangebylex(AUTOCOMPLETION_KEY, "(#{term.downcase}", "+", limit).map do |result| - result = result.split("||") + results = search.results.objects.values.compact.flatten - term = result[0] - name = result[1] - type = result[2] - identifier = result[3] + results.map do |result| + name = result.name + type = result.class.name.underscore + identifier = result.send(identifier_field(type)) - url = type == 'protected_area' ? "/#{identifier}" : "/country/#{identifier}" + url = type == 'country' ? "/country/#{identifier}" : "/#{identifier}" { title: name, url: url } end end - def self.populate - ProtectedArea.pluck(:name, :wdpa_id).each do |name, wdpa_id| - $redis.zadd(AUTOCOMPLETION_KEY, 0, "#{name.downcase}||#{name}||protected_area||#{wdpa_id}") - end - - Country.pluck(:name, :iso).each do |name, iso| - $redis.zadd(AUTOCOMPLETION_KEY, 0, "#{name.downcase}||#{name}||country||#{iso}") - end - end + private - def self.drop - $redis.del(AUTOCOMPLETION_KEY) + def self.identifier_field(type) + IDENTIFIER_FIELDS[type] || :id end end From e5862750f14e3f8471eb66785527c11f1e4bcf6f Mon Sep 17 00:00:00 2001 From: stacytalbot Date: Fri, 22 May 2020 11:09:07 +0100 Subject: [PATCH 005/109] Start to refactor the search so that it works with 1 set of results rather than an Array of results grouped by geo type --- app/controllers/concerns/filterable.rb | 24 ++++++++-------- app/controllers/search_areas_controller.rb | 8 ++++++ .../components/search/SearchAreas.vue | 21 ++++++++++---- .../components/search/SearchAreasResults.vue | 28 +++++++++---------- ...eoType.vue => SearchAreasResultsItems.vue} | 20 ++++++------- app/javascript/components/tabs/TabsFake.vue | 2 +- app/serializers/search/areas_serializer.rb | 4 +-- app/views/search/index.html.erb | 4 +-- app/views/search_areas/index.html.erb | 9 +++--- config/deploy/staging.rb | 2 +- config/locales/en.yml | 8 +----- config/locales/global/en.yml | 26 ----------------- config/locales/search/en.yml | 27 ++++++++++++++++++ 13 files changed, 98 insertions(+), 85 deletions(-) rename app/javascript/components/search/{SearchAreasGeoType.vue => SearchAreasResultsItems.vue} (95%) create mode 100644 config/locales/search/en.yml diff --git a/app/controllers/concerns/filterable.rb b/app/controllers/concerns/filterable.rb index 6a516b86a..f7d7d2d7b 100644 --- a/app/controllers/concerns/filterable.rb +++ b/app/controllers/concerns/filterable.rb @@ -16,15 +16,15 @@ def load_filters @filter_groups = [ { - title: I18n.t('global.search.view-by'), + title: I18n.t('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: 'all', title: I18n.t('search.view-group-geo-type.options')[0] }, + { id: 'regions', title: I18n.t('search.view-group-geo-type.options')[1] }, + { id: 'countries', title: I18n.t('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' @@ -32,35 +32,35 @@ def load_filters ] }, { - title: I18n.t('global.search.filter-by'), + title: I18n.t('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] } + { id: 'all', title: I18n.t('search.filter-group-type.options')[0] }, + { id: 'terrestrial', title: I18n.t('search.filter-group-type.options')[1] }, + { id: 'marine', title: I18n.t('search.filter-group-type.options')[2] } ], - title: I18n.t('global.search.filter-group-type.title'), + title: I18n.t('search.filter-group-type.title'), type: 'radio' }, { id: 'designation', options: objs_for(Designation), - title: I18n.t('global.search.filter-group-designation.title'), + title: I18n.t('search.filter-group-designation.title'), type: 'checkbox' }, { id: 'governance', options: objs_for(Governance), - title: I18n.t('global.search.filter-group-governance.title'), + title: I18n.t('search.filter-group-governance.title'), type: 'checkbox' }, { id: 'iucn_category', options: objs_for(IucnCategory), - title: I18n.t('global.search.filter-group-iucn-category.title'), + title: I18n.t('search.filter-group-iucn-category.title'), type: 'checkbox' } ] diff --git a/app/controllers/search_areas_controller.rb b/app/controllers/search_areas_controller.rb index f512a3226..fbcf4fe43 100644 --- a/app/controllers/search_areas_controller.rb +++ b/app/controllers/search_areas_controller.rb @@ -15,6 +15,14 @@ def index placeholder: I18n.t('global.placeholder.search-oecm-wdpa') }.to_json + @tabs = [] + + I18n.t('search.geo-types').each_with_index.map do |type, i| + @tabs << { id: i, title: type } + end + + @tabs.to_json + @query = search_params[:search_term] end diff --git a/app/javascript/components/search/SearchAreas.vue b/app/javascript/components/search/SearchAreas.vue index 560684621..91a13cf86 100644 --- a/app/javascript/components/search/SearchAreas.vue +++ b/app/javascript/components/search/SearchAreas.vue @@ -27,7 +27,7 @@
@@ -35,12 +35,17 @@ class="search__filters" :filter-close-text="filterCloseText" :filter-groups="filterGroups" - :isActive="isFilterPaneActive" + :is-active="isFilterPaneActive" :title="textFilters" v-on:update:filter-group="updateFilters" v-on:toggle:filter-pane="toggleFilterPane" />
+ + - @@ -25,13 +23,13 @@ diff --git a/app/javascript/components/form-fields/RadioButtonsSearch.vue b/app/javascript/components/form-fields/RadioButtonSearch.vue similarity index 100% rename from app/javascript/components/form-fields/RadioButtonsSearch.vue rename to app/javascript/components/form-fields/RadioButtonSearch.vue diff --git a/app/javascript/components/search/SearchAreas.vue b/app/javascript/components/search/SearchAreas.vue index eccb78022..933149913 100644 --- a/app/javascript/components/search/SearchAreas.vue +++ b/app/javascript/components/search/SearchAreas.vue @@ -196,11 +196,13 @@ export default { params: { filters: this.activeFilterOptions, items_per_page: 9, + requested_page: 1, search_term: this.searchTerm, // geo_type: this.selectedTab } } + console.log('data', data.params.filters) this.axiosSetHeaders() axios.get(this.endpointSearch, data) diff --git a/app/serializers/search/filters_serializer.rb b/app/serializers/search/filters_serializer.rb index 464ba33af..5c9b78d93 100644 --- a/app/serializers/search/filters_serializer.rb +++ b/app/serializers/search/filters_serializer.rb @@ -56,7 +56,7 @@ def serialize } ], title: I18n.t('search.filter-group-geo-type.title'), - type: 'radio-search' + type: 'checkbox-search' }, { id: 'designation', From 53b3a50088aa9a2c0522f932004c028c79fad6dc Mon Sep 17 00:00:00 2001 From: Ferdinando Primerano Date: Wed, 17 Jun 2020 16:10:41 +0100 Subject: [PATCH 033/109] Make tabs work again --- app/controllers/search_areas_controller.rb | 7 +++---- app/javascript/components/search/SearchAreas.vue | 2 +- app/serializers/search/areas_serializer.rb | 13 ++++--------- app/serializers/search/base_serializer.rb | 6 +++--- config/locales/search/en.yml | 7 +++---- 5 files changed, 14 insertions(+), 21 deletions(-) diff --git a/app/controllers/search_areas_controller.rb b/app/controllers/search_areas_controller.rb index 61c3aac3d..1d8e617a2 100644 --- a/app/controllers/search_areas_controller.rb +++ b/app/controllers/search_areas_controller.rb @@ -7,6 +7,7 @@ class SearchAreasController < ApplicationController before_action :load_search, only: [:search_results] before_action :load_filters, only: [:index, :search_results] + TABS = %w(region country site).freeze def index placeholder = @db_type == 'all' ? 'oecm-wdpa' : @db_type @config_search_areas = { @@ -16,11 +17,9 @@ def index @tabs = [] - I18n.t('search.geo-types').each_with_index.map do |type, i| - @tabs << { id: "geo-type-#{i}", title: type } #FERDI update the ids here to what you need + TABS.each do |tab| + @tabs << { id: tab, title: I18n.t("search.geo-types.#{tab}") } end - - @tabs.to_json end def search_results diff --git a/app/javascript/components/search/SearchAreas.vue b/app/javascript/components/search/SearchAreas.vue index eccb78022..3b43a0bbe 100644 --- a/app/javascript/components/search/SearchAreas.vue +++ b/app/javascript/components/search/SearchAreas.vue @@ -197,7 +197,7 @@ export default { filters: this.activeFilterOptions, items_per_page: 9, search_term: this.searchTerm, - // geo_type: this.selectedTab + geo_type: this.selectedTab } } diff --git a/app/serializers/search/areas_serializer.rb b/app/serializers/search/areas_serializer.rb index 13452aaba..155eff6e3 100644 --- a/app/serializers/search/areas_serializer.rb +++ b/app/serializers/search/areas_serializer.rb @@ -7,12 +7,7 @@ def initialize(search, geo_type=nil) end def serialize - if @geo_type - areas = @geo_type == 'site' ? @results.protected_areas : paginate(@aggregations[@geo_type]) - return areas_ary(@geo_type, areas).to_json - end - - sites + send(@geo_type.pluralize) end private @@ -20,13 +15,13 @@ def serialize def regions _regions = @aggregations['region'] - geo_hash('region', _regions, _regions.length) + geo_hash('region', paginate(_regions), _regions.length) end def countries _countries = @aggregations['country'] - geo_hash('country', _countries, _countries.length) + geo_hash('country', paginate(_countries), _countries.length) end def sites @@ -39,7 +34,7 @@ def sites geo_hash('site', _sites, _total_count) end - def geo_hash(geo_type, areas, total=nil) + def geo_hash(geo_type, areas, total=0) areas = areas.present? ? areas.first(9) : [] geo_type_locale = geo_type == 'site' ? 'area-types.wdpa' : "geo-types.#{geo_type.pluralize}" { diff --git a/app/serializers/search/base_serializer.rb b/app/serializers/search/base_serializer.rb index 822f6f0ba..bf4646e22 100644 --- a/app/serializers/search/base_serializer.rb +++ b/app/serializers/search/base_serializer.rb @@ -19,11 +19,11 @@ def serialize private def paginate(items) - size = @search.options[:size] - page = @search.options[:page] + size = @search.options[:size] || 1 + page = @search.options[:page] || 1 offset = size * (page - 1) last_item = size * page - 1 - items[offset..last_item].presence || [] + items && items[offset..last_item].presence || [] end end diff --git a/config/locales/search/en.yml b/config/locales/search/en.yml index 4c7883dd5..2bfc302e5 100644 --- a/config/locales/search/en.yml +++ b/config/locales/search/en.yml @@ -30,10 +30,9 @@ en: - Terrestrial - Marine geo-types: - - All - - Regions - - Countries - - Individual Areas + region: Regions + country: Countries + site: Individual Areas map: Map protected-areas: Protected Areas results: results From e740b465a7d6d359f0c91664d19d53247674a949 Mon Sep 17 00:00:00 2001 From: stacytalbot Date: Wed, 17 Jun 2020 16:13:13 +0100 Subject: [PATCH 034/109] Work on styling the checkbox search filter --- app/assets/stylesheets/base/_base.scss | 4 ++ app/assets/stylesheets/base/_buttons.scss | 34 ++++++++++++++++- app/assets/stylesheets/base/mixins/_text.scss | 1 + app/assets/stylesheets/components/_tabs.scss | 38 +++++++++++++++---- .../stylesheets/components/form/_input.scss | 9 +++++ app/javascript/components/filters/vFilter.vue | 18 ++++----- .../components/form-fields/CheckboxSearch.vue | 5 ++- .../components/search/SearchAreas.vue | 2 +- app/javascript/components/tabs/TabsFake.vue | 2 +- 9 files changed, 90 insertions(+), 23 deletions(-) diff --git a/app/assets/stylesheets/base/_base.scss b/app/assets/stylesheets/base/_base.scss index 9a69eed57..0ef756389 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 ffaa2bc04..e1ffcc106 100644 --- a/app/assets/stylesheets/base/_buttons.scss +++ b/app/assets/stylesheets/base/_buttons.scss @@ -16,7 +16,6 @@ $padding-medium: rem-calc(27); } @mixin button-basic { - @include responsive(font-size, rem-calc(16), rem-calc(18), rem-calc(18)); background-color: transparent; border: none; color: inherit; @@ -28,6 +27,10 @@ $padding-medium: rem-calc(27); &:hover { text-decoration: none; } } +@mixin button-font { + @include responsive(font-size, rem-calc(16), rem-calc(18), rem-calc(18)); +} + @mixin button-disabled { cursor: disabled; } @mixin button-height { @@ -37,7 +40,7 @@ $padding-medium: rem-calc(27); 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); } @@ -53,6 +56,7 @@ $padding-medium: rem-calc(27); @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; @@ -61,6 +65,7 @@ $padding-medium: rem-calc(27); @mixin button-with-icon { @include button-basic; + @include button-font; @include flex; @include flex-v-center; @@ -74,6 +79,7 @@ $padding-medium: rem-calc(27); @mixin button-outline ($colour: $black) { @include button-basic; + @include button-font; @include button-height; @include button-padding; @include button-radius; @@ -95,6 +101,7 @@ $padding-medium: rem-calc(27); @mixin button-download-trigger { @include button-basic; + @include button-font; @include button-radius; @include flex; @include flex-center; @@ -146,6 +153,7 @@ $padding-medium: rem-calc(27); @mixin button-search { @include button-basic; + @include button-font; @include button-radius; @include flex-center; background-color: $primary; @@ -157,6 +165,28 @@ $padding-medium: rem-calc(27); } } +@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 //-------------------------------------------------- diff --git a/app/assets/stylesheets/base/mixins/_text.scss b/app/assets/stylesheets/base/mixins/_text.scss index ae411456d..8b6b4578b 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/_tabs.scss b/app/assets/stylesheets/components/_tabs.scss index c69e73274..a8c20b45b 100644 --- a/app/assets/stylesheets/components/_tabs.scss +++ b/app/assets/stylesheets/components/_tabs.scss @@ -5,7 +5,7 @@ //-------------------------------------------------- // mixins //-------------------------------------------------- -@mixin tab-trigger { +@mixin tab-trigger-underlined { @include text-tabs-fake; border-bottom: solid transparent 2px; cursor: pointer; @@ -42,25 +42,47 @@ } &__trigger { - @include tab-trigger; + @include tab-trigger-underlined; &.active { color: $primary; } } } } - &--fake { + &--rounded { @include flex; + @include flex-h-center; @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)); + margin: rem-calc(26 0); + overflow-x: scroll; + + @include breakpoint($medium) { margin: rem-calc(26 0 32 0); } + + @include breakpoint($medium) { + @include flex-wrap; + margin: rem-calc(30 0 10 0); + overflow-x: initial; + } .tab { &__trigger { + @include button-tab-rounded; @include flex-no-shrink; - @include tab-trigger; - @include responsive(margin-bottom, 0, 0, rem-calc(10)); + margin: rem-calc(0 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; } } } 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/javascript/components/filters/vFilter.vue b/app/javascript/components/filters/vFilter.vue index 906633a0a..8e8a0c233 100644 --- a/app/javascript/components/filters/vFilter.vue +++ b/app/javascript/components/filters/vFilter.vue @@ -14,15 +14,6 @@ v-on:update:options="updateFilter" /> - -
+ +
diff --git a/app/javascript/components/form-fields/CheckboxSearch.vue b/app/javascript/components/form-fields/CheckboxSearch.vue index 1d74cb54d..1154120d1 100644 --- a/app/javascript/components/form-fields/CheckboxSearch.vue +++ b/app/javascript/components/form-fields/CheckboxSearch.vue @@ -2,17 +2,18 @@
-
+
diff --git a/app/javascript/components/tabs/TabsFake.vue b/app/javascript/components/tabs/TabsFake.vue index 9d507e55c..34a2ddcae 100644 --- a/app/javascript/components/tabs/TabsFake.vue +++ b/app/javascript/components/tabs/TabsFake.vue @@ -1,5 +1,5 @@ diff --git a/lib/modules/asset_generator.rb b/lib/modules/asset_generator.rb index bd33014dc..de09fb874 100644 --- a/lib/modules/asset_generator.rb +++ b/lib/modules/asset_generator.rb @@ -31,7 +31,7 @@ def self.mapbox_url geojson mapbox_config = Rails.application.secrets.mapbox access_token = mapbox_config[:access_token] || mapbox_config['access_token'] uri = URI(mapbox_config[:base_url] || mapbox_config['base_url']) - size = {y: 128, x: 256} + size = {y: 138, x: 304} raise AssetGenerationFailedError unless geojson.present? From e55222592b135e09a1d0ee804a5aa845a1f0572e Mon Sep 17 00:00:00 2001 From: Ferdinando Primerano Date: Thu, 25 Jun 2020 17:08:58 +0100 Subject: [PATCH 085/109] Fetch images from CMS fragments --- app/controllers/application_controller.rb | 7 +++++++ app/models/comfy/cms/searchable_page.rb | 8 ++++++++ app/serializers/search/full_serializer.rb | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) 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/models/comfy/cms/searchable_page.rb b/app/models/comfy/cms/searchable_page.rb index c45ab7e0b..23a8efa09 100644 --- a/app/models/comfy/cms/searchable_page.rb +++ b/app/models/comfy/cms/searchable_page.rb @@ -35,4 +35,12 @@ def summary fragment.content end + + # TODO Consider lazy loading + def image + fragment = self.fragments.find_by(identifier: 'image') + return '' unless fragment + + Rails.application.routes.url_helpers.rails_blob_path(fragment.attachments_blobs.first) + end end diff --git a/app/serializers/search/full_serializer.rb b/app/serializers/search/full_serializer.rb index a9edd8d59..af1ed6e1e 100644 --- a/app/serializers/search/full_serializer.rb +++ b/app/serializers/search/full_serializer.rb @@ -64,7 +64,7 @@ def image(obj) if obj.is_a?(ProtectedArea) ApplicationController.helpers.protected_area_cover(obj, with_tag: false) elsif obj.is_a?(Comfy::Cms::SearchablePage) - 'page_image' #TODO + obj.image else 'placeholder_image' #TODO end From acd211a9716ac006db7ec5fa20f22620316922fe Mon Sep 17 00:00:00 2001 From: Ferdinando Primerano Date: Fri, 26 Jun 2020 11:58:38 +0100 Subject: [PATCH 086/109] First draft for making the search match the term for countries and regions --- app/controllers/concerns/searchable.rb | 14 ++++++++++++-- app/models/region.rb | 2 +- app/serializers/search/areas_serializer.rb | 18 +++++++++--------- lib/modules/search.rb | 3 ++- lib/modules/search/index.rb | 3 +++ lib/modules/search/results.rb | 5 +++++ lib/modules/search/templates/mappings.json | 19 +++++++++++++++++-- 7 files changed, 49 insertions(+), 15 deletions(-) diff --git a/app/controllers/concerns/searchable.rb b/app/controllers/concerns/searchable.rb index 307686089..53682b902 100644 --- a/app/controllers/concerns/searchable.rb +++ b/app/controllers/concerns/searchable.rb @@ -29,9 +29,18 @@ def search_options 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 - is_area_category = parsed_filters && parsed_filters['ancestor'] == 'areas' - (controller_name.include?('area') || is_area_category) ? Search::PA_INDEX : 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 DB_TYPES = %w(wdpa oecm all).freeze @@ -62,6 +71,7 @@ def load_search_from_query_string # def filters return '' unless search_params[:filters].present? + return '' if %w(country region).include?(search_params[:geo_type]) _filters = sanitise_filters _filters.to_hash.symbolize_keys.slice(*Search::ALLOWED_FILTERS) end diff --git a/app/models/region.rb b/app/models/region.rb index 26854683f..47d841e4e 100644 --- a/app/models/region.rb +++ b/app/models/region.rb @@ -102,7 +102,7 @@ def sources_per_jurisdiction def as_indexed_json options={} self.as_json( - only: [:id, :name] + only: [:id, :name, :iso] ) end diff --git a/app/serializers/search/areas_serializer.rb b/app/serializers/search/areas_serializer.rb index 837fdc29c..42ef887ed 100644 --- a/app/serializers/search/areas_serializer.rb +++ b/app/serializers/search/areas_serializer.rb @@ -13,13 +13,13 @@ def serialize private def regions - _regions = @aggregations['region'] + _regions = @results.regions || [] geo_hash('region', paginate(_regions), _regions.length) end def countries - _countries = @aggregations['country'] + _countries = @results.countries || [] geo_hash('country', paginate(_countries), _countries.length) end @@ -52,19 +52,19 @@ def areas_ary(geo_type, areas) def region_hash(region) { - title: region[:label], - totalAreas: "#{region[:count]} #{I18n.t('search.protected-areas')}", - url: region_path(iso: region[:identifier]) + title: region.name, + totalAreas: "#{region.protected_areas.count} #{I18n.t('search.protected-areas')}", + url: region_path(iso: region.iso) } end def country_hash(country) - _slug = slug(country[:label]) + _slug = slug(country.name) { countryFlag: ActionController::Base.helpers.image_url("flags/#{_slug}.svg"), - totalAreas: "#{country[:count]} #{I18n.t('search.protected-areas')}", - title: country[:label], - url: country_path(iso: country[:identifier]) + totalAreas: "#{country.protected_areas.count} #{I18n.t('search.protected-areas')}", + title: country.name, + url: country_path(iso: country.iso_3) } end diff --git a/lib/modules/search.rb b/lib/modules/search.rb index d50faf928..b1280a745 100644 --- a/lib/modules/search.rb +++ b/lib/modules/search.rb @@ -2,9 +2,10 @@ class Search CONFIGURATION_FILE = File.read(Rails.root.join('config', 'search.yml')).freeze ALLOWED_FILTERS = [:type, :country, :iucn_category, :designation, :region, :marine, :has_irreplaceability_info, :has_parcc_info, :governance, :is_green_list, :category, :ancestor, :is_oecm].freeze COUNTRY_INDEX = "countries_#{Rails.env}".freeze + REGION_INDEX = "regions_#{Rails.env}".freeze PA_INDEX = "protectedareas_#{Rails.env}".freeze CMS_INDEX = "cms_#{Rails.env}".freeze - DEFAULT_INDEX_NAME = [PA_INDEX, COUNTRY_INDEX, CMS_INDEX].join(',').freeze + DEFAULT_INDEX_NAME = [PA_INDEX, CMS_INDEX].join(',').freeze AREAS_INDEX_NAME = [PA_INDEX, COUNTRY_INDEX].join(',').freeze attr_reader :search_term, :options diff --git a/lib/modules/search/index.rb b/lib/modules/search/index.rb index 62695913e..47d8d2db3 100644 --- a/lib/modules/search/index.rb +++ b/lib/modules/search/index.rb @@ -12,10 +12,13 @@ def self.create ]) + region_index = Search::Index.new Search::REGION_INDEX, Region.without_geometry.all + region_index.create country_index = Search::Index.new Search::COUNTRY_INDEX, Country.without_geometry.all country_index.create pa_index = Search::Index.new Search::PA_INDEX, pa_relation pa_index.create + region_index.index country_index.index pa_index.index end diff --git a/lib/modules/search/results.rb b/lib/modules/search/results.rb index 56b89cc68..4ede43ab5 100644 --- a/lib/modules/search/results.rb +++ b/lib/modules/search/results.rb @@ -2,6 +2,7 @@ class Search::Results def initialize query_results @query_results = query_results @type_index_map = { + Search::REGION_INDEX => "Region", Search::COUNTRY_INDEX => "Country", Search::PA_INDEX => "ProtectedArea", Search::CMS_INDEX => "Comfy::Cms::SearchablePage" @@ -46,6 +47,10 @@ def countries @countries ||= objects[@type_index_map[Search::COUNTRY_INDEX]] end + def regions + @regions ||= objects[@type_index_map[Search::REGION_INDEX]] + end + def cms_pages @cms_pages ||= objects[@type_index_map[Search::CMS_INDEX]] end diff --git a/lib/modules/search/templates/mappings.json b/lib/modules/search/templates/mappings.json index 28dab8c97..582c11344 100644 --- a/lib/modules/search/templates/mappings.json +++ b/lib/modules/search/templates/mappings.json @@ -115,7 +115,6 @@ "type": "text", "analyzer": "english" }, - "countries_for_index": { "type": "nested", "properties": { @@ -143,7 +142,23 @@ } } } - }, + }, + "regions_for_index": { + "type": "nested", + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "text", + "analyzer": "english" + }, + "iso": { + "type": "keyword", + "normalizer": "lc_normalizer" + } + } + }, "iucn_category": { "type": "nested", "properties": { From 972e7d261cbaa78bf828afd0a04ea39c52fce2c5 Mon Sep 17 00:00:00 2001 From: Stacy Talbot Date: Mon, 6 Jul 2020 17:03:32 +0100 Subject: [PATCH 087/109] Add placeholder image for search results --- .../cards/cards/_cards-articles.scss | 12 +---- .../cards/_cards-search-results-areas.scss | 10 ++++- .../cards/cards/_cards-search-results.scss | 8 +++- app/assets/stylesheets/helpers/_helpers.scss | 1 + app/assets/stylesheets/helpers/_images.scss | 25 +++++++++++ .../components/card/CardSearchResult.vue | 4 ++ .../components/card/CardSearchResultArea.vue | 44 ++++++++++--------- 7 files changed, 71 insertions(+), 33 deletions(-) create mode 100644 app/assets/stylesheets/helpers/_images.scss diff --git a/app/assets/stylesheets/components/cards/cards/_cards-articles.scss b/app/assets/stylesheets/components/cards/cards/_cards-articles.scss index 61f3d666a..a546c5915 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 +} \ 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 2b4831a3c..bf00e2ae6 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 @@ -2,6 +2,8 @@ // 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 @@ -44,7 +46,13 @@ $card-search-results-areas-flag-size: rem-calc(60); } &__image { - width: 100%; height: auto; + 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 { 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 33d6acdd9..c488d18c9 100644 --- a/app/assets/stylesheets/components/cards/cards/_cards-search-results.scss +++ b/app/assets/stylesheets/components/cards/cards/_cards-search-results.scss @@ -2,6 +2,7 @@ // variables //-------------------------------------------------- $search-results-image-width: rem-calc(165); +$search-results-image-height: rem-calc(130); //-------------------------------------------------- // classes //-------------------------------------------------- @@ -28,14 +29,17 @@ $search-results-image-width: rem-calc(165); } &__image { - background-color: $grey-light; background-position: center; background-size: cover; - width: $search-results-image-width; height: rem-calc(130); + 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/helpers/_helpers.scss b/app/assets/stylesheets/helpers/_helpers.scss index 70d2e230a..9c6bb65c6 100644 --- a/app/assets/stylesheets/helpers/_helpers.scss +++ b/app/assets/stylesheets/helpers/_helpers.scss @@ -2,6 +2,7 @@ @import './background'; @import './border-and-shadows'; @import './form-fields'; +@import './images'; @mixin limit_lines($number, $line-height: 1.25) { overflow-y: hidden; 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/javascript/components/card/CardSearchResult.vue b/app/javascript/components/card/CardSearchResult.vue index 6bcb28fc9..aea73de59 100644 --- a/app/javascript/components/card/CardSearchResult.vue +++ b/app/javascript/components/card/CardSearchResult.vue @@ -23,6 +23,10 @@ class="card__image" :style="{ backgroundImage: `url(${image})` }" /> +
diff --git a/app/javascript/components/card/CardSearchResultArea.vue b/app/javascript/components/card/CardSearchResultArea.vue index b77f22867..453ed0a3a 100644 --- a/app/javascript/components/card/CardSearchResultArea.vue +++ b/app/javascript/components/card/CardSearchResultArea.vue @@ -1,26 +1,30 @@