From e6de37c8ce9df4dc03705cc484b3ab3eebc83481 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 7 Feb 2019 15:02:11 +1300 Subject: [PATCH 001/549] Tests for crop.photos --- spec/models/crop_spec.rb | 68 +++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 1b8de81ed..2c9531467 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -139,57 +139,61 @@ describe Crop do end context 'photos' do - before :each do - @crop = FactoryBot.create(:tomato) + shared_examples 'has default photo' do + it { expect(Crop.has_photos).to include(crop) } end + let!(:crop) { FactoryBot.create :tomato } + let(:member) { FactoryBot.create :member } context 'with a planting photo' do - before :each do - @planting = FactoryBot.create(:planting, crop: @crop) - @photo = FactoryBot.create(:photo, owner: @planting.owner) - @planting.photos << @photo - end + let!(:photo) { FactoryBot.create(:photo, owner: planting.owner) } + let!(:planting) { FactoryBot.create(:planting, crop: crop) } - it 'has a default photo' do - @crop.default_photo.should be_an_instance_of Photo - expect(@crop.default_photo.id).to eq @photo.id - end - - it 'is found in has_photos scope' do - Crop.has_photos.should include(@crop) - end + before { planting.photos << photo } + it { expect(crop.default_photo).to eq photo } + include_examples 'has default photo' end context 'with a harvest photo' do - before :each do - @harvest = FactoryBot.create(:harvest, crop: @crop) - @photo = FactoryBot.create(:photo, owner: @harvest.owner) - @harvest.photos << @photo - end - - it 'has a default photo' do - @crop.default_photo.should be_an_instance_of Photo - expect(@crop.default_photo.id).to eq @photo.id - end + let!(:harvest) { FactoryBot.create(:harvest, crop: crop) } + let!(:photo) { FactoryBot.create(:photo, owner: harvest.owner) } + before { harvest.photos << photo } + it { expect(crop.default_photo).to eq photo } + include_examples 'has default photo' context 'and planting photo' do - before :each do - @planting = FactoryBot.create(:planting, crop: @crop) - @planting_photo = FactoryBot.create(:photo, owner: @planting.owner) - @planting.photos << @planting_photo - end + let(:planting) { FactoryBot.create(:planting, crop: crop) } + let!(:planting_photo) { FactoryBot.create(:photo, owner: planting.owner) } + before { planting.photos << planting_photo } it 'should prefer the planting photo' do - expect(@crop.default_photo.id).to eq @planting_photo.id + expect(crop.default_photo.id).to eq planting_photo.id end end end context 'with no plantings or harvests' do it 'has no default photo' do - expect(@crop.default_photo).to eq nil + expect(crop.default_photo).to eq nil end end + + describe 'finding all photos' do + let(:planting) { FactoryBot.create :planting, crop: crop } + let(:harvest) { FactoryBot.create :harvest, crop: crop } + let(:seed) { FactoryBot.create :seed, crop: crop } + before do + # Add photos to all + planting.photos << FactoryBot.create(:photo, owner: planting.owner) + harvest.photos << FactoryBot.create(:photo, owner: harvest.owner) + seed.photos << FactoryBot.create(:photo, owner: seed.owner) + end + + it { expect(crop.photos.size).to eq 3 } + it { expect(crop.planting_photos.size).to eq 1 } + it { expect(crop.harvest_photos.size).to eq 1 } + it { expect(crop.seed_photos.size).to eq 1 } + end end context 'sunniness' do From 3967e68038dea25c10ee0c9a00b2de3f57fe5625 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 15 Feb 2019 09:13:08 +1300 Subject: [PATCH 002/549] More info on a crop's varieties, and parent --- app/views/crops/_thumbnail.html.haml | 8 +++++--- app/views/crops/_varieties.html.haml | 25 +++++-------------------- app/views/crops/show.html.haml | 12 ++++++++++-- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/app/views/crops/_thumbnail.html.haml b/app/views/crops/_thumbnail.html.haml index 77793ef22..c9dfe207e 100644 --- a/app/views/crops/_thumbnail.html.haml +++ b/app/views/crops/_thumbnail.html.haml @@ -11,6 +11,8 @@ - unless crop.scientific_names.empty? .scientificname = crop.scientific_names.first.name - .plantingcount - Planted - = pluralize(crop.plantings.size, "time") + - if crop.annual? && crop.median_lifespan.present? + .planting-lifespan + lifespan + %strong= crop.median_lifespan + days diff --git a/app/views/crops/_varieties.html.haml b/app/views/crops/_varieties.html.haml index 5cdc453ed..2b3407388 100644 --- a/app/views/crops/_varieties.html.haml +++ b/app/views/crops/_varieties.html.haml @@ -1,20 +1,5 @@ -.varieties - - if crop.parent - %p - = crop.name - is a variety of - = succeed "." do - = link_to crop.parent, crop.parent - - - unless crop.varieties.empty? - %p - Varieties of #{crop.name}: - - - max = 5 - = render partial: 'hierarchy', locals: { display_crops: [crop], max: max } - - if max != 0 && @count > max - = button_tag "Show all #{@count - 1} varieties", class: 'btn btn-link toggle crop-hierarchy' - = button_tag "Show less varieties", class: 'btn btn-link toggle crop-hierarchy hide' - - - if !crop.parent && crop.varieties.empty? - %p None known. +- if crop.varieties.size.positive? + %h3 Varieties + .row + - crop.varieties.order(:name).each do |v| + .col-md-2.six-across= render 'crops/thumbnail', crop: v \ No newline at end of file diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 2b58de0bf..11b3eddd3 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -36,6 +36,7 @@ %h2 Photos %p= render 'crops/photos', photos: @photos %p= link_to 'more photos', crop_photos_path(@crop) + .row .col-md-3 @@ -49,6 +50,8 @@ = pie_chart crop_harvested_for_path(@crop, format: :json), legend: "bottom" + = render 'varieties', crop: @crop + %h3 Crop Map %p Only plantings by members who have set their locations are shown on this map. @@ -90,8 +93,13 @@ = render 'scientific_names', crop: @crop = render 'alternate_names', crop: @crop - %h4 #{@crop.name.capitalize} varieties - = render 'varieties', crop: @crop + - if @crop.parent + .parent-crop + = @crop.name + is a variety of + = succeed "." do + = link_to @crop.parent, @crop.parent + = render 'crops/thumbnail', crop: @crop.parent = render 'plantings', crop: @crop = render 'harvests', crop: @crop From 3ed173ebcd48450212fb41128914ecc4e4e798d6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 15 Feb 2019 21:06:37 +1300 Subject: [PATCH 003/549] Material design changes --- Gemfile | 3 + Gemfile.lock | 13 + app/assets/javascripts/application.js | 4 + app/assets/javascripts/jquery-roadmap.js | 212 ++++++++++ app/assets/stylesheets/application.sass | 16 +- .../stylesheets/bootstrap-accessibility.css | 82 ---- .../custom_bootstrap/custom_bootstrap.sass | 59 --- .../stylesheets/custom_bootstrap/mixins.sass | 1 - app/assets/stylesheets/homepage.sass | 17 + app/assets/stylesheets/jquery-roadmap.scss | 381 ++++++++++++++++++ app/assets/stylesheets/members.sass | 19 + app/assets/stylesheets/overrides.sass | 56 +-- app/assets/stylesheets/plantings.sass | 5 +- app/assets/stylesheets/predictions.sass | 3 +- .../{custom_bootstrap => }/variables.sass | 11 +- app/helpers/application_helper.rb | 2 - app/helpers/buttons_helper.rb | 26 +- app/helpers/photos_helper.rb | 13 +- app/models/planting.rb | 2 +- app/models/seed.rb | 2 +- app/views/crops/_actions.html.haml | 32 +- app/views/crops/_photos.html.haml | 21 +- app/views/crops/_predictions.html.haml | 69 ++-- app/views/crops/_search_bar.haml | 3 +- app/views/crops/_thumbnail.html.haml | 29 +- app/views/crops/index.html.haml | 11 +- app/views/crops/show.html.haml | 66 ++- app/views/gardens/_overview.html.haml | 5 +- app/views/gardens/show.html.haml | 4 +- app/views/harvests/_list.html.haml | 20 +- app/views/home/_blurb.html.haml | 15 +- app/views/home/_crops.html.haml | 7 +- app/views/home/_discuss.html.haml | 41 +- app/views/home/_harvests.html.haml | 4 +- app/views/home/_members.html.haml | 19 +- app/views/home/_plantings.html.haml | 4 +- app/views/home/_seeds.html.haml | 27 +- app/views/home/index.html.haml | 62 ++- app/views/layouts/_header.html.haml | 45 ++- app/views/layouts/_nav.haml | 6 +- app/views/layouts/application.html.haml | 8 +- app/views/members/_avatar.html.haml | 9 +- app/views/members/_thumbnail.html.haml | 50 ++- app/views/photos/_actions.html.haml | 2 +- app/views/photos/_item_photos.haml | 5 +- .../photos/_photo_association_delete.haml | 5 +- .../photos/_photo_associations.html.haml | 39 +- app/views/photos/edit.html.haml | 15 +- app/views/photos/show.html.haml | 26 +- app/views/plantings/_descendants.html.haml | 5 +- app/views/plantings/_harvests.html.haml | 5 +- .../plantings/_image_with_popover.html.haml | 2 +- app/views/plantings/_list.html.haml | 24 +- app/views/plantings/_quick_actions.haml | 23 +- app/views/plantings/_stats.haml | 13 + app/views/plantings/show.html.haml | 2 +- app/views/seeds/_actions.html.haml | 4 +- app/views/seeds/_list.html.haml | 16 + app/views/seeds/_thumbnail.html.haml | 26 +- app/views/shared/_global_actions.html.haml | 20 +- app/views/shared/buttons/_finish_seeds.haml | 5 - config/environments/development.rb | 2 +- config/environments/production.rb | 2 + spec/models/photo_spec.rb | 12 +- 64 files changed, 1170 insertions(+), 567 deletions(-) create mode 100644 app/assets/javascripts/jquery-roadmap.js delete mode 100644 app/assets/stylesheets/bootstrap-accessibility.css delete mode 100644 app/assets/stylesheets/custom_bootstrap/custom_bootstrap.sass delete mode 100644 app/assets/stylesheets/custom_bootstrap/mixins.sass create mode 100644 app/assets/stylesheets/homepage.sass create mode 100644 app/assets/stylesheets/jquery-roadmap.scss create mode 100644 app/assets/stylesheets/members.sass rename app/assets/stylesheets/{custom_bootstrap => }/variables.sass (84%) create mode 100644 app/views/plantings/_stats.haml create mode 100644 app/views/seeds/_list.html.haml delete mode 100644 app/views/shared/buttons/_finish_seeds.haml diff --git a/Gemfile b/Gemfile index d52faad1c..743ff4d78 100644 --- a/Gemfile +++ b/Gemfile @@ -17,6 +17,9 @@ gem 'jsonapi-resources' # CSS framework gem 'bootstrap-sass' +gem 'bootstrap', '4.1.1' +gem 'material-sass', '4.1.1' +gem 'material_icons' gem 'font-awesome-sass' gem 'uglifier' # JavaScript compressor diff --git a/Gemfile.lock b/Gemfile.lock index e00ef2345..a72188955 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -66,6 +66,10 @@ GEM bonsai-elasticsearch-rails (7.0.1) elasticsearch-model (< 8) elasticsearch-rails (< 8) + bootstrap (4.1.1) + autoprefixer-rails (>= 6.0.3) + popper_js (>= 1.12.9, < 2) + sass (>= 3.5.2) bootstrap-datepicker-rails (1.8.0.1) railties (>= 3.0) bootstrap-kaminari-views (0.0.5) @@ -280,6 +284,11 @@ GEM mini_mime (>= 0.1.1) marcel (0.3.3) mimemagic (~> 0.3.2) + material-sass (4.1.1) + autoprefixer-rails (>= 6.0.3) + sass (>= 3.5.2) + material_icons (2.2.1) + railties (>= 3.2) memcachier (0.0.2) method_source (0.9.2) mime-types (3.2.2) @@ -336,6 +345,7 @@ GEM capybara (>= 2.1, < 4) cliver (~> 0.3.1) websocket-driver (>= 0.2.0) + popper_js (1.14.5) powerpack (0.1.2) public_suffix (3.0.3) puma (3.12.0) @@ -510,6 +520,7 @@ DEPENDENCIES better_errors bluecloth bonsai-elasticsearch-rails + bootstrap (= 4.1.1) bootstrap-datepicker-rails bootstrap-kaminari-views bootstrap-sass @@ -556,6 +567,8 @@ DEPENDENCIES letter_opener listen loofah (>= 2.2.1) + material-sass (= 4.1.1) + material_icons memcachier newrelic_rpm omniauth (~> 1.3) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 419c55d00..cd1924033 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -18,4 +18,8 @@ // = require jquery-ui/widgets/autocomplete // = require bootstrap-sprockets // = require bootstrap-datepicker +// = require jquery +// = require popper +// = require bootstrap +// = require material // = require_tree . diff --git a/app/assets/javascripts/jquery-roadmap.js b/app/assets/javascripts/jquery-roadmap.js new file mode 100644 index 000000000..cc8fd6a32 --- /dev/null +++ b/app/assets/javascripts/jquery-roadmap.js @@ -0,0 +1,212 @@ +;(function(factory) { + "use strict"; + + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else if (typeof exports !== 'undefined') { + module.exports = factory(require('jquery'), window, document); + } else { + factory(jQuery, window, document); + } + +}(function($, window, document, undefined ) { + + "use strict"; + + // undefined is used here as the undefined global variable in ECMAScript 3 is + // mutable (ie. it can be changed by someone else). undefined isn't really being + // passed in so we can ensure the value of it is truly undefined. In ES5, undefined + // can no longer be modified. + + // window and document are passed through as local variables rather than global + // as this (slightly) quickens the resolution process and can be more efficiently + // minified (especially when both are regularly referenced in your plugin). + + /** + * jQuery custom plugin implement the roadmap functionality + */ + $.fn.roadmap = function(events, opts) { + if ( !events instanceof Array ) { + events = []; + } + + var defaults = { + slide: 1, + eventsPerSlide: 6, + rootClass: 'roadmap', + prevArrow: 'prev', + nextArrow: 'next', + orientation: 'auto', + eventTemplate: '
' + + '
####DATE###
' + + '
####CONTENT###
' + + '
' + }; + + var settings = $.extend({}, defaults, opts); + + var buildEvent = function(event, key) { + var html = '
  • ' + settings.eventTemplate + '
  • '; + html = html.replace('####DATE###', event.date); + html = html.replace('####CONTENT###', event.content); + + var left = (100/(settings.eventsPerSlide-1))*key; + + return $(html).css('left', left + '%'); + } + + return this.each(function() { + var _this = this; + var $this = $(this); + var currentSlide = settings.slide - 1; + + /** + * Store events and settings + */ + $this.data({ + events: events, + settings: settings, + currentSlide: currentSlide + }).addClass(settings.rootClass); + + var clear = function() { + $this.removeClass(settings.rootClass + '--initialized'); + + $this.find('.' + settings.rootClass + '__events').remove(); + $this.find('.' + settings.rootClass + '__navigation').remove(); + } + + var buildEvents = function() { + var currentSlide = $this.data('currentSlide'); + var settings = $this.data('settings'); + var events = $this.data('events'); + + $('
      ', {class: settings.rootClass + '__events'}).append(events.slice((currentSlide*settings.eventsPerSlide), ((currentSlide+1)*settings.eventsPerSlide)).map(buildEvent)).appendTo(_this); + } + + var buildNavigation = function() { + var currentSlide = $this.data('currentSlide'); + + var buildNav = function(nav) { + switch (nav) { + case 'prev': + if ( currentSlide > 0 ) { + return $('
    1. ' + settings.prevArrow + '
    2. '); + } + break; + + case 'next': + if ( (currentSlide+1)*settings.eventsPerSlide < events.length ) { + return $('
    3. ' + settings.nextArrow + '
    4. '); + } + break; + } + + return $('
    5. '); + } + + $('
        ', {class: settings.rootClass + '__navigation'}).append(['prev', 'next'].map(buildNav)).appendTo(_this); + } + + var setOrientation = function() { + + var getOrientation = function() { + switch (settings.orientation) { + case 'horizontal': + case 'vertical': + case 'auto': + return settings.orientation; + break; + } + + return 'auto'; + } + + $this.addClass(settings.rootClass + '--orientation-' + getOrientation()); + } + + var build = function() { + + clear(); + + /** + * Init events + */ + buildEvents(); + + /** + * Init navigation + */ + buildNavigation(); + + /** + * Set orientation + */ + setOrientation(); + + /** + * Initialize + */ + setTimeout(function() { + $this.addClass(settings.rootClass + '--initialized'); + }, 100); + } + + /** + * Build roadmap + */ + build(); + + /** + * Event Listeners + */ + $('body').on('click', '.' + settings.rootClass + ' .' + settings.rootClass + '__navigation li > *', function(e) { + e.preventDefault(); + + /** + * Handle prev click + */ + if ( $(this).hasClass('prev') ) { + + var currentSlide = $this.data('currentSlide'); + if ( currentSlide < 1 ) { + return false; + } + + $this.data({ + events: events, + settings: settings, + currentSlide: currentSlide-1 + }); + + build(); + } + + /** + * Handle next click + */ + else { + + var currentSlide = $this.data('currentSlide'); + if ( (currentSlide+1)*settings.eventsPerSlide >= events.length ) { + return false; + } + + $this.data({ + events: events, + settings: settings, + currentSlide: currentSlide+1 + }); + + build(); + } + }); + + $(window).on('resize', function () { + $this.removeClass(settings.rootClass + '--initialized'); + build(); + }); + }); + }; + +})); \ No newline at end of file diff --git a/app/assets/stylesheets/application.sass b/app/assets/stylesheets/application.sass index a8e11cf2f..8c66377d8 100644 --- a/app/assets/stylesheets/application.sass +++ b/app/assets/stylesheets/application.sass @@ -1,9 +1,19 @@ +@import 'material' +@import 'material_icons' +@import 'variables' +@import 'overrides' + + @import 'jquery-ui/autocomplete' @import 'bootstrap-datepicker' @import 'leaflet' @import 'leaflet.markercluster' -@import 'custom_bootstrap/custom_bootstrap' -@import 'overrides' @import 'graphs' @import 'predictions' -@import 'plantings' \ No newline at end of file +@import 'plantings' +@import 'members' +@import 'homepage' + +// Font Awesome +@import 'font-awesome-sprockets' +@import 'font-awesome' diff --git a/app/assets/stylesheets/bootstrap-accessibility.css b/app/assets/stylesheets/bootstrap-accessibility.css deleted file mode 100644 index 78a4eb9d1..000000000 --- a/app/assets/stylesheets/bootstrap-accessibility.css +++ /dev/null @@ -1,82 +0,0 @@ -.btn:focus { - outline: dotted 2px #000; -} -div.active:focus { - outline: dotted 1px #000; -} -a:focus { - outline: dotted 1px #000; -} -.close:hover, -.close:focus { - outline: dotted 1px #000; -} -.nav > li > a:hover, -.nav > li > a:focus { - outline: dotted 1px #000; -} -.carousel-indicators li, -.carousel-indicators li.active { - height: 18px; - width: 18px; - border-width: 2px; - position: relative; - box-shadow: 0px 0px 0px 1px #808080; -} -.carousel-indicators.active li { - background-color: rgba(100, 149, 253, 0.6); -} -.carousel-indicators.active li.active { - background-color: white; -} -.carousel-tablist-highlight { - display: block; - position: absolute; - outline: 2px solid transparent; - background-color: transparent; - box-shadow: 0px 0px 0px 1px transparent; -} -.carousel-tablist-highlight.focus { - outline: 2px solid #6495ed; - background-color: rgba(0, 0, 0, 0.4); -} -a.carousel-control:focus { - outline: 2px solid #6495ed; - background-image: linear-gradient( - to right, - transparent 0px, - rgba(0, 0, 0, 0.5) 100% - ); - box-shadow: 0px 0px 0px 1px #000000; -} -.carousel-pause-button { - position: absolute; - top: -30em; - left: -300em; - display: block; -} -.carousel-pause-button.focus { - top: 0.5em; - left: 0.5em; -} -.carousel:hover .carousel-caption, -.carousel.contrast .carousel-caption { - background-color: rgba(0, 0, 0, 0.5); - z-index: 10; -} -.alert-success { - color: #2d4821; -} -.alert-info { - color: #214c62; -} -.alert-warning { - color: #6c4a00; - background-color: #f9f1c6; -} -.alert-danger { - color: #d2322d; -} -.alert-danger:hover { - color: #a82824; -} diff --git a/app/assets/stylesheets/custom_bootstrap/custom_bootstrap.sass b/app/assets/stylesheets/custom_bootstrap/custom_bootstrap.sass deleted file mode 100644 index 1dba52253..000000000 --- a/app/assets/stylesheets/custom_bootstrap/custom_bootstrap.sass +++ /dev/null @@ -1,59 +0,0 @@ -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -// !!! AUTOMATICALLY GENERATED FILE. DO NOT MODIFY !!! -// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -// Core variables and mixins -@import "bootstrap-sprockets" -@import "bootstrap/variables" -// Modify this for custom colors, font-sizes, etc -@import "custom_bootstrap/variables" -@import "bootstrap/mixins" -// Modify this for custom mixins -@import "custom_bootstrap/mixins" - -// Reset and dependencies -@import "bootstrap/normalize" -@import "bootstrap/print" -@import "bootstrap/glyphicons" - -// Core CSS -@import "bootstrap/scaffolding" -@import "bootstrap/type" -@import "bootstrap/code" -@import "bootstrap/grid" -@import "bootstrap/tables" -@import "bootstrap/forms" -@import "bootstrap/buttons" - -// Components -@import "bootstrap/component-animations" -@import "bootstrap/dropdowns" -@import "bootstrap/button-groups" -@import "bootstrap/input-groups" -@import "bootstrap/navs" -@import "bootstrap/navbar" -@import "bootstrap/breadcrumbs" -@import "bootstrap/pagination" -@import "bootstrap/pager" -@import "bootstrap/labels" -@import "bootstrap/badges" -@import "bootstrap/jumbotron" -@import "bootstrap/thumbnails" -@import "bootstrap/alerts" -@import "bootstrap/progress-bars" -@import "bootstrap/media" -@import "bootstrap/list-group" -@import "bootstrap/panels" -@import "bootstrap/responsive-embed" -@import "bootstrap/wells" -@import "bootstrap/close" - -// Components w/ JavaScript -@import "bootstrap/modals" -@import "bootstrap/tooltip" -@import "bootstrap/popovers" -@import "bootstrap/carousel" - -// Utility classes -@import "bootstrap/utilities" -@import "bootstrap/responsive-utilities" diff --git a/app/assets/stylesheets/custom_bootstrap/mixins.sass b/app/assets/stylesheets/custom_bootstrap/mixins.sass deleted file mode 100644 index 44c24bdb7..000000000 --- a/app/assets/stylesheets/custom_bootstrap/mixins.sass +++ /dev/null @@ -1 +0,0 @@ -// Use this file to override Twitter Bootstrap mixins or define own mixins. diff --git a/app/assets/stylesheets/homepage.sass b/app/assets/stylesheets/homepage.sass new file mode 100644 index 000000000..2feef9319 --- /dev/null +++ b/app/assets/stylesheets/homepage.sass @@ -0,0 +1,17 @@ +// let's condense the hero unit a little +.jumbotron + //padding-top: 30px + //padding-bottom: 30px + +// info under the main heading on homepage +.jumbotron .info + // padding-top: 15px + +// signup widget on homepage +.jumbotron .signup + background-color: lighten($green, 40%) + border: 1px solid lighten($green, 20%) + border-radius: 6px + line-height: 200% + padding: 15px + text-align: center \ No newline at end of file diff --git a/app/assets/stylesheets/jquery-roadmap.scss b/app/assets/stylesheets/jquery-roadmap.scss new file mode 100644 index 000000000..4708a4f92 --- /dev/null +++ b/app/assets/stylesheets/jquery-roadmap.scss @@ -0,0 +1,381 @@ +// Config +@import 'base/variables'; +@import 'base/mixins'; + +@mixin roadmap-default { + position: relative; + width: 95%; + margin: 0 auto; + + .roadmap__events { + position: relative; + width: calc(100% - 200px); + margin: 0 auto; + padding: 200px 0; + + &:after { + position: absolute; + top: 50%; + left: 0; + display: block; + content: ""; + width: 0%; + height: 4px; + background-color: $primary-color; + // box-shadow: 0 0 30px -1px rgba($primary-color, 0.2); + border-radius: 2px; + + transition: all 0.5s linear; + } + + &__event { + position: absolute; + width: 280px; + height: 200px; + margin-left: -140px; + list-style: none; + font-size: 16px; + + &:before, + &:after { + position: absolute; + content: ""; + display: block; + background-color: $primary-color; + // box-shadow: 0 0 30px -1px rgba($primary-color, 0.2); + + transition: all 0.3s $transition-function; + } + + &:before { + width: 20px; + height: 20px; + border-radius: 20px; + left: 50%; + transform: translateX(-50%); + transform: scale(0); + } + + &:after { + width: 4px; + // height: 62px; + height: 0; + border-radius: 2px; + left: 50%; + transform: translateX(-50%); + } + + .event { + position: absolute; + display: block; + text-align: center; + width: 100%; + + transition: all 0.3s $transition-function; + transform: scale(0); + + .event__date { + font-weight: 600; + } + + .event__content { + + small { + display: block; + } + } + } + + /** + * Events showing on the bottom of the timeline + */ + &:nth-child(odd) { + bottom: 0; + + &:before { + top: -8px; + } + + &:after { + top: 0; + } + + .event { + top: 80px; + } + } + + /** + * Events showing on the top of the timeline + */ + &:nth-child(even) { + top: 0; + + &:before { + bottom: -12px; + } + + &:after { + bottom: -4px; + } + + .event { + bottom: 80px; + } + } + + @for $i from 1 through 15 { + &:nth-child(#{$i}n) { + + &:before, + &:after, + .event { + transition-delay: #{$i * 0.13}s; + } + } + } + } + } + + .roadmap__navigation { + margin: 0; + + &>* { + position: absolute; + top: 50%; + transform: translateY(-46%); + z-index: 100; + list-style: none; + + a { + display: block; + color: #000; + line-height: 0; + + i { + font-size: 44px; + } + + &:hover { + text-decoration: none; + box-shadow: none; + } + } + + &:first-child { + left: 40px; + } + + &:last-child { + right: 40px; + } + } + + .prev {} + .next {} + } + + &.roadmap--initialized { + + .roadmap__events { + + &:after { + width: 100%; + } + + .roadmap__events__event { + + /** + * Dot + */ + &:before { + transform: scale(1) translateX(-50%); + } + + /** + * Line + */ + &:after { + height: 62px; + } + + .event { + transform: scale(1); + } + } + } + } +} + +@mixin roadmap-vertical { + margin: $gap*2 auto; + + .roadmap__events { + padding: 0; + width: 80%; + max-width: 640px; + min-height: 400px; + + &:after { + left: 50%; + top: 0; + width: 4px; + height: calc(0% - 0px); + transform: translateX(-50%); + } + + &__event { + position: relative; + left: auto !important; + top: auto; + bottom: auto; + margin-left: 0; + width: auto; + height: auto; + min-height: 120px; + + &:before { + top: -8px; + bottom: auto; + } + + &:after { + top: 0; + bottom: auto; + // width: 48px; + width: 0; + height: 4px !important; + } + + .event { + top: -15px; + bottom: auto; + width: 40%; + + @include sm-down { + width: 50%; + } + } + + /** + * Events showing on the left of the timeline + */ + &:nth-child(odd) { + + &:before {} + + &:after { + transform: translateX(-100%); + } + + .event { + @include sm-down { + margin-left: -10%; + } + } + } + + /** + * Events showing on the right of the timeline + */ + &:nth-child(even) { + + &:before { + // margin-left: -12px; + } + + &:after { + transform: translateX(0%); + } + + .event { + right: 0; + + @include sm-down { + margin-right: -10%; + } + } + } + } + } + + &.roadmap--initialized { + + .roadmap__events { + + &:after { + width: 4px; + height: calc(100% - 120px); + } + + .roadmap__events__event { + + /** + * Dot + */ + &:before {} + + /** + * Line + */ + &:after { + width: 48px; + + @include sm-down { + width: 32px; + } + } + + .event {} + + /** + * Events showing on the left of the timeline + */ + &:nth-child(odd) { + + &:before {} + + &:after { + transform: translateX(-100%); + } + + .event {} + } + + /** + * Events showing on the right of the timeline + */ + &:nth-child(even) { + + &:before {} + + &:after { + transform: translateX(0%); + } + + .event {} + } + } + } + } +} + +.roadmap { + + &.roadmap--orientation-auto { + @include roadmap-default; + + @include md-down { + @include roadmap-vertical; + } + } + + &.roadmap--orientation-horizontal { + @include roadmap-default; + } + + &.roadmap--orientation-vertical { + @include roadmap-default; + @include roadmap-vertical; + } +} \ No newline at end of file diff --git a/app/assets/stylesheets/members.sass b/app/assets/stylesheets/members.sass new file mode 100644 index 000000000..4de1bdb1a --- /dev/null +++ b/app/assets/stylesheets/members.sass @@ -0,0 +1,19 @@ +.member-cards + display: flex + flex: none + flex-wrap: wrap + +.member-thumbnail + padding: .25em + margin: 1em + border-radius: 12px + height: 200px + + div + width: 5em + display: inline-block + vertical-align: top + +.member-thumbnail div~div + padding-left: 1em + width: 15em diff --git a/app/assets/stylesheets/overrides.sass b/app/assets/stylesheets/overrides.sass index 1b7d4d152..7edaf3092 100644 --- a/app/assets/stylesheets/overrides.sass +++ b/app/assets/stylesheets/overrides.sass @@ -1,6 +1,5 @@ @import "bootstrap-sprockets" @import "bootstrap" -@import "custom_bootstrap/variables" // this padding needs to be done before the responsive stuff is imported body padding-top: $navbar-height @@ -72,7 +71,13 @@ h3 // info under the main heading on homepage .jumbotron .info - padding-top: 15px + //padding-top: 15px + padding: 0.5em + text-align: center + + p + + // signup widget on homepage .jumbotron .signup @@ -87,29 +92,12 @@ h3 p.stats font-weight: bold -.member-cards - display: flex - flex: none - flex-wrap: wrap - .card-row display: grid grid-template-columns: 50% 50% grid-gap: 25px grid-row-gap: 5px -.member-thumbnail - padding: .25em - margin: 1em - - div - width: 5em - display: inline-block - vertical-align: top - -.member-thumbnail div~div - padding-left: 1em - width: 15em .progress border-radius: 0 @@ -117,7 +105,6 @@ p.stats text-align: center .layout-actions - width: 100% #placesmap, #cropmap height: 500px @@ -141,6 +128,8 @@ p.stats .member-location a color: $brown +.associations + list-style-type: none .photo-thumbnail padding: 0 @@ -168,11 +157,20 @@ p.stats display: block .thumbnail - border: none + // border: 1px solid lighten($green, 20%) text-align: center margin-bottom: 1.5em max-width: 160px - max-height: 200px + //max-height: 220px + //height: 180px + + .seed-thumbnail + height: 220px + .seedinfo + .seed-name + font-size: 120% + overflow: hidden + .member-thumbnail text-align: left @@ -182,8 +180,8 @@ p.stats max-width: 85px .crop-thumbnail - height: 220px .cropinfo + margin-top: 0.5em display: inline-block max-width: 100% white-space: nowrap @@ -193,15 +191,21 @@ p.stats .cropname overflow: hidden text-overflow: ellipsis + font-size: 120% + .scientificname font-size: small font-style: italic overflow: hidden text-overflow: ellipsis + font-size: 70% + .plantingcount font-size: small + .planting-lifespan + font-size: 70% .crop-name a padding-top: 2px @@ -257,11 +261,9 @@ html, body height: 100% .crop-image, .member-image - width: 100% - height: 100% + border-radius: 50% // Autosuggest - .ui-autocomplete background: white z-index: $zindex-tooltip @@ -363,8 +365,6 @@ ul.thumbnail-buttons .homepage .thumbnail height: 180px - .seed-thumbnail - height: 220px #maincontainer padding: 10px diff --git a/app/assets/stylesheets/plantings.sass b/app/assets/stylesheets/plantings.sass index a6d450b68..d37c9fdfd 100644 --- a/app/assets/stylesheets/plantings.sass +++ b/app/assets/stylesheets/plantings.sass @@ -26,8 +26,9 @@ top: -0.5em .planting-quick-actions position: absolute - left: 142px - top: 6px + top: 0px + left: 130px + .planting-thumbnail-photo height: 150px diff --git a/app/assets/stylesheets/predictions.sass b/app/assets/stylesheets/predictions.sass index f8120c8b5..f33a8e73e 100644 --- a/app/assets/stylesheets/predictions.sass +++ b/app/assets/stylesheets/predictions.sass @@ -1,11 +1,10 @@ .predictions .prediction-metric text-align: center - height: 180px border: 1px solid lighten($green, 20%) border-radius: 5% background: $white - margin: 4px + margin: 1em strong font-size: 4em font-align: center diff --git a/app/assets/stylesheets/custom_bootstrap/variables.sass b/app/assets/stylesheets/variables.sass similarity index 84% rename from app/assets/stylesheets/custom_bootstrap/variables.sass rename to app/assets/stylesheets/variables.sass index f2fc82dda..c306fe18f 100644 --- a/app/assets/stylesheets/custom_bootstrap/variables.sass +++ b/app/assets/stylesheets/variables.sass @@ -1,10 +1,10 @@ // Use this file to override Twitter Bootstrap variables or define own variables. // Import original variables so they can be used in overrides -@import 'bootstrap/variables.scss' +//@import 'bootstrap/variables.scss' +//$screen-md-min: 1028px // Base colours - $beige: #f3f1ee $brown: #413f3b @@ -22,7 +22,7 @@ $graph-hover: $orange $brand-primary: $green -$font-family-sans-serif: "Helvetica Neue", Helvetica, Arial, sans-serif +$font-family-sans-serif: "Helvetica Neue", Helvetica, Arial, sans-serif $font-family-serif: Georgia, "Times New Roman", Times, serif $font-family-mono: Monaco, Menlo, Consolas, "Courier New", monospace @@ -33,7 +33,7 @@ $alt-font-family: $font-family-serif $headings-font-family: $font-family-sans-serif $headings-font-weight: bold // instead of browser default, bold -$headings-color: inherit // empty to use BS default, $textColor +$headings-color: inherit // empty to use BS default, $textColor // Hero unit $jumbotron-bg: darken($body-bg, 10%) @@ -48,9 +48,10 @@ $navbar-default-link-active-color: darken($beige,80%) $navbar-default-brand-color: lighten($green, 20%) // Top nav collapse threshold -$grid-float-breakpoint: $screen-md-min +//$grid-float-breakpoint: $screen-md-min $dropdown-bg: lighten($beige, 10%) $dropdown-link-color: $brown $dropdown-link-hover-color: $brown $dropdown-link-hover-bg: lighten($green, 50%) + diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d93850629..b86731d7e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -27,11 +27,9 @@ module ApplicationHelper end def required_field_help_text - # rubocop:disable Rails/OutputSafety asterisk = content_tag :span, '*', class: ['red'] text = content_tag :em, 'denotes a required field' content_tag :div, asterisk + ' '.html_safe + text, class: ['margin-bottom'] - # rubocop:enable Rails/OutputSafety end # diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 7ae28247e..491ee82bb 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,7 +1,7 @@ module ButtonsHelper include IconsHelper def garden_plant_something_button(garden) - link_to new_planting_path(garden_id: garden.id), class: "btn btn-default btn-xs btn-primary" do + link_to new_planting_path(garden_id: garden.id), class: "btn btn-default" do planting_icon + ' ' + t('buttons.plant_something_here') end end @@ -9,13 +9,13 @@ module ButtonsHelper def garden_mark_active_button(garden) link_to t('buttons.mark_as_active'), garden_path(garden, garden: { active: 1 }), - method: :put, class: 'btn btn-default btn-xs' + method: :put, class: 'btn' end def garden_mark_inactive_button(garden) link_to t('buttons.mark_as_inactive'), garden_path(garden, garden: { active: 0 }), - method: :put, class: 'btn btn-default btn-xs', + method: :put, class: 'btn', data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } end @@ -43,7 +43,15 @@ module ButtonsHelper return unless can?(:edit, planting) || planting.finished link_to planting_path(planting, planting: { finished: 1 }), - method: :put, class: 'btn btn-default btn-xs append-date' do + method: :put, class: 'btn btn-default btn-secondary append-date' do + finished_icon + ' ' + t('buttons.mark_as_finished') + end + end + + def seed_finish_button(seed) + return unless can?(:create, Planting) && seed.active? + + link_to seed_path(seed, seed: { finished: 1 }), method: :put, class: 'btn btn-default append-date' do finished_icon + ' ' + t('buttons.mark_as_finished') end end @@ -51,7 +59,7 @@ module ButtonsHelper def planting_harvest_button(planting) return unless planting.active? && can?(:create, Harvest) && can?(:edit, planting) - link_to new_planting_harvest_path(planting), class: "btn btn-default btn-xs" do + link_to new_planting_harvest_path(planting), class: "btn btn-default" do harvest_icon + ' ' + t('buttons.harvest') end end @@ -59,7 +67,7 @@ module ButtonsHelper def planting_save_seeds_button(planting) return unless can?(:edit, planting) - link_to new_planting_seed_path(planting), class: "btn btn-default btn-xs" do + link_to new_planting_seed_path(planting), class: "btn btn-default" do seed_icon + ' ' + t('buttons.save_seeds') end end @@ -68,13 +76,13 @@ module ButtonsHelper return unless can?(:edit, model) && can?(:create, Photo) link_to new_photo_path(id: model.id, type: model_type_for_photo(model)), - class: "btn btn-default btn-xs" do + class: "btn btn-default" do photo_icon + ' ' + t('buttons.add_photo') end end def edit_button(path) - link_to path, class: "btn btn-default btn-xs" do + link_to path, class: "btn btn-raised btn-info" do edit_icon + ' ' + t('buttons.edit') end end @@ -82,7 +90,7 @@ module ButtonsHelper def delete_button(model, message: 'are_you_sure') return unless can? :destroy, model - link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-default btn-xs' do + link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-danger' do delete_icon + ' ' + t('buttons.delete') end end diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb index 6087a9c74..345d6eea1 100644 --- a/app/helpers/photos_helper.rb +++ b/app/helpers/photos_helper.rb @@ -15,9 +15,10 @@ module PhotosHelper end end - def planting_image_path(planting) + def planting_image_path(planting, full_size: false) if planting.photos.present? - planting.photos.order(date_taken: :desc).first.thumbnail_url + photo = planting.photos.order(date_taken: :desc).first + full_size ? photo.fullsize_url : photo.thumbnail_url else placeholder_image end @@ -33,11 +34,13 @@ module PhotosHelper end end - def seed_image_path(seed) + def seed_image_path(seed, full_size: false) if seed.default_photo.present? - seed.default_photo.thumbnail_url + photo = seed.default_photo + full_size ? photo.fullsize_url : photo.thumbnail_url elsif seed.crop.default_photo.present? - seed.crop.default_photo.thumbnail_url + photo = seed.crop.default_photo + full_size ? photo.fullsize_url : photo.thumbnail_url else placeholder_image end diff --git a/app/models/planting.rb b/app/models/planting.rb index 95908723b..08a78fdd8 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -23,7 +23,7 @@ class Planting < ApplicationRecord # Ancestry of food belongs_to :parent_seed, class_name: 'Seed', # parent foreign_key: 'parent_seed_id', - required: false, + optional: true, inverse_of: :child_plantings has_many :child_seeds, class_name: 'Seed', # children foreign_key: 'parent_planting_id', diff --git a/app/models/seed.rb b/app/models/seed.rb index 2075afba2..253718039 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -14,7 +14,7 @@ class Seed < ApplicationRecord # Relationships belongs_to :crop belongs_to :parent_planting, class_name: 'Planting', foreign_key: 'parent_planting_id', - required: false, inverse_of: :child_seeds # parent + optional: true, inverse_of: :child_seeds # parent has_many :child_plantings, class_name: 'Planting', foreign_key: 'parent_seed_id', dependent: :nullify, inverse_of: :parent_seed # children diff --git a/app/views/crops/_actions.html.haml b/app/views/crops/_actions.html.haml index 92ae2b00f..7b292e3d3 100644 --- a/app/views/crops/_actions.html.haml +++ b/app/views/crops/_actions.html.haml @@ -1,16 +1,18 @@ -.crop-actions - .btn-group - - if can? :create, Planting - = link_to new_planting_path(crop_id: crop.id), class: 'btn btn-default' do - = planting_icon - = t('buttons.plant_crop', crop_name: crop.name) +- if signed_in? - - if can? :create, Harvest - = link_to new_harvest_path(crop_id: crop.id), class: 'btn btn-default' do - = harvest_icon - = t('buttons.harvest_crop', crop_name: crop.name) - - - if can? :create, Seed - = link_to new_seed_path(crop_id: crop.id), class: 'btn btn-default' do - = seed_icon - = t('buttons.add_seed_to_stash', crop_name: crop.name) + .crop-actions + .btn-group + - if can? :create, Planting + = link_to new_planting_path(crop_id: crop.id), class: 'btn btn-default' do + = planting_icon + = t('buttons.plant_crop', crop_name: crop.name) + + - if can? :create, Harvest + = link_to new_harvest_path(crop_id: crop.id), class: 'btn btn-default' do + = harvest_icon + = t('buttons.harvest_crop', crop_name: crop.name) + + - if can? :create, Seed + = link_to new_seed_path(crop_id: crop.id), class: 'btn btn-default' do + = seed_icon + = t('buttons.add_seed_to_stash', crop_name: crop.name) diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index 567cf5be6..9960027f5 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -1,10 +1,11 @@ -- [Planting, Harvest, Seed].each do |model_name| - .row - .col-md-12 - %h3 - = @crop.name - = t("activerecord.models.#{model_name.to_s.downcase}.other") - .row - - photos.by_model(model_name).limit(6).each do |photo| - .col-md-2.six-across - .thumbnail= link_to image_tag(photo.thumbnail_url, alt: photo.title, class: 'img'), photo +- if @crop.photos.size.positive? + %h2 Photos + - [Planting, Harvest, Seed].each do |model_name| + - if photos.by_model(model_name).size.positive? + %h3 #{@crop.name} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} + .row + - photos.by_model(model_name).limit(6).each do |photo| + .col-md-2.six-across + .thumbnail= link_to image_tag(photo.thumbnail_url, alt: photo.title, class: 'img'), photo + + %p.text-right= link_to 'more photos »', crop_photos_path(@crop), class: 'btn' diff --git a/app/views/crops/_predictions.html.haml b/app/views/crops/_predictions.html.haml index dfdc7659f..63d344820 100644 --- a/app/views/crops/_predictions.html.haml +++ b/app/views/crops/_predictions.html.haml @@ -1,32 +1,51 @@ +%h3 Predictions .predictions - - unless crop.perennial.nil? - .row - .col-md-12 - %p - #{crop.name} is - - if crop.perennial == true - = link_to 'https://en.wikipedia.org/wiki/Annual_vs._perennial_plant_evolution' do - a perennial crop - (living more than two years) - - elsif crop.perennial == false - = link_to 'https://en.wikipedia.org/wiki/Annual_vs._perennial_plant_evolution' do - an annual crop - (living and reproducing in a single year or less) .row + - unless crop.perennial.nil? + .col-md-3.col-xs-5 + .card + .card-body.text-center + %h3 + = link_to 'https://en.wikipedia.org/wiki/Annual_vs._perennial_plant_evolution' do + - if crop.perennial == true + Perennial + - elsif crop.perennial == false + Annual + + .d-flex.justify-content-between + %p.display-1 + %i.far.fa-calendar + + + - if crop.perennial == true + %small living more than two years + - elsif crop.perennial == false + %small living and reproducing in a single year or less + - if crop.annual? && crop.median_lifespan.present? - .prediction-metric.col-md-3.col-xs-5 - %h3 Median lifespan - %strong= crop.median_lifespan - %span days + .col-md-3.col-xs-5 + .card + .card-body.text-center + %h3 Median lifespan + .d-flex.justify-content-between + %p.display-1= crop.median_lifespan + %i.fas.fa-sun-o.fa-5x.pt-3.amber-text + %span days + - if crop.median_days_to_first_harvest.present? - .prediction-metric.col-md-3.col-xs-5 - %h3 First harvest expected - %strong= crop.median_days_to_first_harvest - %span days after planting + .col-md-3.col-xs-5 + .card + .card-body.text-center + %h3 First harvest expected + %p.display-1= crop.median_days_to_first_harvest + %span days after planting - if crop.annual? && crop.median_days_to_last_harvest.present? - .prediction-metric.col-md-3.col-xs-5 - %h3 Last harvest expected - %strong= crop.median_days_to_last_harvest - %span days after planting + .col-md-3.col-xs-5 + .card + .card-body.text-center + %h3 Last harvest expected + %p.display-1= crop.median_days_to_last_harvest + %span days after planting + diff --git a/app/views/crops/_search_bar.haml b/app/views/crops/_search_bar.haml index c626a97a1..0d9b3d94d 100644 --- a/app/views/crops/_search_bar.haml +++ b/app/views/crops/_search_bar.haml @@ -1,4 +1,5 @@ -= form_tag search_crops_path, method: :get, id: 'navbar-search' do += form_tag 'search' do + -# , method: :get, id: 'navbar-search' do = label_tag :term, "Search crop database:", class: 'sr-only' .input .input-group diff --git a/app/views/crops/_thumbnail.html.haml b/app/views/crops/_thumbnail.html.haml index c9dfe207e..9d87101d2 100644 --- a/app/views/crops/_thumbnail.html.haml +++ b/app/views/crops/_thumbnail.html.haml @@ -1,18 +1,17 @@ - cache cache_key_for(Crop, crop.id) do .thumbnail .crop-thumbnail - - if crop - = link_to image_tag(crop_image_path(crop), - alt: crop.name, class: 'img'), - crop - .cropinfo - .cropname - = link_to crop.name, crop - - unless crop.scientific_names.empty? - .scientificname - = crop.scientific_names.first.name - - if crop.annual? && crop.median_lifespan.present? - .planting-lifespan - lifespan - %strong= crop.median_lifespan - days + = link_to image_tag(crop_image_path(crop), + alt: crop.name, class: 'img'), + crop + .cropinfo + .cropname + = link_to crop.name, crop + - unless crop.scientific_names.empty? + .scientificname + = crop.scientific_names.first.name + - if crop.annual? && crop.median_lifespan.present? + .planting-lifespan + lifespan + %strong= crop.median_lifespan + days diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml index 8dc437f30..f850f9043 100644 --- a/app/views/crops/index.html.haml +++ b/app/views/crops/index.html.haml @@ -1,8 +1,12 @@ - content_for :title, t('.title') - content_for :subtitle, t('.subtitle', crops_size: @crops.size) -- if can? :wrangle, Crop - = link_to 'Wrangle Crops', wrangle_crops_path, class: 'btn btn-primary' +- content_for :buttonbar do + - if can? :wrangle, Crop + = link_to 'Wrangle Crops', wrangle_crops_path, class: 'btn btn-secondary' + - if can? :create, Crop + = link_to 'Add new Crop', new_crop_path, class: 'btn btn-primary' + - if @num_requested_crops && @num_requested_crops.positive? = link_to(I18n.t('crops.requested.link', number_crops: @num_requested_crops), requested_crops_path) @@ -30,9 +34,6 @@ .col-md-2.six-across = render partial: "thumbnail", locals: { crop: crop } -- if can? :create, Crop - %div - = link_to 'New Crop', new_crop_path, class: 'btn btn-primary' .pagination = will_paginate @crops diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 11b3eddd3..6d6bcdbc8 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -21,34 +21,35 @@ .col-md-9 %h2 - if !@crop.plantings.empty? - = @crop.name.titleize - has been planted + #{@crop.name.titleize} has been planted = pluralize(@crop.plantings.size, "time") by #{ENV['GROWSTUFF_SITE_NAME']} members. - else Nobody is growing this yet. You could be the first! + %hr/ - - %h3 Predictions = render 'predictions', crop: @crop + %hr/ + = render 'crops/photos', photos: @photos + %hr/ - %h2 Photos - %p= render 'crops/photos', photos: @photos - %p= link_to 'more photos', crop_photos_path(@crop) - - - .row - .col-md-3 - %h3 Sunniness - = pie_chart crop_sunniness_path(@crop, format: :json), legend: "bottom" - .col-md-3 - %h3 Planted from - = pie_chart crop_planted_from_path(@crop, format: :json), legend: "bottom" - .col-md-3 - %h3 Harvested for - = pie_chart crop_harvested_for_path(@crop, format: :json), legend: "bottom" - + .row.text-center + .col-md-4 + .card + .card-body + %h3.section-heading.h3.pt-4 Sunniness + = pie_chart crop_sunniness_path(@crop, format: :json), legend: "bottom" + .col-md-4 + .card + .card-body + %h3.section-heading.h3.pt-4 Planted from + = pie_chart crop_planted_from_path(@crop, format: :json), legend: "bottom" + .col-md-4 + .card + .card-body + %h3.section-heading.h3.pt-4 Harvested for + = pie_chart crop_harvested_for_path(@crop, format: :json), legend: "bottom" = render 'varieties', crop: @crop @@ -59,27 +60,18 @@ = link_to "Set your location.", edit_member_registration_path #cropmap - .row - .col-md-12 - = render 'crops/posts', crop: @crop + = render 'crops/posts', crop: @crop .col-md-3 - = render partial: 'wrangle', locals: { crop: @crop } - %p - %li - = link_to crop_seeds_path(@crop) do - View all #{@crop.name} seeds - (#{@crop.seeds.size}) - %li - = link_to crop_plantings_path(@crop) do - View all #{@crop.name} plantings - (#{@crop.plantings.size}) - %li - = link_to crop_harvests_path(@crop) do - View all #{@crop.name} harvests - (#{@crop.harvests.size}) + = link_to crop_plantings_path(@crop) do + View all #{@crop.name} plantings + (#{@crop.plantings.size}) + %p + = link_to crop_harvests_path(@crop) do + View all #{@crop.name} harvests + (#{@crop.harvests.size}) - if member_signed_in? %p = link_to member_seeds_path(current_member, crop_slug: @crop.slug) do diff --git a/app/views/gardens/_overview.html.haml b/app/views/gardens/_overview.html.haml index 635874211..ac6eb896f 100644 --- a/app/views/gardens/_overview.html.haml +++ b/app/views/gardens/_overview.html.haml @@ -7,6 +7,9 @@ .col-md-2.col-xs-12.garden-info %p= render 'gardens/photo', garden: garden %p= display_garden_description(garden) + - if can?(:edit, garden) + = render 'gardens/actions', garden: garden + .col-md-10 - if garden.plantings.current.size.positive? .row @@ -15,5 +18,3 @@ = render "plantings/thumbnail", planting: planting - else no plantings - - if can?(:edit, garden) - .panel-footer= render 'gardens/actions', garden: garden diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index 2c8ec76d6..a1f03e243 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -100,6 +100,7 @@ - if can?(:edit, @garden) && can?(:create, Photo) %p + = = link_to new_photo_path(type: "garden", id: @garden.id), class: 'btn btn-primary' do %span.glyphicon.glyphicon-camera{ title: "Add photo" } @@ -108,5 +109,4 @@ %h3= localize_plural(@garden.photos, Photo) .row - @garden.photos.includes(:owner).each do |photo| - .col-xs-6 - = render partial: 'photos/thumbnail', locals: { photo: photo } + .col-xs-6= render partial: 'photos/thumbnail', locals: { photo: photo } diff --git a/app/views/harvests/_list.html.haml b/app/views/harvests/_list.html.haml index 8e4e1a7a1..fa4d3e01f 100644 --- a/app/views/harvests/_list.html.haml +++ b/app/views/harvests/_list.html.haml @@ -1,10 +1,12 @@ -- harvests.each do |h| - - cache h do - .row - .col-lg-6.col-md-3.col-xs-4.homepage-listing - = render 'harvests/image_with_popover', harvest: h - .col-lg-3.col-md-9.col-xs-4 - = link_to h.crop, crop_path(h.crop) - %br/ +- harvests.each do |harvest| + - cache harvest do + .card + .view.overlay + = link_to harvest do + %img.card-img-top.img-responsive{alt: harvest, src: harvest.default_photo.fullsize_url}/ + .card-body.p-3 + %h5.card-title.font-weight-bold.fuchsia-rose-text.mb-0 + = link_to harvest, harvest %small - %i= h.owner.location + %i= harvest.owner.location + %hr/ diff --git a/app/views/home/_blurb.html.haml b/app/views/home/_blurb.html.haml index 81e65510f..f4120ce64 100644 --- a/app/views/home/_blurb.html.haml +++ b/app/views/home/_blurb.html.haml @@ -1,11 +1,10 @@ -.container - .row - .col-md-12 - %h1= ENV['GROWSTUFF_SITE_NAME'] - .col-md-8.info - %p= t('.intro', site_name: ENV['GROWSTUFF_SITE_NAME']) - = render partial: 'stats' - .col-md-4.signup +.row + .col-md-8.info + %h1= ENV['GROWSTUFF_SITE_NAME'] + %p= t('.intro', site_name: ENV['GROWSTUFF_SITE_NAME']) + = render partial: 'stats' + .col-md-4 + .signup %p= t('.perks') %p= link_to(t('.sign_up'), new_member_registration_path, class: 'btn btn-primary btn-lg') %p diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml index 8cffe4b78..f971cf6b4 100644 --- a/app/views/home/_crops.html.haml +++ b/app/views/home/_crops.html.haml @@ -1,6 +1,9 @@ - cache cache_key_for(Crop, 'interesting'), expires_in: 1.day do + %h2.section-heading.h1.pt-4= t('.our_crops') .row - %h2= t('.our_crops') - - Crop.interesting.includes(:scientific_names, :photos).shuffle.first(12).each do |c| + - Crop.interesting.includes(:scientific_names, :photos).shuffle.first(36).each do |c| .col-lg-2.col-md-4.col-sm-3.col-xs-6 = render 'crops/thumbnail', crop: c + + .align-bottom + %p.text-right= link_to "#{t('home.crops.view_all')} »", crops_path, class: 'btn' \ No newline at end of file diff --git a/app/views/home/_discuss.html.haml b/app/views/home/_discuss.html.haml index 0ec3077e1..101b4c7e4 100644 --- a/app/views/home/_discuss.html.haml +++ b/app/views/home/_discuss.html.haml @@ -1,17 +1,34 @@ %h2= t('.discussion') -- posts = Post.order(created_at: :desc).limit(6) -- if posts - = render "posts/summary", posts: posts, howmany: 6 +-# - Post.order(created_at: :desc).limit(6).each do |post| -- cache cache_key_for(Forum) do - - forums = Forum.all.order(:name) - - if forums - %ul.list-inline - %li - %strong #{t('.forums')}: - - forums.each do |f| - %li= link_to f.name, f +-# = link_to truncate(strip_tags(post.subject), length: 40, separator: ' '), post +-# by +-# = link_to post.author, post.author +-# - cache cache_key_for(Forum) do +-# - forums = Forum.all.order(:name) +-# - if forums +-# %ul.list-inline +-# %li +-# %strong #{t('.forums')}: +-# - forums.each do |f| +-# %li= link_to f.name, f + + + +.list-group + - Post.order(created_at: :desc).limit(3).each do |post| + %a.list-group-item.list-group-item-action.flex-column.align-items-start{:href => post_path(post)} + .d-flex.w-100.justify-content-between + %h5.mb-2.h5= truncate(strip_tags(post.subject)) + %small + = time_ago_in_words(post.created_at) + ago + %p.mb-2 + = truncate(strip_tags(post.body), length: 200) + %small + = post.comments.size + comments %p.text-right - = link_to "#{t('.view_all')} »", posts_path + = link_to "#{t('.view_all')} »", posts_path, class: 'btn' diff --git a/app/views/home/_harvests.html.haml b/app/views/home/_harvests.html.haml index 2229eae63..8374bcea7 100644 --- a/app/views/home/_harvests.html.haml +++ b/app/views/home/_harvests.html.haml @@ -1,3 +1,3 @@ - cache cache_key_for(Harvest) do - %h2 Recently Harvested - = render 'harvests/list', harvests: Harvest.includes(:crop, :owner, :photos).has_photos.recent.first(6) + %h2.section-heading.h1.pt-4 Recently Harvested + = render 'harvests/list', harvests: Harvest.includes(:crop, :owner, :photos).has_photos.recent.first(3) diff --git a/app/views/home/_members.html.haml b/app/views/home/_members.html.haml index c3a4392ba..f3aef80ca 100644 --- a/app/views/home/_members.html.haml +++ b/app/views/home/_members.html.haml @@ -1,13 +1,12 @@ - cache cache_key_for(Member) do .hidden-xs - - members = Member.includes(plantings: :crop).interesting.first(6) - - if members.present? - %section - %h2= t('.title') + %section.section.pb-3.text-center + - members = Member.includes(plantings: :crop).interesting.first(6) + - if members.present? + %h2.section-heading.h1.pt-4= t('.title') + .row.member-cards + - members.each do |m| + .col-md-3.col.sm-2= render "members/thumbnail", member: m - .member-cards - - members.each do |m| - = render "members/thumbnail", member: m - - %p.text-right - = link_to "#{t('.view_all')} »", members_path + %p.text-right + = link_to "#{t('.view_all')} »", members_path, class: 'btn' diff --git a/app/views/home/_plantings.html.haml b/app/views/home/_plantings.html.haml index dd631d2ff..d4d7b8faa 100644 --- a/app/views/home/_plantings.html.haml +++ b/app/views/home/_plantings.html.haml @@ -1,3 +1,3 @@ - cache cache_key_for(Planting, 'home'), expires_in: 1.day do - %h2= t('.recently_planted') - = render 'plantings/list', plantings: Planting.includes(:crop, garden: :owner).has_photos.recent.limit(6) + %h2.section-heading.h2.pt-4= t('.recently_planted') + = render 'plantings/list', plantings: Planting.includes(:crop, garden: :owner).has_photos.recent.limit(3) diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml index 4a28f9590..299f60100 100644 --- a/app/views/home/_seeds.html.haml +++ b/app/views/home/_seeds.html.haml @@ -1,22 +1,5 @@ -- cache cache_key_for(Seed, 'interesting'), expires_in: 1.day do - %h2= t('.title') - .row - - Seed.current.tradable.includes(:owner, :crop).order(created_at: :desc).limit(6).each do |seed| - .col-md-2.col-sm-2.col-xs-6 - .thumbnail.seed-thumbnail - - cache cache_key_for(Crop, seed.id) do - = link_to image_tag(seed_image_path(seed), - alt: seed.crop.name, class: 'img'), - seed - .seedinfo - = link_to seed.crop.name, seed - .trade-to - %p= seed.owner.location - %p - %small - Will trade to: - %br/ - %em= seed.tradable_to - -%p.text-right - = link_to "#{t('.view_all')} »", seeds_path +- cache cache_key_for(Seed) do + - seeds = Seed.current.tradable.includes(:owner, :crop).order(created_at: :desc).limit(6) + - if seeds.size.positive? + %h2.section-heading.h1.pt-4.text-center= t('.title') + = render 'seeds/list', seeds: seeds diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index be274c930..c30d62489 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1,36 +1,32 @@ -.homepage.row - .col-md-12 - - if member_signed_in? - - content_for :title, t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) +.homepage + .row + .col-md-12 + - if member_signed_in? + - content_for :title, t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) - = render 'stats' - - else - .hidden-xs - .jumbotron - = render 'blurb' - .visible-xs - = render 'blurb' + = render 'stats' + - else + .hidden-xs + .jumbotron= render 'blurb' + -# .visible-xs= render 'blurb' - .row - .col-lg-8.col-md-6.col-sm-12 - = render 'crops' - .col-lg-2.col-md-3.col-sm-6 - = render 'plantings' - .col-lg-2.col-md-3.col-sm-6 - = render 'harvests' - .col-md-12 - - cache cache_key_for(Crop, 'recent') do - %p{ style: 'margin-top: 11.25px' } - %strong - #{t('.recently_added')}: - != Crop.recent.limit(30).map { |c| link_to(c, c) }.join(", ") + .row + .col-lg-8.col-md-6.col-sm-12.well + = render 'crops' + .col-lg-2.col-md-3.col-sm-6 + = render 'plantings' + .col-lg-2.col-md-3.col-sm-6 + = render 'harvests' + .col-md-12 + - cache cache_key_for(Crop, 'recent') do + %p{ style: 'margin-top: 11.25px' } + %strong + #{t('.recently_added')}: + != Crop.recent.limit(30).map { |c| link_to(c, c) }.join(", ") - %p.text-right - = link_to "#{t('home.crops.view_all')} »", crops_path - .row - .col-md-12 - = render 'seeds' - = render 'members' - .row - .col-md-12 - = render 'discuss' + .row + .col-lg-8.col-md-6.col-sm-12 + = render 'seeds' + .col-lg-4.col-md-6.col-sm-12 + = render 'discuss' + = render 'members' diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 2b188afd5..5da0bfd24 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -1,10 +1,9 @@ .sr-only = link_to t(".skip"), "#skipnav" .navbar.navbar-default.navbar-fixed-top{ role: "navigation" } - .container + .container-fluid .navbar-header - %button.navbar-toggle{ 'data-target': "#navbar-collapse", 'data-toggle': "collapse" } - %span.sr-only= t('.toggle_navigation') + %button.navbar-toggle{"data-target" => ".navbar-responsive-collapse", "data-toggle" => "collapse", type: "button"} %span.icon-bar %span.icon-bar %span.icon-bar @@ -16,15 +15,36 @@ class: "img-responsive", alt: ENV['GROWSTUFF_SITE_NAME']) - .form.navbar-form.pull-left + .navbar-collapse.collapse.navbar-responsive-collapse + -# %ul.nav.navbar-nav + -# %li.active + -# %a{href: "javascript:void(0)"} Active + -# %li + -# %a{href: "javascript:void(0)"} Link + -# %li.dropdown + -# %a.dropdown-toggle{"data-target" => "#", "data-toggle" => "dropdown", href: "http://fezvrasta.github.io/bootstrap-material-design/bootstrap-elements.html"} + -# Dropdown + -# %b.caret + -# %ul.dropdown-menu + -# %li + -# %a{href: "javascript:void(0)"} Action + -# %li + -# %a{href: "javascript:void(0)"} Another action + -# %li + -# %a{href: "javascript:void(0)"} Something else here + -# %li.divider + -# %li.dropdown-header Dropdown header + -# %li + -# %a{href: "javascript:void(0)"} Separated link + -# %li + -# %a{href: "javascript:void(0)"} One more separated link + %form.navbar-form.navbar-left = render 'crops/search_bar' - - .navbar-collapse.collapse#navbar-collapse + -# .form-group + -# %input.form-control.col-sm-8{placeholder: "Search", type: "text"}/ %ul.nav.navbar-nav.navbar-right %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path } - = t('.crops') - %b.caret + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path }= t('.crops') %ul.dropdown-menu %li= link_to t('.browse_crops'), crops_path %li= link_to t('.seeds'), seeds_path @@ -33,13 +53,11 @@ %li.dropdown< %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: members_path } = t('.community') - %b.caret %ul.dropdown-menu %li= link_to t('.community_map'), places_path %li= link_to t('.browse_members'), members_path %li= link_to t('.posts'), posts_path %li= link_to t('.forums'), forums_path - - if member_signed_in? %li.dropdown< %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: root_path } @@ -47,7 +65,6 @@ = t('.your_stuff', unread_count: current_member.notifications.unread_count) - else = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) - %b.caret %ul.dropdown-menu %li= link_to t('.profile'), member_path(current_member) %li= link_to t('.gardens'), member_gardens_path(current_member) @@ -68,13 +85,11 @@ - if current_member.role?(:admin) %li= link_to t('.admin'), admin_path - %li= link_to t('.sign_out'), destroy_member_session_path, method: :delete - else %li= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' %li= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' - -# anchor tag for accessibility link to skip the navigation menu -%a{ name: 'skipnav' } +%a{ name: 'skipnav' } \ No newline at end of file diff --git a/app/views/layouts/_nav.haml b/app/views/layouts/_nav.haml index 62310672c..86b4d1e4b 100644 --- a/app/views/layouts/_nav.haml +++ b/app/views/layouts/_nav.haml @@ -1,13 +1,13 @@ - content_for :buttonbar do - if current_member.present? - = link_to url_for([current_member, model]), class: 'btn btn-default' do + = link_to url_for([current_member, model]), class: 'btn' do My #{model.model_name.human.pluralize} - = link_to model, class: 'btn btn-default' do + = link_to model, class: 'btn' do Everyone's #{model.model_name.human.pluralize} - if can?(:create, model) - = link_to url_for([model, action: :new]), class: 'btn btn-default' do + = link_to url_for([model, action: :new]), class: 'btn' do Add a #{model.model_name.human} - unless current_member diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index c1f2c2e33..d34b311c5 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -8,15 +8,15 @@ #maincontainer .row .col-md-6 + + - if content_for?(:buttonbar) + = yield(:buttonbar) + - if content_for?(:title) %h1#title = yield(:title) - if content_for?(:subtitle) %small= yield(:subtitle) - - - if content_for?(:buttonbar) - .btn-group.layout-actions - = yield(:buttonbar) .col-md-6 = render 'shared/global_actions' diff --git a/app/views/members/_avatar.html.haml b/app/views/members/_avatar.html.haml index 421424256..484b8575a 100644 --- a/app/views/members/_avatar.html.haml +++ b/app/views/members/_avatar.html.haml @@ -1,5 +1,4 @@ -- if member - = link_to image_tag(avatar_uri(member, 150), - alt: '', - class: 'img img-responsive avatar'), - member_path(member) += link_to image_tag(avatar_uri(member, 150), + alt: member, + class: 'img img-responsive avatar mr-3'), + member_path(member) diff --git a/app/views/members/_thumbnail.html.haml b/app/views/members/_thumbnail.html.haml index c9504ea96..c64f36843 100644 --- a/app/views/members/_thumbnail.html.haml +++ b/app/views/members/_thumbnail.html.haml @@ -1,26 +1,38 @@ +-# .member-thumbnail.well +-# %div +-# = render "members/avatar", member: member +-# %div +-# %p.login-name +-# = link_to member.login_name, member +-# - unless member.location.blank? +-# %small +-# %br/ +-# %i= member.location +-# - unless member.plantings.empty? +-# %small +-# %br/ +-# Recently planted: +-# != member.plantings.order(created_at: :desc).first(3).map { |p| link_to p.crop_name, p }.join(", ") - cache member do - .member-thumbnail.panel - %div - = render partial: "members/avatar", locals: { member: member } - %div - %p.login-name - = link_to member.login_name, member - - unless member.location.blank? - %small - %br/ - %i= member.location - - unless member.plantings.empty? - %small - %br/ - Recently planted: - != member.plantings.order(created_at: :desc).first(3).map { |p| link_to p.crop_name, p }.join(", ") + .card.text-center + / Background color + .card-up.teal.lighten-2 + / Avatar + .avatar.mx-auto.white + = link_to member do + = image_tag(avatar_uri(member, 150), class: 'rounded-circle img-fluid', alt: member) + .card-body + / Name + %h4.card-title + = link_to member, member + %hr/ %p %small Joined = distance_of_time_in_words(member.created_at, Time.zone.now) ago. %p - %small - = [localize_plural(member.gardens, Garden), - localize_plural(member.plantings, Planting), - localize_plural(member.seeds, Seed)].join(", ") + %ul.nav.md-pills.nav-justified.pills-pink.small + %li.nav-item= link_to localize_plural(member.plantings, Planting), member_plantings_path(member) + %li.nav-item= link_to localize_plural(member.harvests, Harvest), member_harvests_path(member) + %li.nav-item= link_to localize_plural(member.seeds, Seed), member_seeds_path(member) diff --git a/app/views/photos/_actions.html.haml b/app/views/photos/_actions.html.haml index 95d9de0d1..1b19a50a5 100644 --- a/app/views/photos/_actions.html.haml +++ b/app/views/photos/_actions.html.haml @@ -2,6 +2,6 @@ - if can?(:edit, @photo) && can?(:destroy, @photo) %p - if can?(:edit, @photo) - = edit_button(@photo) + = edit_button(edit_photo_path(@photo)) - if can?(:destroy, @photo) = delete_button(@photo) diff --git a/app/views/photos/_item_photos.haml b/app/views/photos/_item_photos.haml index f0642c336..05a2f8319 100644 --- a/app/views/photos/_item_photos.haml +++ b/app/views/photos/_item_photos.haml @@ -8,7 +8,4 @@ - photos.each do |photo| .col-xs-6.col-md-3.six-across= render 'photos/thumbnail', photo: photo -- if can?(:create, Photo) && can?(:edit, item) - = link_to new_photo_path(type: type, id: item.id), class: 'btn btn-primary' do - %span.glyphicon.glyphicon-camera{ title: "Add photo" } - Add photo += add_photo_button(item) diff --git a/app/views/photos/_photo_association_delete.haml b/app/views/photos/_photo_association_delete.haml index fd950821c..9f33d85ba 100644 --- a/app/views/photos/_photo_association_delete.haml +++ b/app/views/photos/_photo_association_delete.haml @@ -1,4 +1,5 @@ - if can? :edit, photo = link_to photo_associations_path(photo_id: photo.id, type: type, id: thing.id), - method: 'delete', class: 'btn btn-default btn-xs' do - = delete_icon + method: 'delete', class: 'btn btn-danger btn-xs' do + %i.fas.fa-backspace + diff --git a/app/views/photos/_photo_associations.html.haml b/app/views/photos/_photo_associations.html.haml index 9bd764cfe..2f1d34317 100644 --- a/app/views/photos/_photo_associations.html.haml +++ b/app/views/photos/_photo_associations.html.haml @@ -1,21 +1,26 @@ %h4 This photo depicts: -%ul - - @photo.plantings.each do |planting| - %li - = link_to t('photos.show.planting', planting: planting.to_s, owner: planting.owner.to_s), planting_path(planting) - = render partial: "photo_association_delete", locals: { photo: @photo, type: 'planting', thing: planting } +%p + %ul.associations + - @photo.plantings.each do |planting| + %li + = planting_icon + = link_to t('photos.show.planting', planting: planting.to_s, owner: planting.owner.to_s), planting_path(planting) + = render partial: "photo_association_delete", locals: { photo: @photo, type: 'planting', thing: planting } - - @photo.harvests.each do |harvest| - %li - = link_to t('photos.show.harvest', crop: harvest.crop.name, owner: harvest.owner.to_s), harvest_path(harvest) - = render partial: "photo_association_delete", locals: { photo: @photo, type: 'harvest', thing: harvest } + - @photo.harvests.each do |harvest| + %li + = harvest_icon + = link_to t('photos.show.harvest', crop: harvest.crop.name, owner: harvest.owner.to_s), harvest_path(harvest) + = render partial: "photo_association_delete", locals: { photo: @photo, type: 'harvest', thing: harvest } - - @photo.gardens.each do |garden| - %li - = link_to t('photos.show.garden', garden: garden.to_s, owner: garden.owner.to_s), garden_path(garden) - = render partial: "photo_association_delete", locals: { photo: @photo, type: 'garden', thing: garden } + - @photo.gardens.each do |garden| + %li + = garden_icon + = link_to t('photos.show.garden', garden: garden.to_s, owner: garden.owner.to_s), garden_path(garden) + = render partial: "photo_association_delete", locals: { photo: @photo, type: 'garden', thing: garden } - - @photo.seeds.each do |seed| - %li - = link_to t('photos.show.seed', seed: seed.to_s, owner: seed.owner.to_s), seed_path(seed) - = render partial: "photo_association_delete", locals: { photo: @photo, type: 'seed', thing: seed } + - @photo.seeds.each do |seed| + %li + = seed_icon + = link_to t('photos.show.seed', seed: seed.to_s, owner: seed.owner.to_s), seed_path(seed) + = render partial: "photo_association_delete", locals: { photo: @photo, type: 'seed', thing: seed } diff --git a/app/views/photos/edit.html.haml b/app/views/photos/edit.html.haml index 04068b570..33ecfac34 100644 --- a/app/views/photos/edit.html.haml +++ b/app/views/photos/edit.html.haml @@ -1,5 +1,10 @@ -- content_for :title, "Edit Photo" -= form_for(@photo) do |f| - = f.label :title - = f.text_field :title, placeholder: "title" - = f.submit +.rol + .col-md-2= render 'photos/thumbnail', photo: @photo + .col-md-10 + - content_for :title, "Edit Photo" + = form_for(@photo) do |f| + .form-group + = f.label :title + = f.text_field :title, placeholder: "title" + .form-group + .form-actions= f.submit 'Save', class: 'btn' diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 78f5074a4..27aa0e5ed 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -8,13 +8,13 @@ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) .row - .col-md-8 - %p= image_tag(@photo.fullsize_url, alt: @photo.title, class: 'img img-responsive') - - .col-md-4 - = render 'photos/actions', photo: @photo + .col-md-5 + - if @crops.size.positive? + - @crops.each do |crop| + = render 'crops/index_card', crop: crop %p - %strong Posted by: + %i.fas.fa-camera-retro + %strong Photo by = link_to @photo.owner, @photo.owner %p %strong License: @@ -22,13 +22,13 @@ = link_to @photo.license_name, @photo.license_url - else = succeed "." do - = @photo.license_name - - %p= link_to "View on Flickr", @photo.link_url + = @photo.license_name + - if @photo.associations? = render "photo_associations", locals: { photo: @photo } - - - if @crops.size.positive? - - @crops.each do |crop| - = render 'crops/index_card', crop: crop + = render 'photos/actions', photo: @photo + .col-md-7 + //%img.img-fluid.z-depth-1{:alt => "1", :src => "https://mdbootstrap.com/img/Photos/Slides/img%20(54).jpg"}/ + %p= image_tag(@photo.fullsize_url, alt: @photo.title, class: 'rounded img-fluid z-depth-1 float-right ') + %p= link_to "View on Flickr", @photo.link_url, class: 'btn' diff --git a/app/views/plantings/_descendants.html.haml b/app/views/plantings/_descendants.html.haml index 27e81c6b8..35f320551 100644 --- a/app/views/plantings/_descendants.html.haml +++ b/app/views/plantings/_descendants.html.haml @@ -8,7 +8,4 @@ - else %p No seeds saved -- if planting.active? && can?(:create, Seed) && can?(:edit, planting) - = link_to new_planting_seed_path(planting), class: 'btn btn-primary' do - %span.glyphicon.glyphicon-heart{ title: "Add photo" } - Save seeds += planting_save_seeds_button(planting) \ No newline at end of file diff --git a/app/views/plantings/_harvests.html.haml b/app/views/plantings/_harvests.html.haml index a845e980e..a457f2fd3 100644 --- a/app/views/plantings/_harvests.html.haml +++ b/app/views/plantings/_harvests.html.haml @@ -7,7 +7,4 @@ .col-xs-6.col-sm-4.col-md-3 = render 'harvests/thumbnail', harvest: harvest -- if planting.active? && can?(:edit, planting) - = link_to new_planting_harvest_path(planting), class: 'btn btn-primary' do - %span.glyphicon.glyphicon-leaf{ title: "Harvest" } - Harvest += planting_harvest_button(planting) diff --git a/app/views/plantings/_image_with_popover.html.haml b/app/views/plantings/_image_with_popover.html.haml index 740562fda..41a5c3b26 100644 --- a/app/views/plantings/_image_with_popover.html.haml +++ b/app/views/plantings/_image_with_popover.html.haml @@ -1,7 +1,7 @@ - cache planting do = link_to image_tag(planting_image_path(planting), alt: planting.to_s, - class: 'image-responsive crop-image'), + class: 'image-responsive'), planting, rel: "popover", 'data-trigger': 'hover', diff --git a/app/views/plantings/_list.html.haml b/app/views/plantings/_list.html.haml index 21be75416..0e2a87148 100644 --- a/app/views/plantings/_list.html.haml +++ b/app/views/plantings/_list.html.haml @@ -1,10 +1,14 @@ -- plantings.each do |p| - - cache p do - .row - .col-lg-6.col-md-3.col-xs-4.homepage-listing - = render 'plantings/image_with_popover', planting: p - .col-lg-3.col-md-9.col-xs-4 - = link_to p.crop, p.crop - %br/ - %small - %i= p.location +- plantings.each do |planting| + - cache planting do + .card + .view.overlay + = link_to planting do + %img.card-img-top.img-responsive{alt: planting, src: planting_image_path(planting, full_size: true)}/ + .card-body.p-3 + %h5.card-title.font-weight-bold.fuchsia-rose-text.mb-0 + = link_to planting, planting + + %p.float-right + = link_to planting.owner do + = image_tag(avatar_uri(planting.owner, 50), alt: '', class: 'img img-responsive avatar rounded-circle') + %hr/ diff --git a/app/views/plantings/_quick_actions.haml b/app/views/plantings/_quick_actions.haml index 5a8b02c3e..a190f7a9b 100644 --- a/app/views/plantings/_quick_actions.haml +++ b/app/views/plantings/_quick_actions.haml @@ -1,13 +1,16 @@ - if can?(:edit, planting) .planting-quick-actions.pull-right - %a.btn.btn-default.btn-xs#actionsMenu.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", href: "#"} - =icon('fas', 'bars') - %ul.dropdown-menu{"aria-labelledby" => "actionsMenu"} - - if can?(:edit, planting) - %li= planting_edit_button(planting) - %li= add_photo_button(planting) + %a.btn#actionsMenu.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", href: "#"} + -# =icon('fas', 'ellipsis-v') + %ul.dropdown-menu.dropdown-menu-left{"aria-labelledby" => "actionsMenu"} + %li.btn-xs + = link_to t('view'), planting, class: 'btn' + %li.btn-xs= planting_edit_button(planting) + %li.btn-xs= add_photo_button(planting) + + - if planting.active? + %li.btn-xs= planting_finish_button(planting) + %li.btn-xs= planting_harvest_button(planting) + %li.btn-xs= planting_save_seeds_button(planting) + - - if planting.active? - %li= planting_finish_button(planting) - %li= planting_harvest_button(planting) - %li= planting_save_seeds_button(planting) diff --git a/app/views/plantings/_stats.haml b/app/views/plantings/_stats.haml new file mode 100644 index 000000000..31c87329e --- /dev/null +++ b/app/views/plantings/_stats.haml @@ -0,0 +1,13 @@ +.planting-stats + %span.badge.harvest-count{'data-toggle': "tooltip", 'data-placement': "top", title: 'Harvests'} + = harvest_icon + = planting.harvests.size + %span.badge.child-seeds-count{'data-toggle': "tooltip", 'data-placement': "top", title: 'Seeds saved'} + = seed_icon + = planting.child_seeds.size + %span.badge.photos-count{'data-toggle': "tooltip", 'data-placement': "top", title: 'Photos'} + = photo_icon + = planting.photos.size + %span.badge.photos-count{'data-toggle': "tooltip", 'data-placement': "top", title: 'Age in days'} + = planting_icon + = planting.age_in_days diff --git a/app/views/plantings/show.html.haml b/app/views/plantings/show.html.haml index 970aa43b7..45119150b 100644 --- a/app/views/plantings/show.html.haml +++ b/app/views/plantings/show.html.haml @@ -73,7 +73,7 @@ %dd= render 'plantings/progress', planting: @planting, show_explanation: true .col-xs-12.col-sm-6 - = render partial: "crops/index_card", locals: { crop: @planting.crop } + = render "crops/index_card", crop: @planting.crop - if @planting.owner.location %p %small diff --git a/app/views/seeds/_actions.html.haml b/app/views/seeds/_actions.html.haml index c801142a4..719c12de9 100644 --- a/app/views/seeds/_actions.html.haml +++ b/app/views/seeds/_actions.html.haml @@ -5,10 +5,10 @@ = add_photo_button(seed) - if can?(:create, Planting) && seed.active? - = link_to new_planting_path(seed_id: seed), class: 'btn btn-default btn-xs' do + = link_to new_planting_path(seed_id: seed), class: 'btn btn-default' do %span.glyphicon.glyphicon-grain{ title: "Plant seeds" } Plant seeds - = render 'shared/buttons/finish_seeds', seed: seed + = seed_finish_button(seed) = delete_button(seed) if can? :destroy, seed diff --git a/app/views/seeds/_list.html.haml b/app/views/seeds/_list.html.haml new file mode 100644 index 000000000..189ff7052 --- /dev/null +++ b/app/views/seeds/_list.html.haml @@ -0,0 +1,16 @@ +- seeds.each do |seed| + - cache seed do + .col-lg-3.col-md-4.col-sm-3.col-xs-6 + .card + .view.overlay + = link_to seed do + = image_tag(seed_image_path(seed, full_size: true), alt: seed, class: 'card-img-top img-responsive') + .card-body.p-3 + %h5.card-title.font-weight-bold.fuchsia-rose-text.mb-0 + = link_to seed, seed + %p + %i #{seed.owner.location} + %p Will trade #{seed.tradable_to} + %p.float-right + = link_to seed.owner do + = image_tag(avatar_uri(seed.owner, 50), alt: '', class: 'img img-responsive avatar rounded') \ No newline at end of file diff --git a/app/views/seeds/_thumbnail.html.haml b/app/views/seeds/_thumbnail.html.haml index 38aa66d65..c66b0948b 100644 --- a/app/views/seeds/_thumbnail.html.haml +++ b/app/views/seeds/_thumbnail.html.haml @@ -1,14 +1,12 @@ -.thumbnail - .seed-thumbnail - = link_to image_tag(seed_image_path(seed), - alt: seed.crop.name, class: 'img'), - seed_path(seed) - .seedinfo - .seed-name - = link_to seed, seed_path(seed) - .trade-to - %p= seed.owner.location - %p - Will trade to: - %br/ - = seed.tradable_to +- cache cache_key_for(Seed, seed.id) do + .thumbnail + .seed-thumbnail + = link_to image_tag(seed_image_path(seed), + alt: seed.name, class: 'img'), + seed + .seedinfo + .seedname + = link_to seed.name, seed + %small.trade-to + %p #{seed.owner.location} + %p Will trade #{seed.tradable_to} diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 0f51209bf..cc9961885 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,22 +1,24 @@ - if signed_in? .global-actions.pull-right - .btn-group - = link_to member_gardens_path(current_member), class: 'btn btn-default' do - = garden_icon - = t('links.my_gardens') .btn-group - = link_to new_planting_path, class: 'btn btn-default' do + = link_to new_planting_path, class: "btn #{current_page?(new_planting_path) ? 'btn-primary' : ''}" do = planting_icon = t('plantings.plant_something') - = link_to new_harvest_path, class: 'btn btn-default' do + = link_to new_harvest_path, class: "btn #{current_page?(new_harvest_path) ? 'btn-primary' : ''}" do = harvest_icon = t('harvests.harvest_something') - = link_to new_seed_path, class: 'btn btn-default' do + = link_to new_seed_path, class: "btn #{current_page?(new_seed_path) ? 'btn-primary' : ''}" do = seed_icon = t('buttons.save_seeds') - .btn-group - = link_to t('posts.write_blog_post'), new_post_path, class: 'btn btn-default' + -# .btn-group + -# = link_to t('posts.write_blog_post'), new_post_path, class: 'btn' + + - unless current_page?(member_gardens_path(current_member)) + .btn-group + = link_to member_gardens_path(current_member), class: "btn" do + = garden_icon + = t('links.my_gardens') diff --git a/app/views/shared/buttons/_finish_seeds.haml b/app/views/shared/buttons/_finish_seeds.haml deleted file mode 100644 index 23316d861..000000000 --- a/app/views/shared/buttons/_finish_seeds.haml +++ /dev/null @@ -1,5 +0,0 @@ -- unless seed.finished - = link_to seed_path(seed, seed: { finished: 1 }), - method: :put, class: 'btn btn-default btn-xs append-date' do - = render 'shared/glyphicon', icon: 'ok', title: 'buttons.finished' - =t('buttons.mark_as_finished') diff --git a/config/environments/development.rb b/config/environments/development.rb index 46106e08d..1992a8d2f 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -79,6 +79,6 @@ Rails.application.configure do config.after_initialize do Bullet.enable = true Bullet.rails_logger = true - Bullet.add_footer = true + # Bullet.add_footer = true end end diff --git a/config/environments/production.rb b/config/environments/production.rb index 95f82b4c8..cd0492e5c 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -118,4 +118,6 @@ Rails.application.configure do # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + + config.bot_email = 'cropbot@growstuff.org' end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 88439fae1..a839b6758 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -145,12 +145,12 @@ describe Photo do seed.photos << seed_photo end - it { expect(Photo.by_model(Harvest)).to eq([ harvest_photo ]) } - it { expect(Photo.by_model(Planting)).to eq([ planting_photo ]) } - it { expect(Photo.by_model(Seed)).to eq([ seed_photo ]) } + it { expect(Photo.by_model(Harvest)).to eq([harvest_photo]) } + it { expect(Photo.by_model(Planting)).to eq([planting_photo]) } + it { expect(Photo.by_model(Seed)).to eq([seed_photo]) } - it { expect(Photo.by_crop(harvest_crop)).to eq([ harvest_photo ]) } - it { expect(Photo.by_crop(planting_crop)).to eq([ planting_photo ]) } - it { expect(Photo.by_crop(seed_crop)).to eq([ seed_photo ]) } + it { expect(Photo.by_crop(harvest_crop)).to eq([harvest_photo]) } + it { expect(Photo.by_crop(planting_crop)).to eq([planting_photo]) } + it { expect(Photo.by_crop(seed_crop)).to eq([seed_photo]) } end end From ba3ee3a9f0277f1605ae639fdbca2eae8addfb4f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 21 Apr 2019 13:54:38 +1200 Subject: [PATCH 004/549] Tidy up login form --- app/assets/stylesheets/overrides.sass | 7 ++++ app/views/devise/sessions/new.html.haml | 43 +++++++++---------------- app/views/devise/shared/_links.haml | 24 ++++++++------ 3 files changed, 38 insertions(+), 36 deletions(-) diff --git a/app/assets/stylesheets/overrides.sass b/app/assets/stylesheets/overrides.sass index 8f7915980..86ee57b85 100644 --- a/app/assets/stylesheets/overrides.sass +++ b/app/assets/stylesheets/overrides.sass @@ -346,6 +346,13 @@ ul.thumbnail-buttons .navbar .navbar-form width: 250px +.login-page + text-align: center + .login-card + max-width: 500px + text-align: center + display: inline-block + // Overrides applying only to mobile view. This must be at the end of the overrides file. @media only screen and (max-width: 767px) .sidebar diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 085ae9fe3..8be829730 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -1,31 +1,20 @@ -- content_for :title, "Sign in" -= form_for(resource, as: resource_name, - url: session_path(resource_name), - html: { class: "form-horizontal" }) do |f| - = devise_error_messages! - - .form-group - = f.label :login, class: "control-label col-md-2" - .col-md-8 - = f.text_field :login, class: 'form-control' - - .form-group - = f.label :password, class: "control-label col-md-2" - .col-md-8 - = f.password_field :password, class: 'form-control' - - - if devise_mapping.rememberable? - .form-group - .col-md-8.col-md-offset-2.checkbox - %label +.login-page + %section.card.login-card + %h1 Sign in + = form_for(resource, as: resource_name, + url: session_path(resource_name), + html: { class: "text-center border border-light p-5" }) do |f| + = devise_error_messages! + = f.text_field :login, class: "form-control mb-4", placeholder: "E-mail", type: "email" + = f.password_field :password, class: 'form-control mb-4', placeholder: "Password", type: "password" + - if devise_mapping.rememberable? + %p = f.check_box :remember_me Remember me + - if devise_mapping.recoverable? && controller_name != 'passwords' + %p + = link_to "Forgot password?", new_password_path(resource_name) + = f.submit "Sign in", class: 'btn btn-block my-4 btn-primary' - .form-group - .form-actions.col-md-8.col-md-offset-2 - = f.submit "Sign in", class: 'btn btn-primary' - - .form-group - .col-md-8.col-md-offset-2 - = render "devise/shared/links" + = render "devise/shared/links" diff --git a/app/views/devise/shared/_links.haml b/app/views/devise/shared/_links.haml index e3b7c3300..b36c31bf3 100644 --- a/app/views/devise/shared/_links.haml +++ b/app/views/devise/shared/_links.haml @@ -1,17 +1,23 @@ -- if devise_mapping.recoverable? && controller_name != 'passwords' - = link_to "Forgot your password?", new_password_path(resource_name) - %br +-# - if devise_mapping.recoverable? && controller_name != 'passwords' +-# = link_to "Forgot password?", new_password_path(resource_name) +-# %br + - if devise_mapping.confirmable? && controller_name != 'confirmations' - = link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) - %br + %p + %small= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) - if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' - = link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) - %br + %p + %small= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) - if devise_mapping.omniauthable? - resource_class.omniauth_providers.each do |provider| - = link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) - %br + %p + = link_to omniauth_authorize_path(resource_name, provider) do + = icon 'fab', provider + Sign in with #{provider.to_s.titleize} + %p + Not a member? + =link_to 'Register', new_member_registration_path \ No newline at end of file From 730c2b79f734815f821898632e5ebaecdbc42e27 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 21 Apr 2019 14:01:45 +1200 Subject: [PATCH 005/549] Tidy up forgot password page --- app/assets/stylesheets/overrides.sass | 4 ++-- app/views/devise/passwords/new.html.haml | 27 +++++++++++------------- app/views/devise/sessions/new.html.haml | 4 ++-- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/app/assets/stylesheets/overrides.sass b/app/assets/stylesheets/overrides.sass index 86ee57b85..061c56335 100644 --- a/app/assets/stylesheets/overrides.sass +++ b/app/assets/stylesheets/overrides.sass @@ -346,9 +346,9 @@ ul.thumbnail-buttons .navbar .navbar-form width: 250px -.login-page +.form-page text-align: center - .login-card + .form-card max-width: 500px text-align: center display: inline-block diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml index 95ea33ff5..fe8df5ba0 100644 --- a/app/views/devise/passwords/new.html.haml +++ b/app/views/devise/passwords/new.html.haml @@ -1,19 +1,16 @@ -- content_for :title, "Forgot your password?" -= form_for(resource, as: resource_name, - url: password_path(resource_name), - html: { method: :post, - class: 'form-horizontal', role: 'form' }) do |f| - = devise_error_messages! +.form-page + %section.card.form-card + %h2 Forgot your password? + = form_for(resource, as: resource_name, + url: password_path(resource_name), + html: { method: :post, + class: 'text-center border border-light p-5', role: 'form' }) do |f| + = devise_error_messages! - .form-group - = f.label :login, class: 'control-label col-md-2' - .col-md-8 - = f.text_field :login, class: 'form-control' - .form-group - .form-actions.col-md-offset-2.col-md-8 + = f.text_field :login, class: "form-control mb-4", placeholder: "E-mail", type: "email" = f.submit "Send me reset password instructions", class: 'btn btn-primary' - .form-group - .col-md-offset-2.col-md-8 - = render "devise/shared/links" + .form-group + .col-md-offset-2.col-md-8 + = render "devise/shared/links" diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 8be829730..cb3764270 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -1,6 +1,6 @@ -.login-page - %section.card.login-card +.form-page + %section.card.form-card %h1 Sign in = form_for(resource, as: resource_name, url: session_path(resource_name), From e6e50a3a42252864efe292fdd9c2e20677f1ae22 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 21 Apr 2019 14:02:04 +1200 Subject: [PATCH 006/549] Turn the plantings facts into cards with drop shadow --- app/views/plantings/_facts.haml | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/app/views/plantings/_facts.haml b/app/views/plantings/_facts.haml index 5c57da05c..2d8d3ec5d 100644 --- a/app/views/plantings/_facts.haml +++ b/app/views/plantings/_facts.haml @@ -1,25 +1,24 @@ .planting-facts - - if planting.parent_seed - .fact + .fact.card %h3 Parent seed %strong = link_to @planting.parent_seed, seed_path(@planting.parent_seed) - if planting.finished - .fact.grid-sizer + .fact.card.grid-sizer %h3 Planted %strong=planting_icon - if planting.quantity.present? %span= planting.quantity - if planting.planted_at.present? && !planting.finished? - .fact + .fact.card %h3 Planted %strong #{planting.days_since_planted} %span days ago - if planting.quantity.to_i.positive? - .fact + .fact.card %h3 Quantity %strong= planting.quantity %span @@ -27,13 +26,13 @@ #{pluralize((planting.quantity.to_i), planting.planted_from)} - unless planting.finished? - .fact.grid-sizer + .fact.card.grid-sizer %h3 Growing %strong= seedling_icon %span= planting.planted_at.to_formatted_s(:rfc822) - if planting.percentage_grown - .fact + .fact.card %h3 Progress %strong #{sprintf '%.0f', planting.percentage_grown}% .progress @@ -44,16 +43,16 @@ - if planting.planted_from.present? - .fact + .fact.card %h3 Grown from %span=planting.planted_from - .fact + .fact.card %h3 Grown in %strong= sunniness_icon(planting.sunniness) %span= planting.sunniness.blank? ? "not specified" : planting.sunniness - -# .fact + -# .fact.card -# %h3 Garden -# = link_to planting.garden do -# - if planting.garden.default_photo.present? @@ -62,7 +61,7 @@ -# %strong= garden_icon -# %span= planting.garden.name - .fact + .fact.card %h3 = planting.finished? ? "Harvests" : "Harvesting" %strong @@ -71,12 +70,12 @@ %span= planting.first_harvest_date&.to_formatted_s(:rfc822) || planting&.first_harvest_predicted_at&.to_formatted_s(:rfc822) || 'unknown' - if planting.crop.perennial - .fact + .fact.card %h3 Perennial %strong=perennial_icon - else - if !planting.finished? && planting.finish_is_predicatable? - .fact + .fact.card - days = days_from_now_to_finished(planting) - if days.positive? %h3 Prediction @@ -89,7 +88,7 @@ %span= planting.finish_predicted_at&.to_formatted_s(:rfc822) - if planting.child_seeds.size.positive? - .fact + .fact.card %h3 Seeds saved %strong = link_to planting_seeds_path(planting) do @@ -97,7 +96,7 @@ %span #{pluralize(planting.child_seeds.size, 'packet')} of seed - if planting.finished? - .fact + .fact.card %h3 Finished %strong=finished_icon %span=planting.finished_at&.to_formatted_s(:rfc822) From ee03b57d8919fff26e6539a96cdc476d5445f9b0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 21 Apr 2019 15:02:04 +1200 Subject: [PATCH 007/549] Tidy up sign up form --- app/assets/stylesheets/overrides.sass | 1 + app/views/devise/passwords/new.html.haml | 2 +- app/views/devise/registrations/new.html.haml | 64 ++++++++------------ 3 files changed, 27 insertions(+), 40 deletions(-) diff --git a/app/assets/stylesheets/overrides.sass b/app/assets/stylesheets/overrides.sass index 061c56335..e7e72a2b9 100644 --- a/app/assets/stylesheets/overrides.sass +++ b/app/assets/stylesheets/overrides.sass @@ -352,6 +352,7 @@ ul.thumbnail-buttons max-width: 500px text-align: center display: inline-block + padding: 1em // Overrides applying only to mobile view. This must be at the end of the overrides file. @media only screen and (max-width: 767px) diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml index fe8df5ba0..1ff9114ff 100644 --- a/app/views/devise/passwords/new.html.haml +++ b/app/views/devise/passwords/new.html.haml @@ -9,7 +9,7 @@ = devise_error_messages! = f.text_field :login, class: "form-control mb-4", placeholder: "E-mail", type: "email" - = f.submit "Send me reset password instructions", class: 'btn btn-primary' + = f.submit "Send me reset password instructions", class: 'btn btn-block my-4 btn-primary' .form-group .col-md-offset-2.col-md-8 diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index b9e61347c..bf0329f4f 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -1,51 +1,37 @@ -- content_for :title, "Join Growstuff" +.form-page + %section.card.form-card + %h2 Join Growstuff + .card-body + %p Sign up for a Growstuff account to track your veggie garden and connect with other local growers. -%p Sign up for a Growstuff account to track your veggie garden and connect with other local growers. + = form_for(resource, as: resource_name, + url: registration_path(resource_name), + html: { class: "text-center border border-light p-5" }) do |f| + = devise_error_messages! -= form_for(resource, as: resource_name, - url: registration_path(resource_name), - html: { class: "form-horizontal" }) do |f| - = devise_error_messages! + = f.text_field :login_name, class: 'form-control form-control-lg{', placeholder: 'login name' + %span This is the name that will show on the website. - .form-group - = f.label :login_name, class: "control-label col-md-2" - .col-md-8 - = f.text_field :login_name, class: 'form-control' - %span.help-inline This is the name that will show on the website. + = icon 'fas', 'email' + = f.email_field :email, class: 'form-control', placeholder: 'email', type: :email + %span We'll use this address to contact you (we never spam!) - .form-group - = f.label :email, class: "control-label col-md-2" - .col-md-8 - = f.email_field :email, class: 'form-control' - %span.help-inline We'll use this address to contact you (we never spam!) + %hr/ + = f.password_field :password, class: "form-control", placeholder: 'password', type: :password + = f.password_field :password_confirmation, class: 'form-control', placeholder: 'confirm password' - .form-group - = f.label :password, class: "control-label col-md-2" - .col-md-8= f.password_field :password, class: 'form-control' + %hr/ - .form-group - = f.label :password_confirmation, class: "control-label col-md-2" - .col-md-8= f.password_field :password_confirmation, class: 'form-control' - - .form-group - .col-md-offset-2.col-md-8.checkbox - %label + %p = f.check_box :tos_agreement I agree to the - = succeed "." do - = link_to 'Terms of Service', "#{root_url}/policy/tos" - .form-group - .col-md-offset-2.col-md-8.checkbox - %label + = link_to 'Terms of Service', "#{root_url}/policy/tos" + + %p = f.check_box :newsletter, checked: true Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} newsletter - .help-inline - = render partial: 'newsletter_blurb' + %p= render partial: 'newsletter_blurb' - .form-group - .form-actions.col-md-offset-2.col-md-8 - = f.submit "Sign up", class: 'btn btn-primary' + = f.submit "Sign up", class: 'btn btn-block my-4 btn-primary' - .form-group - .col-md-offset-2.col-md-8 - = render "devise/shared/links" + = render "devise/shared/links" From 9dfe4d5b2de957d160ef86709ca7c0917bad925e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 21 Apr 2019 15:24:45 +1200 Subject: [PATCH 008/549] More form tidy up --- app/views/devise/confirmations/new.html.haml | 29 ++++++++---------- app/views/devise/registrations/new.html.haml | 2 +- app/views/devise/unlocks/new.html.haml | 32 +++++++++----------- 3 files changed, 29 insertions(+), 34 deletions(-) diff --git a/app/views/devise/confirmations/new.html.haml b/app/views/devise/confirmations/new.html.haml index 526b99efa..a17ab86a9 100644 --- a/app/views/devise/confirmations/new.html.haml +++ b/app/views/devise/confirmations/new.html.haml @@ -1,20 +1,17 @@ -- content_for :title, "Resend confirmation instructions" -= form_for(resource, as: resource_name, - url: confirmation_path(resource_name), - html: { method: :post, class: 'form-horizontal', role: 'form' }) do |f| - = devise_error_messages! +.form-page + .card.form-card + %h2 Resend confirmation instructions + = form_for(resource, as: resource_name, + url: confirmation_path(resource_name), + html: { method: :post, class: 'form-horizontal', role: 'form' }) do |f| + = devise_error_messages! - %p Enter either your login name or your email address to resend the confirmation email. + %p Enter either your login name or your email address to resend the confirmation email. - .form-group - = f.label :login, class: 'control-label col-md-2' - .col-md-8 - = f.text_field :login, class: 'form-control' - .form-group - .form-actions.col-md-offset-2.col-md-8 - = f.submit "Resend confirmation instructions", class: 'btn btn-primary' + = f.text_field :login, class: 'form-control', placeholder: 'email or login name' + = f.submit "Resend confirmation instructions", class: 'btn btn-block my-4 btn-primary' - .form-group - .col-md-offset-2.col-md-8 - = render "devise/shared/links" + .form-group + .col-md-offset-2.col-md-8 + = render "devise/shared/links" diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index bf0329f4f..5cb413d4d 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -1,6 +1,6 @@ .form-page %section.card.form-card - %h2 Join Growstuff + %h1 Join Growstuff .card-body %p Sign up for a Growstuff account to track your veggie garden and connect with other local growers. diff --git a/app/views/devise/unlocks/new.html.haml b/app/views/devise/unlocks/new.html.haml index be29d7fb5..3160bcfac 100644 --- a/app/views/devise/unlocks/new.html.haml +++ b/app/views/devise/unlocks/new.html.haml @@ -1,20 +1,18 @@ -- content_for :title, "Resend unlock instructions" +- content_for :title, "" +.form-page + .card.form-card + = form_for(resource, as: resource_name, + url: unlock_path(resource_name), + html: { method: :post, + class: 'form-horizontal', + role: 'form' }) do |f| -= form_for(resource, as: resource_name, - url: unlock_path(resource_name), - html: { method: :post, - class: 'form-horizontal', - role: 'form' }) do |f| - = devise_error_messages! + %h2 Resend unlock instructions + = devise_error_messages! - .form-group - = f.label :email, class: 'control-label col-md-2' - .col-md-8 - = f.email_field :email, class: 'form-control' - .form-group - .form-actions.col-md-offset-2.col-md-8 - = f.submit "Resend unlock instructions", class: 'btn btn-primary' + = f.email_field :email, class: 'form-control', placeholder: 'email' - .form-group - .col-md-offset-2.col-md-8 - = render "devise/shared/links" + = f.submit "Resend unlock instructions", class: 'btn btn-block my-4 btn-primary' + + + = render "devise/shared/links" From 64877fe2ac30f0a255e7740ab5bea486e327cd95 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 21 Apr 2019 19:07:33 +1200 Subject: [PATCH 009/549] more tidy up of password reset form --- app/views/devise/passwords/new.html.haml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml index 1ff9114ff..f7ee373db 100644 --- a/app/views/devise/passwords/new.html.haml +++ b/app/views/devise/passwords/new.html.haml @@ -11,6 +11,4 @@ = f.text_field :login, class: "form-control mb-4", placeholder: "E-mail", type: "email" = f.submit "Send me reset password instructions", class: 'btn btn-block my-4 btn-primary' - .form-group - .col-md-offset-2.col-md-8 - = render "devise/shared/links" + = render "devise/shared/links" From ab7eb913de3df7e4164de6d2c160fbd54baa765d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 25 Apr 2019 12:47:24 +1200 Subject: [PATCH 010/549] removed git conflict marker --- app/views/crops/show.html.haml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 9c835e7ee..457d0afcd 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -101,11 +101,7 @@ = render 'alternate_names', crop: @crop - if @crop.parent -<<<<<<< HEAD .parent-crop -======= - .parent-crop ->>>>>>> upstream/dev = @crop.name is a variety of = succeed "." do From 7dd3f169eefe2c75ebc992c51d711205231f989e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 25 Apr 2019 12:49:23 +1200 Subject: [PATCH 011/549] Fixed haml error --- app/views/gardens/show.html.haml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index a1f03e243..e89c739e7 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -100,7 +100,6 @@ - if can?(:edit, @garden) && can?(:create, Photo) %p - = = link_to new_photo_path(type: "garden", id: @garden.id), class: 'btn btn-primary' do %span.glyphicon.glyphicon-camera{ title: "Add photo" } From 4918d0c95093073cd069bc3e407b325c1259a362 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 25 Apr 2019 23:28:41 +1200 Subject: [PATCH 012/549] Tidy up homepage --- app/assets/stylesheets/application.sass | 1 + app/assets/stylesheets/harvests.sass | 7 +++ app/assets/stylesheets/homepage.sass | 13 +++- app/assets/stylesheets/members.sass | 3 + app/assets/stylesheets/plantings.sass | 6 +- app/models/seed.rb | 1 + app/views/harvests/_card.html.haml | 37 ++---------- app/views/harvests/_harvest.haml | 6 ++ app/views/home/_crops.html.haml | 11 +--- app/views/home/_harvests.html.haml | 3 - app/views/home/_members.html.haml | 3 +- app/views/home/_plantings.html.haml | 3 - app/views/home/_seeds.html.haml | 2 +- app/views/home/index.html.haml | 63 ++++++++++--------- app/views/members/_member.haml | 20 ++++++ app/views/members/index.html.haml | 4 +- app/views/plantings/_card.html.haml | 51 ++-------------- app/views/plantings/_thumbnail.html.haml | 24 ++++---- app/views/seeds/_card.html.haml | 77 ++++++++++++++---------- app/views/seeds/_seed.haml | 6 ++ 20 files changed, 167 insertions(+), 174 deletions(-) create mode 100644 app/assets/stylesheets/harvests.sass create mode 100644 app/views/harvests/_harvest.haml delete mode 100644 app/views/home/_harvests.html.haml delete mode 100644 app/views/home/_plantings.html.haml create mode 100644 app/views/members/_member.haml create mode 100644 app/views/seeds/_seed.haml diff --git a/app/assets/stylesheets/application.sass b/app/assets/stylesheets/application.sass index ea06615da..4ed20fc4b 100644 --- a/app/assets/stylesheets/application.sass +++ b/app/assets/stylesheets/application.sass @@ -12,6 +12,7 @@ @import 'predictions' @import 'plantings' @import 'members' +@import 'harvests' @import 'homepage' @import 'photos' diff --git a/app/assets/stylesheets/harvests.sass b/app/assets/stylesheets/harvests.sass new file mode 100644 index 000000000..a4a6281c5 --- /dev/null +++ b/app/assets/stylesheets/harvests.sass @@ -0,0 +1,7 @@ +.harvest-cards + display: flex + flex: none + flex-wrap: wrap + .card + max-width: 200px + margin: 1em \ No newline at end of file diff --git a/app/assets/stylesheets/homepage.sass b/app/assets/stylesheets/homepage.sass index 2feef9319..7fc1818e3 100644 --- a/app/assets/stylesheets/homepage.sass +++ b/app/assets/stylesheets/homepage.sass @@ -14,4 +14,15 @@ border-radius: 6px line-height: 200% padding: 15px - text-align: center \ No newline at end of file + text-align: center + +.homepage-cards,.homepage-thumbnails + display: flex + flex: none + flex-wrap: wrap + .card + max-width: 200px + margin: 1em + .thumbnail + margin: 0.5em + diff --git a/app/assets/stylesheets/members.sass b/app/assets/stylesheets/members.sass index 4de1bdb1a..43da58188 100644 --- a/app/assets/stylesheets/members.sass +++ b/app/assets/stylesheets/members.sass @@ -2,6 +2,9 @@ display: flex flex: none flex-wrap: wrap + .card + max-width: 200px + margin: 1em .member-thumbnail padding: .25em diff --git a/app/assets/stylesheets/plantings.sass b/app/assets/stylesheets/plantings.sass index 449f17a3a..96473b6b3 100644 --- a/app/assets/stylesheets/plantings.sass +++ b/app/assets/stylesheets/plantings.sass @@ -16,8 +16,7 @@ padding: 0em margin-bottom: 0.5em margin-top: 0.5em - border: 1px solid darken($beige, 10%) - border-radius: 4px + .badge font-size: 100% .planting-full-badges @@ -27,8 +26,7 @@ .planting-name position: relative text-align: center - font-size: 150% - top: -0.5em + top: 0em .planting-quick-actions position: absolute //Mine diff --git a/app/models/seed.rb b/app/models/seed.rb index 7c49c9201..51da83e48 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -52,6 +52,7 @@ class Seed < ApplicationRecord scope :tradable, -> { where.not(tradable_to: 'nowhere') } scope :interesting, -> { tradable.has_location } scope :has_location, -> { joins(:owner).where.not("members.location": nil) } + scope :recent, -> { order(created_at: :desc) } def default_photo photos.order(created_at: :desc).first diff --git a/app/views/harvests/_card.html.haml b/app/views/harvests/_card.html.haml index 02ad5d3e0..6c926b9bf 100644 --- a/app/views/harvests/_card.html.haml +++ b/app/views/harvests/_card.html.haml @@ -1,31 +1,6 @@ -.panel.panel-success - .panel-heading - %h3.panel-title - = link_to "#{harvest.owner.login_name}'s #{harvest.crop.name} harvest", harvest - - if can? :edit, harvest - %a.pull-right{ href: edit_harvest_path(harvest), role: "button", id: "edit_harvest_glyphicon" } - %span.glyphicon.glyphicon-pencil{ title: "Edit" } - .panel-body - .row - .col-md-4 - = link_to image_tag(harvest_image_path(harvest), - alt: harvest.crop.name, class: 'img'), - harvest - .col-md-8 - %dl.dl-horizontal - %dt Crop : - %dd= link_to harvest.crop.name, harvest.crop - %dt Plant part : - %dd= link_to harvest.plant_part, harvest.plant_part - %dt Quantity : - %dd= display_quantity(harvest) - %dt Harvest date : - %dd= harvest.harvested_at - %dt Notes: - %dd= display_harvest_description(harvest) - - if harvest.planting.present? - %dt Harvested from - %dd= link_to(harvest.planting, planting_path(harvest.planting)) - .row - .col-md-12 - = render 'harvests/actions', harvest: harvest +.card + = link_to harvest do + = image_tag harvest.default_photo.fullsize_url, alt: "Card image cap", class: 'img-fluid card-img-top' + .card-body.text-center + %h4.card-title + %strong= link_to "#{harvest.crop} #{harvest.plant_part}", harvest diff --git a/app/views/harvests/_harvest.haml b/app/views/harvests/_harvest.haml new file mode 100644 index 000000000..7341875cf --- /dev/null +++ b/app/views/harvests/_harvest.haml @@ -0,0 +1,6 @@ +- if local_assigns[:full] + - cache harvest do + = render 'harvests/card', harvest: harvest +- else + - cache harvest do + = render 'harvests/thumbnail', harvest: harvest \ No newline at end of file diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml index f971cf6b4..09c77f139 100644 --- a/app/views/home/_crops.html.haml +++ b/app/views/home/_crops.html.haml @@ -1,9 +1,4 @@ -- cache cache_key_for(Crop, 'interesting'), expires_in: 1.day do - %h2.section-heading.h1.pt-4= t('.our_crops') - .row - - Crop.interesting.includes(:scientific_names, :photos).shuffle.first(36).each do |c| - .col-lg-2.col-md-4.col-sm-3.col-xs-6 - = render 'crops/thumbnail', crop: c +- cache cache_key_for(Crop, 'homepage'), expires_in: 1.day do + - Crop.interesting.includes(:scientific_names, :photos).shuffle.first(18).each do |c| + = render 'crops/thumbnail', crop: c - .align-bottom - %p.text-right= link_to "#{t('home.crops.view_all')} »", crops_path, class: 'btn' \ No newline at end of file diff --git a/app/views/home/_harvests.html.haml b/app/views/home/_harvests.html.haml deleted file mode 100644 index 8374bcea7..000000000 --- a/app/views/home/_harvests.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -- cache cache_key_for(Harvest) do - %h2.section-heading.h1.pt-4 Recently Harvested - = render 'harvests/list', harvests: Harvest.includes(:crop, :owner, :photos).has_photos.recent.first(3) diff --git a/app/views/home/_members.html.haml b/app/views/home/_members.html.haml index f3aef80ca..68ded323f 100644 --- a/app/views/home/_members.html.haml +++ b/app/views/home/_members.html.haml @@ -5,8 +5,7 @@ - if members.present? %h2.section-heading.h1.pt-4= t('.title') .row.member-cards - - members.each do |m| - .col-md-3.col.sm-2= render "members/thumbnail", member: m + = render members %p.text-right = link_to "#{t('.view_all')} »", members_path, class: 'btn' diff --git a/app/views/home/_plantings.html.haml b/app/views/home/_plantings.html.haml deleted file mode 100644 index d4d7b8faa..000000000 --- a/app/views/home/_plantings.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -- cache cache_key_for(Planting, 'home'), expires_in: 1.day do - %h2.section-heading.h2.pt-4= t('.recently_planted') - = render 'plantings/list', plantings: Planting.includes(:crop, garden: :owner).has_photos.recent.limit(3) diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml index 299f60100..8efd1d666 100644 --- a/app/views/home/_seeds.html.haml +++ b/app/views/home/_seeds.html.haml @@ -1,5 +1,5 @@ - cache cache_key_for(Seed) do - seeds = Seed.current.tradable.includes(:owner, :crop).order(created_at: :desc).limit(6) - if seeds.size.positive? - %h2.section-heading.h1.pt-4.text-center= t('.title') + %h2= t('.title') = render 'seeds/list', seeds: seeds diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index c30d62489..55b3ea549 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1,32 +1,37 @@ -.homepage - .row - .col-md-12 - - if member_signed_in? - - content_for :title, t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) +- if member_signed_in? + - content_for :title, t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) - = render 'stats' - - else - .hidden-xs - .jumbotron= render 'blurb' - -# .visible-xs= render 'blurb' + = render 'stats' +- else + .hidden-xs + .jumbotron= render 'blurb' - .row - .col-lg-8.col-md-6.col-sm-12.well - = render 'crops' - .col-lg-2.col-md-3.col-sm-6 - = render 'plantings' - .col-lg-2.col-md-3.col-sm-6 - = render 'harvests' - .col-md-12 - - cache cache_key_for(Crop, 'recent') do - %p{ style: 'margin-top: 11.25px' } - %strong - #{t('.recently_added')}: - != Crop.recent.limit(30).map { |c| link_to(c, c) }.join(", ") +.row + .col-md-8 + %h2= t('.our_crops') + .row.homepage-thumbnails= render 'crops' + .align-bottom + %p.text-right= link_to "#{t('home.crops.view_all')} »", crops_path, class: 'btn' + - cache cache_key_for(Crop, 'recent') do + %h3= t('.recently_added') + != Crop.recent.limit(30).map { |c| link_to(c, c) }.join(", ") - .row - .col-lg-8.col-md-6.col-sm-12 - = render 'seeds' - .col-lg-4.col-md-6.col-sm-12 - = render 'discuss' - = render 'members' + %h2= t('.seeds_available_to_trade') + .row.homepage-cards + = render Seed.current.tradable.recent.includes(:owner, :crop).limit(12), full: true + .align-bottom + %p.text-right= link_to "#{t('home.seeds.view_all')} »", seeds_path, class: 'btn' + + .col-md-2 + %h2= t('.recently_planted') + .row.homepage-thumbnails + = render Planting.has_photos.recent.includes(:crop, garden: :owner).limit(3), full: true + + .col-md-2 + %h2= t('.recently_harvested') + .row.homepage-thumbnails + = render Harvest.has_photos.recent.includes(:crop, :owner, :photos).limit(3), full: true + + +.row= render 'discuss' +.row= render 'members' diff --git a/app/views/members/_member.haml b/app/views/members/_member.haml new file mode 100644 index 000000000..ca7f08078 --- /dev/null +++ b/app/views/members/_member.haml @@ -0,0 +1,20 @@ +- cache member do + .card.text-center + .avatar.mx-auto + = link_to member do + = image_tag(avatar_uri(member, 150), class: 'rounded-circle img-fluid', alt: member) + .card-body + / Name + %h4.card-title + = link_to member, member + %hr/ + %p + %small + Joined + = distance_of_time_in_words(member.created_at, Time.zone.now) + ago. + %p + %ul.nav.md-pills.nav-justified.pills-pink.small + %li.nav-item= link_to localize_plural(member.plantings, Planting), member_plantings_path(member) + %li.nav-item= link_to localize_plural(member.harvests, Harvest), member_harvests_path(member) + %li.nav-item= link_to localize_plural(member.seeds, Seed), member_seeds_path(member) diff --git a/app/views/members/index.html.haml b/app/views/members/index.html.haml index a320a4882..fcf0611ce 100644 --- a/app/views/members/index.html.haml +++ b/app/views/members/index.html.haml @@ -13,9 +13,7 @@ = page_entries_info @members = will_paginate @members -.member-cards - - @members.each do |m| - = render partial: "members/thumbnail", locals: { member: m } +.member-cards= render @members .pagination = page_entries_info @members diff --git a/app/views/plantings/_card.html.haml b/app/views/plantings/_card.html.haml index 09ba70be9..db3475689 100644 --- a/app/views/plantings/_card.html.haml +++ b/app/views/plantings/_card.html.haml @@ -1,47 +1,6 @@ .card - .panel.panel-success.planting-thumbnail - .panel-heading - %h3.panel-title - = link_to planting.crop.name, planting_path(planting) - - if can? :edit, planting - %a.pull-right{ href: edit_planting_path(planting), role: "button", id: "edit_garden_glyphicon" } - %span.glyphicon.glyphicon-pencil{ title: "Edit" } - .panel-body - .row - .col-xs-12.col-md-4 - = link_to image_tag(planting_image_path(planting), - alt: planting.crop_id, class: 'img img-responsive'), - planting - .col-xs-12.col-md-8 - %dl.dl-horizontal.planting-attributes - %dt Owner: - %dd= link_to planting.owner.login_name, planting.owner - %dt Garden: - %dd= link_to planting.garden&.name, planting.garden - %dt Planted on: - %dd= planting.planted_at - - if planting.quantity - %dt Quantity: - %dd= display_planting_quantity(planting) - - if planting.finished? - %dt Finished on: - %dd= display_finished(planting) - - - unless planting.sunniness.blank? - %dt Sun/shade?: - %dd - - sunniness = planting.sunniness.blank? ? "not specified" : planting.sunniness - = image_tag("sunniness_#{sunniness}.png", size: "25x25", alt: sunniness, title: sunniness) - = " (#{sunniness})" - - - unless planting.planted_from.blank? - %dt Planted from: - %dd= display_planted_from(planting) - - %dt Finish expected: - %dd= planting.finish_predicted_at if planting.finish_predicted_at.present? - %p= render 'plantings/progress', planting: planting, show_explanation: true - .row - .col-md-12 - = render 'plantings/actions', planting: planting - + = link_to planting do + = image_tag planting.default_photo.fullsize_url, class: 'card-img-top img-fluid', alt: "Card image cap" + .card-body.card-body-cascade.text-center + %h4.card-title + %strong= link_to planting, planting diff --git a/app/views/plantings/_thumbnail.html.haml b/app/views/plantings/_thumbnail.html.haml index 976503c28..2a13db107 100644 --- a/app/views/plantings/_thumbnail.html.haml +++ b/app/views/plantings/_thumbnail.html.haml @@ -1,12 +1,12 @@ -.planting.col-md-2 - .planting-thumbnail - = render 'plantings/quick_actions', planting: planting - = render 'plantings/badges', planting: planting - .planting-thumbnail-image - = link_to planting do - = image_tag(planting_image_path(planting), - class: 'img-responsive planting-thumbnail-photo', - alt: planting) - - = render 'plantings/progress', planting: planting, show_explanation: false - .planting-name= link_to planting.crop.name, planting +.planting + .thumbnail + .planting-thumbnail + /= render 'plantings/quick_actions', planting: planting + /= render 'plantings/badges', planting: planting + .planting-thumbnail-image + = link_to image_tag(planting_image_path(planting), + alt: planting.crop, class: 'img'), + planting + .plantinginfo + .planting-name + = link_to planting, planting diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index 8cb70f64f..4d07f4598 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -1,32 +1,47 @@ -.panel.panel-success - .panel-heading - %h3.panel-title +-# .panel.panel-success +-# .panel-heading +-# %h3.panel-title +-# = link_to seed, seed +-# - if can? :edit, seed +-# %a.pull-right{ href: edit_seed_path(seed), role: "button", id: "edit_seed_glyphicon" } +-# %span.glyphicon.glyphicon-pencil{ title: "Edit" } +-# .panel-body +-# .row +-# .col-md-4 +-# = link_to image_tag(seed_image_path(seed), +-# alt: seed.crop.name, class: 'img'), +-# seed.crop +-# .col-md-8 +-# %dl.dl-horizontal +-# %dt Crop : +-# %dd= link_to seed.crop.name, seed.crop +-# - if seed.parent_planting.present? +-# %dt Saved from +-# %dd= link_to seed.parent_planting, planting_path(seed.parent_planting) +-# %dt Plant before : +-# %dd= seed.plant_before +-# %dt Quantity : +-# %dd= seed.quantity +-# %dt Will trade to : +-# %dd= seed.tradable_to +-# %dt From location : +-# %dd= seed.owner.location +-# %dt Owner : +-# %dd= link_to seed.owner.login_name, seed.owner +-# .col-md-12 +-# %p= render 'seeds/actions', seed: seed + + +.card + .view.overlay + = link_to seed do + = image_tag(seed_image_path(seed, full_size: true), alt: seed, class: 'card-img-top img-responsive') + .card-body.p-3 + %h5.card-title.font-weight-bold.fuchsia-rose-text.mb-0 = link_to seed, seed - - if can? :edit, seed - %a.pull-right{ href: edit_seed_path(seed), role: "button", id: "edit_seed_glyphicon" } - %span.glyphicon.glyphicon-pencil{ title: "Edit" } - .panel-body - .row - .col-md-4 - = link_to image_tag(seed_image_path(seed), - alt: seed.crop.name, class: 'img'), - seed.crop - .col-md-8 - %dl.dl-horizontal - %dt Crop : - %dd= link_to seed.crop.name, seed.crop - - if seed.parent_planting.present? - %dt Saved from - %dd= link_to seed.parent_planting, planting_path(seed.parent_planting) - %dt Plant before : - %dd= seed.plant_before - %dt Quantity : - %dd= seed.quantity - %dt Will trade to : - %dd= seed.tradable_to - %dt From location : - %dd= seed.owner.location - %dt Owner : - %dd= link_to seed.owner.login_name, seed.owner - .col-md-12 - %p= render 'seeds/actions', seed: seed + %p + %i #{seed.owner.location} + %p Will trade #{seed.tradable_to} + %p.float-right + = link_to seed.owner do + = image_tag(avatar_uri(seed.owner, 50), alt: '', class: 'img img-responsive avatar rounded') \ No newline at end of file diff --git a/app/views/seeds/_seed.haml b/app/views/seeds/_seed.haml new file mode 100644 index 000000000..af5f6203f --- /dev/null +++ b/app/views/seeds/_seed.haml @@ -0,0 +1,6 @@ +- if local_assigns[:full] + - cache seed do + = render 'seeds/card', seed: seed +- else + - cache seed do + = render 'seeds/thumbnail', seed: seed \ No newline at end of file From bff809f482f2b6116aeccf3a198528787bcc84a0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 25 Apr 2019 23:33:49 +1200 Subject: [PATCH 013/549] Removed extra graphs on crops#show --- app/views/crops/show.html.haml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 457d0afcd..fc19f0e96 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -55,17 +55,6 @@ %p= render 'crops/photos', photos: @photos %p= link_to 'more photos', crop_photos_path(@crop) - .row - .col-md-3 - %h3 Sunniness - = pie_chart crop_sunniness_path(@crop, format: :json), legend: "bottom" - .col-md-3 - %h3 Planted from - = pie_chart crop_planted_from_path(@crop, format: :json), legend: "bottom" - .col-md-3 - %h3 Harvested for - = pie_chart crop_harvested_for_path(@crop, format: :json), legend: "bottom" - .varieties= render 'varieties', crop: @crop %h3 Crop Map From 3316514a7aabeba03bde77686bdc360e62cae1af Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 25 Apr 2019 23:41:34 +1200 Subject: [PATCH 014/549] More material bits --- app/assets/stylesheets/plantings.sass | 1 + app/views/crops/_predictions.html.haml | 5 ++--- app/views/crops/_thumbnail.html.haml | 2 +- app/views/plantings/_thumbnail.html.haml | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/plantings.sass b/app/assets/stylesheets/plantings.sass index 96473b6b3..a1709b17d 100644 --- a/app/assets/stylesheets/plantings.sass +++ b/app/assets/stylesheets/plantings.sass @@ -1,4 +1,5 @@ .planting + padding: 0.5em .planting-badges font-size: 100% position: absolute diff --git a/app/views/crops/_predictions.html.haml b/app/views/crops/_predictions.html.haml index 63d344820..60ec32f18 100644 --- a/app/views/crops/_predictions.html.haml +++ b/app/views/crops/_predictions.html.haml @@ -11,17 +11,16 @@ Perennial - elsif crop.perennial == false Annual - + .d-flex.justify-content-between %p.display-1 %i.far.fa-calendar - - if crop.perennial == true %small living more than two years - elsif crop.perennial == false %small living and reproducing in a single year or less - + - if crop.annual? && crop.median_lifespan.present? .col-md-3.col-xs-5 .card diff --git a/app/views/crops/_thumbnail.html.haml b/app/views/crops/_thumbnail.html.haml index 9d87101d2..2f50c8e91 100644 --- a/app/views/crops/_thumbnail.html.haml +++ b/app/views/crops/_thumbnail.html.haml @@ -1,5 +1,5 @@ - cache cache_key_for(Crop, crop.id) do - .thumbnail + .card.thumbnail .crop-thumbnail = link_to image_tag(crop_image_path(crop), alt: crop.name, class: 'img'), diff --git a/app/views/plantings/_thumbnail.html.haml b/app/views/plantings/_thumbnail.html.haml index 2a13db107..b6bcad461 100644 --- a/app/views/plantings/_thumbnail.html.haml +++ b/app/views/plantings/_thumbnail.html.haml @@ -1,8 +1,8 @@ .planting - .thumbnail + .card.thumbnail .planting-thumbnail /= render 'plantings/quick_actions', planting: planting - /= render 'plantings/badges', planting: planting + = render 'plantings/badges', planting: planting .planting-thumbnail-image = link_to image_tag(planting_image_path(planting), alt: planting.crop, class: 'img'), From d5d9c805ad0c94f710fd342913005d4ef3f9855e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 25 Apr 2019 23:51:53 +1200 Subject: [PATCH 015/549] Shadows on the homepage --- app/views/home/_members.html.haml | 13 ++++++------- app/views/home/index.html.haml | 13 ++++++++----- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/views/home/_members.html.haml b/app/views/home/_members.html.haml index 68ded323f..fec54fbb8 100644 --- a/app/views/home/_members.html.haml +++ b/app/views/home/_members.html.haml @@ -1,11 +1,10 @@ - cache cache_key_for(Member) do - .hidden-xs - %section.section.pb-3.text-center - - members = Member.includes(plantings: :crop).interesting.first(6) - - if members.present? - %h2.section-heading.h1.pt-4= t('.title') - .row.member-cards - = render members + .hidden-xs.well + - members = Member.includes(plantings: :crop).interesting.first(6) + - if members.present? + %h2= t('.title') + .member-cards + = render members %p.text-right = link_to "#{t('.view_all')} »", members_path, class: 'btn' diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 55b3ea549..9e3c6b01a 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -6,15 +6,17 @@ .hidden-xs .jumbotron= render 'blurb' -.row +.row.shadow .col-md-8 %h2= t('.our_crops') .row.homepage-thumbnails= render 'crops' .align-bottom %p.text-right= link_to "#{t('home.crops.view_all')} »", crops_path, class: 'btn' - cache cache_key_for(Crop, 'recent') do - %h3= t('.recently_added') - != Crop.recent.limit(30).map { |c| link_to(c, c) }.join(", ") + .well + %h3= t('.recently_added') + != Crop.recent.limit(30).map { |c| link_to(c, c) }.join(", ") + %h2= t('.seeds_available_to_trade') .row.homepage-cards @@ -33,5 +35,6 @@ = render Harvest.has_photos.recent.includes(:crop, :owner, :photos).limit(3), full: true -.row= render 'discuss' -.row= render 'members' +/.row= render 'discuss' +.row + .col-md-12.text-center= render 'members' From cf3477e33313660b05071cb31d067d49680efed8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 00:01:38 +1200 Subject: [PATCH 016/549] Use full size image --- app/helpers/photos_helper.rb | 7 ++++--- app/views/harvests/_card.html.haml | 2 +- app/views/plantings/_card.html.haml | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb index 345d6eea1..ccd8d99a0 100644 --- a/app/helpers/photos_helper.rb +++ b/app/helpers/photos_helper.rb @@ -24,11 +24,12 @@ module PhotosHelper end end - def harvest_image_path(harvest) + def harvest_image_path(harvest, full_size: false) if harvest.photos.present? - harvest.photos.order(date_taken: :desc).first.thumbnail_url + photo = harvest.photos.order(date_taken: :desc).first + full_size ? photo.fullsize_url : photo.thumbnail_url elsif harvest.planting.present? - planting_image_path(harvest.planting) + planting_image_path(harvest.planting, full_size: full_size) else placeholder_image end diff --git a/app/views/harvests/_card.html.haml b/app/views/harvests/_card.html.haml index 6c926b9bf..0eef9d9a1 100644 --- a/app/views/harvests/_card.html.haml +++ b/app/views/harvests/_card.html.haml @@ -1,6 +1,6 @@ .card = link_to harvest do - = image_tag harvest.default_photo.fullsize_url, alt: "Card image cap", class: 'img-fluid card-img-top' + = image_tag harvest_image_path(harvest, full_size: true), alt: harvest, class: 'img-fluid card-img-top' .card-body.text-center %h4.card-title %strong= link_to "#{harvest.crop} #{harvest.plant_part}", harvest diff --git a/app/views/plantings/_card.html.haml b/app/views/plantings/_card.html.haml index db3475689..0241aae44 100644 --- a/app/views/plantings/_card.html.haml +++ b/app/views/plantings/_card.html.haml @@ -1,6 +1,6 @@ .card = link_to planting do - = image_tag planting.default_photo.fullsize_url, class: 'card-img-top img-fluid', alt: "Card image cap" + = image_tag planting_image_path(planting, full_size: true), class: 'card-img-top img-fluid', alt: planting .card-body.card-body-cascade.text-center %h4.card-title %strong= link_to planting, planting From b9ae3a4ab4b7a7b82e6eaee1bf1820a037750e1a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 00:01:54 +1200 Subject: [PATCH 017/549] Add harvests to the homepage in percy specs --- spec/features/percy/percy_spec.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 482066d5a..381a84656 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -21,7 +21,11 @@ describe 'Test with visual testing', type: :feature, js: true do crop = FactoryBot.create crop_type, creator: someone_else owner = FactoryBot.create :member, login_name: crop_type.to_s.reverse, email: "#{crop.name}@example.com" planting = FactoryBot.create :planting, crop: crop, owner: owner, garden: owner.gardens.first - planting.photos << FactoryBot.create(:photo, owner: owner, thumbnail_url: photo_url) + photo = FactoryBot.create(:photo, owner: owner, thumbnail_url: photo_url) + planting.photos << photo + + harvest = FactoryBot.create :harvest, crop: crop, owner: owner + harvest.photos << photo end # Freeze time, so we don't have variations in timestamps on the page From 71cf334e03a3a9fad6db4328a38263b1071b04a7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 00:18:04 +1200 Subject: [PATCH 018/549] Add back the link to crop seeds --- app/views/crops/show.html.haml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index fc19f0e96..56474e34e 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -76,6 +76,11 @@ = link_to crop_harvests_path(@crop) do View all #{@crop.name} harvests (#{@crop.harvests.size}) + %p + = link_to crop_seeds_path(@crop) do + View all #{@crop.name} seeds + (#{@crop.seeds.size}) + - if member_signed_in? %p = link_to member_seeds_path(current_member, crop_slug: @crop.slug) do From 088dd29fac781ca09b1123a5d467db81b8065d1a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 16:26:22 +1200 Subject: [PATCH 019/549] Add an avatar to all members --- spec/factories/member.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/factories/member.rb b/spec/factories/member.rb index b59712e39..5d6abd712 100644 --- a/spec/factories/member.rb +++ b/spec/factories/member.rb @@ -7,7 +7,7 @@ FactoryBot.define do confirmed_at { Time.zone.now } show_email { false } bio { 'I love seeds' } - preferred_avatar_uri { 'http://example.com/me.jpg' } + preferred_avatar_uri { 'http://www.gravatar.com/avatar/d021434aac03a7f7c7c0de60d07dad1c?size=150&default=identicon' } # cropbot is needed for certain tests, eg. Crop.create_from_csv factory :cropbot do From 662160306db673f520228d01f433533b70d4ae3b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 16:34:00 +1200 Subject: [PATCH 020/549] add #new to percy tests --- spec/features/percy/percy_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 381a84656..17934fc2e 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -142,5 +142,25 @@ describe 'Test with visual testing', type: :feature, js: true do visit garden_path(garden) Percy.snapshot(page, name: "#{prefix}/self/gardens#show") end + + it 'loads plantings#new' do + visit new_planting_path + Percy.snapshot(page, name: "#{prefix}/plantings#new") + end + + it 'loads gardens#new' do + visit new_garden_path + Percy.snapshot(page, name: "#{prefix}/gardens#new") + end + + it 'loads harvests#new' do + visit new_harvest_path + Percy.snapshot(page, name: "#{prefix}/harvests#new") + end + + it 'loads posts#new' do + visit new_post_path + Percy.snapshot(page, name: "#{prefix}/posts#new") + end end end From de3aeaf823090444e75234e048dc089880159613 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 16:34:04 +1200 Subject: [PATCH 021/549] add base branch to percy --- script/percy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/percy.sh b/script/percy.sh index 269596889..33c43ce7b 100755 --- a/script/percy.sh +++ b/script/percy.sh @@ -1,2 +1,2 @@ #!/bin/bash -npx percy exec -- bundle exec rspec spec/features/percy/ +PERCY_TARGET_BRANCH=dev npx percy exec -- bundle exec rspec spec/features/percy/ From b82c3b5b76422b5c5b650c81dc90e512ebd354ec Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 17:34:55 +1200 Subject: [PATCH 022/549] Tidy up seeds --- app/assets/stylesheets/application.sass | 1 + app/assets/stylesheets/seeds.sass | 7 +++++++ app/views/seeds/index.html.haml | 7 ++----- 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 app/assets/stylesheets/seeds.sass diff --git a/app/assets/stylesheets/application.sass b/app/assets/stylesheets/application.sass index 4ed20fc4b..31588fd99 100644 --- a/app/assets/stylesheets/application.sass +++ b/app/assets/stylesheets/application.sass @@ -13,6 +13,7 @@ @import 'plantings' @import 'members' @import 'harvests' +@import 'seeds' @import 'homepage' @import 'photos' diff --git a/app/assets/stylesheets/seeds.sass b/app/assets/stylesheets/seeds.sass new file mode 100644 index 000000000..987324aac --- /dev/null +++ b/app/assets/stylesheets/seeds.sass @@ -0,0 +1,7 @@ +.seed-cards + display: flex + flex: none + flex-wrap: wrap + .card + max-width: 200px + margin: 1em \ No newline at end of file diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index 9f81e4a98..ccd544c6c 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -13,11 +13,8 @@ = page_entries_info @seeds = will_paginate @seeds -.card-row - - unless @seeds.empty? - - @seeds.each do |seed| - .seedcard - = render 'seeds/card', seed: seed +- unless @seeds.empty? + .seed-cards= render @seeds, full: true .pagination = page_entries_info @seeds From 4196ce9e6b29225dbf0961656c1dd21fc01d1627 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 17:35:22 +1200 Subject: [PATCH 023/549] Fix search --- app/helpers/icons_helper.rb | 4 ++ app/views/crops/_search_bar.haml | 8 ++- app/views/layouts/_header.html.haml | 62 +++++++++------------- app/views/layouts/application.html.haml | 6 ++- app/views/shared/_global_actions.html.haml | 22 ++++---- 5 files changed, 47 insertions(+), 55 deletions(-) diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index c124d6a7e..bf841c0e5 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -9,6 +9,10 @@ module IconsHelper icon('fas', 'seedling') end + def member_icon + icon('fas', 'user') + end + def harvest_icon icon('fas', 'carrot') end diff --git a/app/views/crops/_search_bar.haml b/app/views/crops/_search_bar.haml index 0d9b3d94d..4c25ea530 100644 --- a/app/views/crops/_search_bar.haml +++ b/app/views/crops/_search_bar.haml @@ -1,10 +1,8 @@ -= form_tag 'search' do - -# , method: :get, id: 'navbar-search' do += form_tag search_crops_path, method: :get, class: 'navbar-form navbar-left', id: 'navbar-search' do = label_tag :term, "Search crop database:", class: 'sr-only' - .input + .input.text-white .input-group - = text_field_tag 'term', nil, class: 'search-query input-medium form-control', placeholder: 'Search crops' + = text_field_tag 'term', nil, class: 'search-query input-medium form-control', placeholder: t('.search_crops') .input-group-btn %button.btn.btn-default{ style: "height: 34px;" } - = submit_tag "Search", class: 'btn sr-only' %span.glyphicon.glyphicon-search diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 5da0bfd24..d81b1d80a 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -1,12 +1,9 @@ -.sr-only - = link_to t(".skip"), "#skipnav" + .navbar.navbar-default.navbar-fixed-top{ role: "navigation" } .container-fluid .navbar-header %button.navbar-toggle{"data-target" => ".navbar-responsive-collapse", "data-toggle" => "collapse", type: "button"} - %span.icon-bar - %span.icon-bar - %span.icon-bar + %span.glyphicon.glyphicon-menu-hamburger.text-white %a.navbar-brand.hidden-xs{ href: root_path } = image_tag("growstuff-brand.png", size: "200x50", alt: ENV['GROWSTUFF_SITE_NAME']) %a.navbar-brand.visible-xs{ href: root_path } @@ -16,32 +13,8 @@ alt: ENV['GROWSTUFF_SITE_NAME']) .navbar-collapse.collapse.navbar-responsive-collapse - -# %ul.nav.navbar-nav - -# %li.active - -# %a{href: "javascript:void(0)"} Active - -# %li - -# %a{href: "javascript:void(0)"} Link - -# %li.dropdown - -# %a.dropdown-toggle{"data-target" => "#", "data-toggle" => "dropdown", href: "http://fezvrasta.github.io/bootstrap-material-design/bootstrap-elements.html"} - -# Dropdown - -# %b.caret - -# %ul.dropdown-menu - -# %li - -# %a{href: "javascript:void(0)"} Action - -# %li - -# %a{href: "javascript:void(0)"} Another action - -# %li - -# %a{href: "javascript:void(0)"} Something else here - -# %li.divider - -# %li.dropdown-header Dropdown header - -# %li - -# %a{href: "javascript:void(0)"} Separated link - -# %li - -# %a{href: "javascript:void(0)"} One more separated link - %form.navbar-form.navbar-left - = render 'crops/search_bar' - -# .form-group - -# %input.form-control.col-sm-8{placeholder: "Search", type: "text"}/ + = render 'crops/search_bar' + %ul.nav.navbar-nav.navbar-right %li.dropdown< %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path }= t('.crops') @@ -66,11 +39,26 @@ - else = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) %ul.dropdown-menu - %li= link_to t('.profile'), member_path(current_member) - %li= link_to t('.gardens'), member_gardens_path(current_member) - %li= link_to t('.plantings'), member_plantings_path(current_member) - %li= link_to t('.harvest'), member_harvests_path(current_member) - %li= link_to t('.seeds'), member_seeds_path(current_member) + %li + = link_to member_path(current_member) do + = member_icon + = t('.profile') + %li + = link_to member_gardens_path(current_member) do + = garden_icon + = t('.gardens') + %li + = link_to member_plantings_path(current_member) do + = planting_icon + = t('.plantings') + %li + = link_to member_harvests_path(current_member) do + = harvest_icon + = t('.harvest') + %li + = link_to member_seeds_path(current_member) do + = seed_icon + = t('.seeds') %li= link_to t('.posts'), member_posts_path(current_member) %li - if current_member.notifications.unread_count.positive? @@ -91,5 +79,3 @@ %li= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' %li= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' --# anchor tag for accessibility link to skip the navigation menu -%a{ name: 'skipnav' } \ No newline at end of file diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 13a0c95ed..3e8130fe0 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -3,10 +3,12 @@ = yield :scripts = render partial: "layouts/meta" %body + .sr-only= link_to t(".skip"), "#skipnav" = render partial: "layouts/header" - + = render 'shared/global_actions' + -# anchor tag for accessibility link to skip the navigation menu + %a{ name: 'skipnav' } #maincontainer - .row= render 'shared/global_actions' .row .col-md-6 diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 383d75aba..9299a5b1c 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,24 +1,26 @@ - if signed_in? - .global-actions.pull-right - .btn-group - = link_to member_gardens_path(current_member), class: 'btn btn-xs' do + %ul.nav.nav-tabs.pull-right + %li.nav-item + = link_to member_gardens_path(current_member), class: 'nav-link' do = garden_icon = t('links.my_gardens') - .btn-group - = link_to new_planting_path, class: 'btn btn-xs' do + %li.nav-item + = link_to new_planting_path, class: 'nav-link' do = planting_icon = t('plantings.plant') - = link_to new_harvest_path, class: 'btn btn-xs' do + %li.nav-item + = link_to new_harvest_path, class: 'nav-link' do = harvest_icon = t('harvests.harvest') - = link_to new_seed_path, class: 'btn btn-xs' do + %li.nav-item + = link_to new_seed_path, class: 'nav-link' do = seed_icon = t('buttons.save_seeds') - .btn-group - = link_to new_post_path, class: 'btn btn-xs' do + %li.nav-item + = link_to new_post_path, class: 'nav-link' do = blog_icon - = t 'posts.write_blog' + = t 'posts.write_blog' \ No newline at end of file From 6d8a9c3579cb573f357108e4498527edb6b0d3f3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 17:54:52 +1200 Subject: [PATCH 024/549] Move global actions --- app/assets/stylesheets/overrides.sass | 5 ++++- app/views/shared/_global_actions.html.haml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/overrides.sass b/app/assets/stylesheets/overrides.sass index e7e72a2b9..07bc04e2b 100644 --- a/app/assets/stylesheets/overrides.sass +++ b/app/assets/stylesheets/overrides.sass @@ -78,7 +78,7 @@ h3 p - + // signup widget on homepage .jumbotron .signup @@ -258,6 +258,9 @@ footer min-height: 80% padding: 50px +#global-actions + padding-top: 10px + html, body height: 100% diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 9299a5b1c..cf7bf1b81 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,5 +1,5 @@ - if signed_in? - %ul.nav.nav-tabs.pull-right + %ul.nav.nav-tabs.pull-right#global-actions %li.nav-item = link_to member_gardens_path(current_member), class: 'nav-link' do = garden_icon From 0871620c556cab138c53f7b16b8b67700bdc39e7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 21:27:35 +1200 Subject: [PATCH 025/549] Tidy up finding seeds from crops#show --- app/views/crops/_find_seeds.html.haml | 46 +++++++++++++++------------ 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/app/views/crops/_find_seeds.html.haml b/app/views/crops/_find_seeds.html.haml index 81b5d0abf..d05bf40c4 100644 --- a/app/views/crops/_find_seeds.html.haml +++ b/app/views/crops/_find_seeds.html.haml @@ -1,22 +1,28 @@ -%h4 Find #{crop.name} seeds -- if crop.seeds.empty? - %p - There are no seeds available to trade on Growstuff right now. -- else - %ul - - crop.seeds.tradable.each do |seed| - %li - = link_to "#{seed.owner} will trade #{seed.tradable_to}.", seed_path(seed) - = render partial: 'members/location', locals: { member: seed.owner } - %p - = link_to "View all #{crop.name} seeds", crop_seeds_path(crop) -%p - = link_to "Purchase seeds via Ebay", +.card + .card-body + %h4 Find #{crop.name} seeds + - if crop.seeds.empty? + %p + There are no seeds available to trade on Growstuff right now. + - else + %ul + - crop.seeds.tradable.each do |seed| + %li + = link_to "#{seed.owner} will trade #{seed.tradable_to}.", seed_path(seed) + = render partial: 'members/location', locals: { member: seed.owner } + %p + = link_to "View all #{crop.name} seeds", crop_seeds_path(crop) + .card-actions.flex-column + = link_to "Purchase seeds via Ebay", crop_ebay_seeds_url(crop), target: "_blank", - rel: "noopener noreferrer" -- if crop.approved? - - if current_member - %p= link_to "List #{crop.name} seeds to trade", new_seed_path(crop_id: crop.id) - - else - = render partial: 'shared/signin_signup', locals: { to: 'list your seeds to trade' } + rel: "noopener noreferrer", + class: 'btn btn-outline-primary' + + - if crop.approved? + - if current_member + = link_to "List #{crop.name} seeds to trade", + new_seed_path(crop_id: crop.id), + class: 'btn btn-outline-primary' + - else + = render partial: 'shared/signin_signup', locals: { to: 'list your seeds to trade' } From 7c51d94dc0ef61cad77794ab578377c4a05d4de4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 21:27:46 +1200 Subject: [PATCH 026/549] More crops#show tidy up --- app/views/crops/show.html.haml | 84 +++++++++++++++++----------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 56474e34e..2ff6c8886 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -30,16 +30,14 @@ = render 'predictions', crop: @crop %hr/ + .well= render 'crops/photos', photos: @photos - = render 'crops/photos', photos: @photos - %hr/ - - .row.text-center + .card-deck.text-center .col-md-4 .card .card-body %h3.section-heading.h3.pt-4 Sunniness - = pie_chart crop_sunniness_path(@crop, format: :json), legend: "bottom" + = pie_chart crop_sunniness_path(@crop, format: :json), legend: "bottom" .col-md-4 .card .card-body @@ -51,23 +49,20 @@ %h3.section-heading.h3.pt-4 Harvested for = pie_chart crop_harvested_for_path(@crop, format: :json), legend: "bottom" - %h2 Photos - %p= render 'crops/photos', photos: @photos - %p= link_to 'more photos', crop_photos_path(@crop) - .varieties= render 'varieties', crop: @crop - %h3 Crop Map - %p - Only plantings by members who have set their locations are shown on this map. - - if current_member && current_member.location.blank? - = link_to "Set your location.", edit_member_registration_path - #cropmap + .well + %h3 Crop Map + %p + Only plantings by members who have set their locations are shown on this map. + - if current_member && current_member.location.blank? + = link_to "Set your location.", edit_member_registration_path + #cropmap - = render 'crops/posts', crop: @crop + .well= render 'crops/posts', crop: @crop .col-md-3 - = render partial: 'wrangle', locals: { crop: @crop } + = render 'wrangle', crop: @crop %p = link_to crop_plantings_path(@crop) do View all #{@crop.name} plantings @@ -86,42 +81,47 @@ = link_to member_seeds_path(current_member, crop_slug: @crop.slug) do = display_seed_availability(@current_member, @crop) - %h4 How to grow #{@crop.name.pluralize} + .card + .card-body + %h4 How to grow #{@crop.name.pluralize} + = render 'grown_for', crop: @crop + = render 'planting_advice', crop: @crop - = render 'grown_for', crop: @crop - = render 'planting_advice', crop: @crop - - = render 'scientific_names', crop: @crop - = render 'alternate_names', crop: @crop + .well + = render 'scientific_names', crop: @crop + = render 'alternate_names', crop: @crop - if @crop.parent - .parent-crop + .parent-crop = @crop.name is a variety of + %span.chip + %img.chip-img{alt: "Chip Image", src: "/material/apple-touch-icon.png"}>/ + Chip Label + = succeed "." do = link_to @crop.parent, @crop.parent = render 'crops/thumbnail', crop: @crop.parent - = render 'plantings', crop: @crop - = render 'harvests', crop: @crop + = render 'find_seeds', crop: @crop - - %h4 Learn more about #{@crop.name.pluralize} - %ul - %li= link_to 'Wikipedia (English)', @crop.en_wikipedia_url, target: "_blank", rel: "noopener noreferrer" - %li - = link_to "OpenFarm - Growing guide", "https://openfarm.cc/en/crops/#{CGI.escape @crop.name}", - target: "_blank", - rel: "noopener noreferrer" - %li - = link_to "Gardenate - Planting reminders", "http://www.gardenate.com/plant/#{CGI.escape @crop.name}", - target: "_blank", rel: "noopener noreferrer" - - if current_member && current_member.location + .well + %h4 Learn more about #{@crop.name.pluralize} + %ul + %li= link_to 'Wikipedia (English)', @crop.en_wikipedia_url, target: "_blank", rel: "noopener noreferrer" %li - = link_to "Google", - 'http://www.google.com/search?q=' + CGI.escape(['Growing', - @crop.name, - current_member.location].join(' ')), + = link_to "OpenFarm - Growing guide", "https://openfarm.cc/en/crops/#{CGI.escape @crop.name}", target: "_blank", rel: "noopener noreferrer" + %li + = link_to "Gardenate - Planting reminders", "http://www.gardenate.com/plant/#{CGI.escape @crop.name}", + target: "_blank", rel: "noopener noreferrer" + - if current_member && current_member.location + %li + = link_to "Google", + 'http://www.google.com/search?q=' + CGI.escape(['Growing', + @crop.name, + current_member.location].join(' ')), + target: "_blank", + rel: "noopener noreferrer" From 83668c4890400e914bd737e9440dfc6a9c5adf5a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 21:30:09 +1200 Subject: [PATCH 027/549] Add photos#show to percy --- spec/features/percy/percy_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 17934fc2e..4738a5903 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -89,6 +89,14 @@ describe 'Test with visual testing', type: :feature, js: true do Percy.snapshot(page, name: "#{prefix}/members#show") end end + + describe 'photos' do + it 'loads photos#show' do + photo = FactoryBot.create :photo, owner: member + visit_page photo_url(photo) + Percy.snapshot(page, name: "#{prefix}/photos#show") + end + end end context "when signed out" do From 548e15a8661222ec8f7371f054ab0a3ee9ac4b91 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 21:38:34 +1200 Subject: [PATCH 028/549] Tidy up Photos#show --- app/views/photos/show.html.haml | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index a833e220a..592c89bbe 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -8,7 +8,13 @@ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) .row - .col-md-5 + .col-md-8 + %p.text-center + = image_tag(@photo.fullsize_url, alt: @photo.title, class: 'rounded img-fluid shadow-sm') + .col-md-4 + %p.text-center + = render 'photos/actions', photo: @photo + = link_to "View on Flickr", @photo.link_url, class: 'btn' - if @crops.size.positive? - @crops.each do |crop| = render 'crops/index_card', crop: crop @@ -16,23 +22,13 @@ %i.fas.fa-camera-retro %strong Photo by = link_to @photo.owner, @photo.owner + Taken on #{@photo.date_taken} %p %strong License: - if @photo.license_url = link_to @photo.license_name, @photo.license_url - else - = succeed "." do - = @photo.license_name + = @photo.license_name - if @photo.associations? - = render "photo_associations", locals: { photo: @photo } - = render 'photos/actions', photo: @photo - - - if @crops.size.positive? - - @crops.each do |crop| - = render 'crops/index_card', crop: crop - - .col-md-7 - //%img.img-fluid.z-depth-1{:alt => "1", :src => "https://mdbootstrap.com/img/Photos/Slides/img%20(54).jpg"}/ - %p= image_tag(@photo.fullsize_url, alt: @photo.title, class: 'rounded img-fluid z-depth-1 float-right ') - %p= link_to "View on Flickr", @photo.link_url, class: 'btn' + = render "photo_associations", photo: @photo \ No newline at end of file From f96b2ca6612083db679a47303c6d3779c6c4ba5a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 21:41:30 +1200 Subject: [PATCH 029/549] Tidy columns on crops index card --- app/views/crops/_index_card.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/crops/_index_card.html.haml b/app/views/crops/_index_card.html.haml index 1c94573cf..5d31d7d97 100644 --- a/app/views/crops/_index_card.html.haml +++ b/app/views/crops/_index_card.html.haml @@ -1,11 +1,11 @@ .well .row - .col-md-4 + .col = link_to image_tag(crop_image_path(crop), alt: '', class: 'img crop-image'), crop - .col-md-8 + .col %h3{ style: 'padding-top: 0px; margin-top: 0px' } = link_to crop, crop From 31bcb35fb40cba18c9af37cd8b88b61642090811 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 22:03:20 +1200 Subject: [PATCH 030/549] Don't turn crop images into circles --- app/assets/stylesheets/overrides.sass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/overrides.sass b/app/assets/stylesheets/overrides.sass index 07bc04e2b..312f2257d 100644 --- a/app/assets/stylesheets/overrides.sass +++ b/app/assets/stylesheets/overrides.sass @@ -264,7 +264,7 @@ footer html, body height: 100% -.crop-image, .member-image +.member-image border-radius: 50% // Autosuggest From 2db8dcf7c12bf5a9bba4f096a87ddff1479ba115 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 22:03:30 +1200 Subject: [PATCH 031/549] Pretty rounded images --- app/views/crops/_index_card.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/crops/_index_card.html.haml b/app/views/crops/_index_card.html.haml index 5d31d7d97..4849e37fc 100644 --- a/app/views/crops/_index_card.html.haml +++ b/app/views/crops/_index_card.html.haml @@ -3,7 +3,7 @@ .col = link_to image_tag(crop_image_path(crop), alt: '', - class: 'img crop-image'), + class: 'img crop-image rounded'), crop .col %h3{ style: 'padding-top: 0px; margin-top: 0px' } From 9524899f78bcb72438954b910ae2068b4340d945 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 22:03:49 +1200 Subject: [PATCH 032/549] tidy up harvests #index --- app/views/harvests/_card.html.haml | 10 +++++++++- app/views/harvests/index.html.haml | 9 ++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/views/harvests/_card.html.haml b/app/views/harvests/_card.html.haml index 0eef9d9a1..8f5a513d7 100644 --- a/app/views/harvests/_card.html.haml +++ b/app/views/harvests/_card.html.haml @@ -2,5 +2,13 @@ = link_to harvest do = image_tag harvest_image_path(harvest, full_size: true), alt: harvest, class: 'img-fluid card-img-top' .card-body.text-center - %h4.card-title + %h5.card-title %strong= link_to "#{harvest.crop} #{harvest.plant_part}", harvest + %p.card-text + = link_to harvest.plant_part, harvest.plant_part + + - if harvest.planting.present? + %p.card-text + %small.text-muted + Harvested from + = link_to harvest.planting, harvest.planting \ No newline at end of file diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index 186dd4f30..ca8bc773c 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -12,11 +12,10 @@ .pagination = page_entries_info @harvests = will_paginate @harvests -.row - - unless @harvests.empty? - - @harvests.each do |harvest| - .col-md-6 - = render 'harvests/card', harvest: harvest + +- unless @harvests.empty? + .harvest-cards + = render @harvests, full: true .pagination = page_entries_info @harvests From 83038fc4f339a9d6b680363f5d03283b30643598 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 22:03:56 +1200 Subject: [PATCH 033/549] More rounded photos --- app/views/photos/_gallery.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/photos/_gallery.haml b/app/views/photos/_gallery.haml index 5c9a49e4f..7c8090bce 100644 --- a/app/views/photos/_gallery.haml +++ b/app/views/photos/_gallery.haml @@ -1,5 +1,5 @@ .photos-grid - .photo-grid-item= link_to image_tag(photos.first.fullsize_url), photos.first + .photo-grid-item= link_to image_tag(photos.first.fullsize_url, class: 'rounded mx-auto'), photos.first - photos.offset(1).each do |photo| .photo-grid-item = link_to photo do From f2a840a1de3510054ab25fa2e27723700c02ed55 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 26 Apr 2019 22:09:17 +1200 Subject: [PATCH 034/549] Fix spec --- spec/features/percy/percy_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 4738a5903..6dd714a25 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -93,7 +93,7 @@ describe 'Test with visual testing', type: :feature, js: true do describe 'photos' do it 'loads photos#show' do photo = FactoryBot.create :photo, owner: member - visit_page photo_url(photo) + visit photo_url(photo) Percy.snapshot(page, name: "#{prefix}/photos#show") end end From 25626ea0ecac4b42247421499c42cf8293367c1d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 27 Apr 2019 09:53:59 +1200 Subject: [PATCH 035/549] Added #edit to percy --- spec/features/percy/percy_spec.rb | 65 +++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 6dd714a25..01637e6c1 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -92,7 +92,9 @@ describe 'Test with visual testing', type: :feature, js: true do describe 'photos' do it 'loads photos#show' do - photo = FactoryBot.create :photo, owner: member + photo = FactoryBot.create :photo, owner: member, + fullsize_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_z.jpg', + thumbnail_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_q.jpg' visit photo_url(photo) Percy.snapshot(page, name: "#{prefix}/photos#show") end @@ -123,10 +125,6 @@ describe 'Test with visual testing', type: :feature, js: true do visit new_member_confirmation_path Percy.snapshot(page, name: "new-confimation") end - - it 'loads sign in page' do - visit crops_path # some random page - end end context 'when signed in' do @@ -134,13 +132,13 @@ describe 'Test with visual testing', type: :feature, js: true do before { login_as member } include_examples 'visit pages' - it 'load plantings#show' do + it 'load my plantings#show' do planting = FactoryBot.create :planting, crop: tomato, owner: member, garden: member.gardens.first visit planting_path(planting) Percy.snapshot(page, name: "#{prefix}/self/plantings#show") end - it 'load members#show' do + it 'load my members#show' do visit member_path(member) Percy.snapshot(page, name: "#{prefix}/self/members#show") end @@ -156,19 +154,52 @@ describe 'Test with visual testing', type: :feature, js: true do Percy.snapshot(page, name: "#{prefix}/plantings#new") end - it 'loads gardens#new' do - visit new_garden_path - Percy.snapshot(page, name: "#{prefix}/gardens#new") + describe '#new' do + it 'loads gardens#new' do + visit new_garden_path + Percy.snapshot(page, name: "#{prefix}/gardens#new") + end + + it 'loads harvests#new' do + visit new_harvest_path + Percy.snapshot(page, name: "#{prefix}/harvests#new") + end + + it 'loads plantings#new' do + visit new_planting_path + Percy.snapshot(page, name: "#{prefix}/plantings#new") + end + + it 'loads posts#new' do + visit new_post_path + Percy.snapshot(page, name: "#{prefix}/posts#new") + end end - it 'loads harvests#new' do - visit new_harvest_path - Percy.snapshot(page, name: "#{prefix}/harvests#new") - end + describe '#edit' do + it 'loads gardens#edit' do + garden = FactoryBot.create :garden, owner: member + visit edit_garden_path(garden) + Percy.snapshot(page, name: "#{prefix}/gardens#edit") + end - it 'loads posts#new' do - visit new_post_path - Percy.snapshot(page, name: "#{prefix}/posts#new") + it 'loads harvests#edit' do + harvest = FactoryBot.create :harvest, owner: member + visit edit_harvest_path(harvest) + Percy.snapshot(page, name: "#{prefix}/harvests#edit") + end + + it 'loads planting#edit' do + planting = FactoryBot.create :planting, owner: member + visit edit_planting_path(planting) + Percy.snapshot(page, name: "#{prefix}/plantings#edit") + end + + it 'loads posts#edit' do + post = FactoryBot.create :post, owner: member + visit edit_post_path(post) + Percy.snapshot(page, name: "#{prefix}/posts#edit") + end end end end From 430334a8318473950303f792dd38175809d65418 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 27 Apr 2019 16:46:11 +1200 Subject: [PATCH 036/549] More photo specs for percy --- spec/features/percy/percy_spec.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 01637e6c1..e1927c5dc 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -21,7 +21,8 @@ describe 'Test with visual testing', type: :feature, js: true do crop = FactoryBot.create crop_type, creator: someone_else owner = FactoryBot.create :member, login_name: crop_type.to_s.reverse, email: "#{crop.name}@example.com" planting = FactoryBot.create :planting, crop: crop, owner: owner, garden: owner.gardens.first - photo = FactoryBot.create(:photo, owner: owner, thumbnail_url: photo_url) + photo = FactoryBot.create(:photo, owner: owner, + thumbnail_url: "#{photo_url}_q.jpg", fullsize_url: "#{photo_url}_z.jpg") planting.photos << photo harvest = FactoryBot.create :harvest, crop: crop, owner: owner @@ -92,10 +93,13 @@ describe 'Test with visual testing', type: :feature, js: true do describe 'photos' do it 'loads photos#show' do - photo = FactoryBot.create :photo, owner: member, + photo = FactoryBot.create :photo, + title: 'look at my tomatoes', + owner: member, fullsize_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_z.jpg', thumbnail_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_q.jpg' - visit photo_url(photo) + photo.plantings << FactoryBot.create(:planting, owner: member, crop: tomato) + visit photo_path(photo) Percy.snapshot(page, name: "#{prefix}/photos#show") end end @@ -196,7 +200,7 @@ describe 'Test with visual testing', type: :feature, js: true do end it 'loads posts#edit' do - post = FactoryBot.create :post, owner: member + post = FactoryBot.create :post, author: member visit edit_post_path(post) Percy.snapshot(page, name: "#{prefix}/posts#edit") end From eabf1fc659636ff8b5e289784ed4c341c49f549d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 27 Apr 2019 19:11:30 +1200 Subject: [PATCH 037/549] Tidy up (most) forms --- app/views/alternate_names/_form.html.haml | 62 +++--- app/views/crops/_form.html.haml | 236 +++++++++++----------- app/views/gardens/_form.html.haml | 118 ++++++----- app/views/harvests/_form.html.haml | 126 ++++++------ app/views/plantings/_form.html.haml | 158 ++++++++------- app/views/posts/_form.html.haml | 62 +++--- app/views/seeds/_form.html.haml | 198 +++++++++--------- 7 files changed, 501 insertions(+), 459 deletions(-) diff --git a/app/views/alternate_names/_form.html.haml b/app/views/alternate_names/_form.html.haml index b2dd8b500..879dc2b54 100644 --- a/app/views/alternate_names/_form.html.haml +++ b/app/views/alternate_names/_form.html.haml @@ -1,32 +1,38 @@ -= form_for @alternate_name, html: { class: 'form-horizontal', role: "form" } do |f| - - if @alternate_name.errors.any? - #error_explanation - %h2 - = pluralize(@alternate_name.errors.size, "error") - prohibited this alternate_name from being saved: - %ul - - @alternate_name.errors.full_messages.each do |msg| - %li= msg +.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 + / Naked Form + .card-body + - if content_for? :title + %h1.h2-responsive.text-center + %strong=yield :title + = form_for @alternate_name, html: { class: 'form-horizontal', role: "form" } do |f| + - if @alternate_name.errors.any? + #error_explanation + %h2 + = pluralize(@alternate_name.errors.size, "error") + prohibited this alternate_name from being saved: + %ul + - @alternate_name.errors.full_messages.each do |msg| + %li= msg - %p - %span.help-block - For detailed crop wrangling guidelines, please consult the - = link_to "crop wrangling guide", "http://wiki.growstuff.org/index.php/Crop_wrangling" - on the Growstuff wiki. + %p + %span.help-block + For detailed crop wrangling guidelines, please consult the + = link_to "crop wrangling guide", "http://wiki.growstuff.org/index.php/Crop_wrangling" + on the Growstuff wiki. - .form-group - = f.label :crop_id, class: 'control-label col-md-2' - .col-md-8 - = collection_select(:alternate_name, :crop_id, - Crop.all, :id, :name, - { selected: @alternate_name.crop_id || @crop.id }, - class: 'form-control') + .form-group + = f.label :crop_id, class: 'control-label col-md-2' + .col-md-8 + = collection_select(:alternate_name, :crop_id, + Crop.all, :id, :name, + { selected: @alternate_name.crop_id || @crop.id }, + class: 'form-control') - .form-group - = f.label :name, class: 'control-label col-md-2' - .col-md-8 - = f.text_field :name, class: 'form-control' + .form-group + = f.label :name, class: 'control-label col-md-2' + .col-md-8 + = f.text_field :name, class: 'form-control' - .form-group - .form-actions.col-md-offset-2.col-md-8 - = f.submit 'Save', class: 'btn btn-primary' + .form-group + .form-actions.col-md-offset-2.col-md-8 + = f.submit 'Save', class: 'btn btn-primary' diff --git a/app/views/crops/_form.html.haml b/app/views/crops/_form.html.haml index c16041f97..e95791797 100644 --- a/app/views/crops/_form.html.haml +++ b/app/views/crops/_form.html.haml @@ -1,128 +1,134 @@ -= form_for @crop, html: { class: 'form-horizontal', role: "form" } do |f| - - if @crop.errors.any? - #error_explanation - %h3 - = pluralize(@crop.errors.size, "error") - prohibited this crop from being saved: - %ul - - @crop.errors.full_messages.each do |msg| - %li= msg +.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 + / Naked Form + .card-body + - if content_for? :title + %h1.h2-responsive.text-center + %strong=yield :title + = form_for @crop, html: { class: 'form-horizontal', role: "form" } do |f| + - if @crop.errors.any? + #error_explanation + %h3 + = pluralize(@crop.errors.size, "error") + prohibited this crop from being saved: + %ul + - @crop.errors.full_messages.each do |msg| + %li= msg - -# Handy link to crop wrangling policy/style guide, shown to wranglers only - - if can? :wrangle, @crop - %p - %span.help-block - For detailed crop wrangling guidelines, please consult the - = link_to "crop wrangling guide", "http://wiki.growstuff.org/index.php/Crop_wrangling" - on the Growstuff wiki. + -# Handy link to crop wrangling policy/style guide, shown to wranglers only + - if can? :wrangle, @crop + %p + %span.help-block + For detailed crop wrangling guidelines, please consult the + = link_to "crop wrangling guide", "http://wiki.growstuff.org/index.php/Crop_wrangling" + on the Growstuff wiki. - -# Everyone (wranglers and requesters) sees the basic info section - %h2 Basic information + -# Everyone (wranglers and requesters) sees the basic info section + %h2 Basic information - .form-group#new_crop - = f.label :name, class: 'control-label col-md-2' - .col-md-8 - = f.text_field :name, class: 'form-control' - %span.help-block - The common name for the crop, in English (required). - - if can? :wrangle, @crop - Wranglers: please ensure this is singular, and capitalize - proper nouns only. - - .form-group - = f.label :perennial, 'Lifespan', class: 'control-label col-md-2' - .col-md-8 - = f.radio_button(:perennial, false) - = f.label(:perennial_false, "Annual") - %span.help-block Living and reproducing in a single year or less - = f.radio_button(:perennial, true) - = f.label(:perennial_true, "Perennial") - %span.help-block Living more than two years - - .form-group - = f.label :en_wikipedia_url, 'Wikipedia URL', class: 'control-label col-md-2' - .col-md-8 - = f.text_field :en_wikipedia_url, class: 'form-control', id: "en_wikipedia_url" - %span.help-block - Link to the crop's page on the English language Wikipedia (required). - - -# Only crop wranglers see the crop hierarchy (for now) - - if can? :wrangle, @crop - .form-group - = f.label :parent_id, 'Parent crop', class: 'control-label col-md-2' - .col-md-8 - = collection_select(:crop, :parent_id, Crop.all.order(:name), :id, :name, - { include_blank: true }, class: 'form-control') - %span.help-block Optional. For setting up crop hierarchies for varieties etc. - - - -# Everyone (wranglers and requesters) gets to add scientific names - %h2 - Scientific names - = button_tag "+", id: "add-sci_name-row", type: "button" - = button_tag "-", id: "remove-sci_name-row", type: "button" - - .form-group#scientific_names - - @crop.scientific_names.each.with_index do |sci, index| - .template.col-md-12{ id: "sci_template[#{index + 1}]" } - .col-md-2 - = label_tag :scientific_names, "Scientific name #{index + 1}:", class: 'control-label' + .form-group#new_crop + = f.label :name, class: 'control-label col-md-2' .col-md-8 - = text_field_tag "sci_name[#{index + 1}]", sci.name, id: "sci_name[#{index + 1}]", class: 'form-control' - %span.help-block Scientific name of crop. - .col-md-2 + = f.text_field :name, class: 'form-control' + %span.help-block + The common name for the crop, in English (required). + - if can? :wrangle, @crop + Wranglers: please ensure this is singular, and capitalize + proper nouns only. - %h2 - Alternate names - = button_tag "+", id: "add-alt_name-row", type: "button" - = button_tag "-", id: "remove-alt_name-row", type: "button" - - .form-group#alternate_names - - @crop.alternate_names.each.with_index do |alt, index| - .template.col-md-12{ id: "alt_template[#{index + 1}]" } - .col-md-2 - = label_tag :alternate_names, "Alternate name #{index + 1}:", class: 'control-label' + .form-group + = f.label :perennial, 'Lifespan', class: 'control-label col-md-2' .col-md-8 - = text_field_tag "alt_name[#{index + 1}]", alt.name, id: "alt_name[#{index + 1}]", class: 'form-control' - %span.help-block Alternate name of crop. - .col-md-2 + = f.radio_button(:perennial, false) + = f.label(:perennial_false, "Annual") + %span.help-block Living and reproducing in a single year or less + = f.radio_button(:perennial, true) + = f.label(:perennial_true, "Perennial") + %span.help-block Living more than two years - -# This is used for comments from crop requesters. We need to show it - -# to everyone, but we don't include it on new crops from wranglers. + .form-group + = f.label :en_wikipedia_url, 'Wikipedia URL', class: 'control-label col-md-2' + .col-md-8 + = f.text_field :en_wikipedia_url, class: 'form-control', id: "en_wikipedia_url" + %span.help-block + Link to the crop's page on the English language Wikipedia (required). - - if (can?(:wrangle, @crop) && @crop.requester) || (cannot?(:wrangle, @crop) && @crop.new_record?) - %h2 Crop request notes - .form-group - = f.label :request_notes, 'Comments', class: 'control-label col-md-2' - .col-md-8 - = f.text_area :request_notes, rows: 3, class: 'form-control', id: 'request_notes' + -# Only crop wranglers see the crop hierarchy (for now) + - if can? :wrangle, @crop + .form-group + = f.label :parent_id, 'Parent crop', class: 'control-label col-md-2' + .col-md-8 + = collection_select(:crop, :parent_id, Crop.all.order(:name), :id, :name, + { include_blank: true }, class: 'form-control') + %span.help-block Optional. For setting up crop hierarchies for varieties etc. - -# A final explanation of what's going to happen next, for crop requesters - - unless can? :wrangle, @crop - %p - When you submit this form, your suggestion will be sent to our team of - volunteer crop wranglers for review. We'll let you know the outcome as soon as we can. - -# Now, for crop wranglers, let's have approval/rejection at the bottom of the page - - if can?(:wrangle, @crop) && @crop.requester - %h2 Approve or reject pending crops - .form-group - = f.label :approval_status, 'Approval status', class: 'control-label col-md-2' - .col-md-8 - = f.select(:approval_status, @crop.approval_statuses, {}, class: 'form-control') + -# Everyone (wranglers and requesters) gets to add scientific names + %h2 + Scientific names + = button_tag "+", id: "add-sci_name-row", type: "button" + = button_tag "-", id: "remove-sci_name-row", type: "button" - .form-group - = f.label :reason_for_rejection, 'Reason for rejection', class: 'control-label col-md-2' - .col-md-8 - = f.select(:reason_for_rejection, @crop.reasons_for_rejection, include_blank: true, class: 'form-control') + .form-group#scientific_names + - @crop.scientific_names.each.with_index do |sci, index| + .template.col-md-12{ id: "sci_template[#{index + 1}]" } + .col-md-2 + = label_tag :scientific_names, "Scientific name #{index + 1}:", class: 'control-label' + .col-md-8 + = text_field_tag "sci_name[#{index + 1}]", sci.name, id: "sci_name[#{index + 1}]", class: 'form-control' + %span.help-block Scientific name of crop. + .col-md-2 - .form-group - = f.label :rejection_notes, 'Rejection notes', class: 'control-label col-md-2' - .col-md-8 - = f.text_area :rejection_notes, rows: 3, class: 'form-control' - %span.help-block - Please provide additional notes why this crop request was rejected if the above reasons do not apply. + %h2 + Alternate names + = button_tag "+", id: "add-alt_name-row", type: "button" + = button_tag "-", id: "remove-alt_name-row", type: "button" - .form-group - .form-actions.col-md-offset-2.col-md-8 - = f.submit 'Save', class: 'btn btn-primary' + .form-group#alternate_names + - @crop.alternate_names.each.with_index do |alt, index| + .template.col-md-12{ id: "alt_template[#{index + 1}]" } + .col-md-2 + = label_tag :alternate_names, "Alternate name #{index + 1}:", class: 'control-label' + .col-md-8 + = text_field_tag "alt_name[#{index + 1}]", alt.name, id: "alt_name[#{index + 1}]", class: 'form-control' + %span.help-block Alternate name of crop. + .col-md-2 + + -# This is used for comments from crop requesters. We need to show it + -# to everyone, but we don't include it on new crops from wranglers. + + - if (can?(:wrangle, @crop) && @crop.requester) || (cannot?(:wrangle, @crop) && @crop.new_record?) + %h2 Crop request notes + .form-group + = f.label :request_notes, 'Comments', class: 'control-label col-md-2' + .col-md-8 + = f.text_area :request_notes, rows: 3, class: 'form-control', id: 'request_notes' + + -# A final explanation of what's going to happen next, for crop requesters + - unless can? :wrangle, @crop + %p + When you submit this form, your suggestion will be sent to our team of + volunteer crop wranglers for review. We'll let you know the outcome as soon as we can. + + -# Now, for crop wranglers, let's have approval/rejection at the bottom of the page + - if can?(:wrangle, @crop) && @crop.requester + %h2 Approve or reject pending crops + .form-group + = f.label :approval_status, 'Approval status', class: 'control-label col-md-2' + .col-md-8 + = f.select(:approval_status, @crop.approval_statuses, {}, class: 'form-control') + + .form-group + = f.label :reason_for_rejection, 'Reason for rejection', class: 'control-label col-md-2' + .col-md-8 + = f.select(:reason_for_rejection, @crop.reasons_for_rejection, include_blank: true, class: 'form-control') + + .form-group + = f.label :rejection_notes, 'Rejection notes', class: 'control-label col-md-2' + .col-md-8 + = f.text_area :rejection_notes, rows: 3, class: 'form-control' + %span.help-block + Please provide additional notes why this crop request was rejected if the above reasons do not apply. + + .form-group + .form-actions.col-md-offset-2.col-md-8 + = f.submit 'Save', class: 'btn btn-primary' diff --git a/app/views/gardens/_form.html.haml b/app/views/gardens/_form.html.haml index b5510fad9..ac2be11e4 100644 --- a/app/views/gardens/_form.html.haml +++ b/app/views/gardens/_form.html.haml @@ -1,64 +1,70 @@ -= required_field_help_text +.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 + / Naked Form + .card-body + - if content_for? :title + %h1.h2-responsive.text-center + %strong=yield :title + = required_field_help_text -= form_for(@garden, html: { class: "form-horizontal", role: "form" }) do |f| - - if @garden.errors.any? - #error_explanation - %h2 - = pluralize(@garden.errors.size, "error") - prohibited this garden from being saved: - %ul - - @garden.errors.full_messages.each do |msg| - %li= msg + = form_for(@garden, html: { class: "form-horizontal", role: "form" }) do |f| + - if @garden.errors.any? + #error_explanation + %h2 + = pluralize(@garden.errors.size, "error") + prohibited this garden from being saved: + %ul + - @garden.errors.full_messages.each do |msg| + %li= msg - .form-group.required - = f.label :name, class: 'control-label col-md-2' - .col-md-8 - = f.text_field :name, class: 'form-control', maxlength: 255, required: "required" + .form-group.required + = f.label :name, class: 'control-label col-md-2' + .col-md-8 + = f.text_field :name, class: 'form-control', maxlength: 255, required: "required" - .form-group - = f.label :description, class: 'control-label col-md-2' - .col-md-8 - = f.text_area :description, rows: 6, class: 'form-control' - = render partial: 'shared/form_optional' + .form-group + = f.label :description, class: 'control-label col-md-2' + .col-md-8 + = f.text_area :description, rows: 6, class: 'form-control' + = render partial: 'shared/form_optional' - .form-group - = f.label :location, class: 'control-label col-md-2' - .col-md-8 - = f.text_field :location, - value: @garden.location || current_member.location, - class: 'form-control', maxlength: 255 - = render partial: 'shared/form_optional' - %span.help-block - = t('.location_helper') - - if current_member.location.blank? - = link_to "Set your location now.", edit_member_registration_path - - else - = link_to "Change your location.", edit_member_registration_path + .form-group + = f.label :location, class: 'control-label col-md-2' + .col-md-8 + = f.text_field :location, + value: @garden.location || current_member.location, + class: 'form-control', maxlength: 255 + = render partial: 'shared/form_optional' + %span.help-block + = t('.location_helper') + - if current_member.location.blank? + = link_to "Set your location now.", edit_member_registration_path + - else + = link_to "Change your location.", edit_member_registration_path - .form-group - = f.label :area, class: 'control-label col-md-2' - .col-md-2 - = f.number_field :area, class: 'input-small form-control' - = render partial: 'shared/form_optional' - .col-md-2 - = f.select(:area_unit, Garden::AREA_UNITS_VALUES, { include_blank: false }, class: 'form-control') + .form-group + = f.label :area, class: 'control-label col-md-2' + .col-md-2 + = f.number_field :area, class: 'input-small form-control' + = render partial: 'shared/form_optional' + .col-md-2 + = f.select(:area_unit, Garden::AREA_UNITS_VALUES, { include_blank: false }, class: 'form-control') - .form-group - = f.label :garden_type, class: 'control-label col-md-2' - .col-md-2 - = collection_select(:garden, :garden_type_id, - GardenType.all.order(:name), - :id, :name, - selected: @garden.garden_type_id, - class: 'form-control') + .form-group + = f.label :garden_type, class: 'control-label col-md-2' + .col-md-2 + = collection_select(:garden, :garden_type_id, + GardenType.all.order(:name), + :id, :name, + selected: @garden.garden_type_id, + class: 'form-control') - .form-group - = f.label :active, 'Active? ', class: 'control-label col-md-2' - .col-md-8 - = f.check_box :active - You can mark a garden as inactive if you no longer use it. Note: - this will mark all plantings in the garden as "finished". + .form-group + = f.label :active, 'Active? ', class: 'control-label col-md-2' + .col-md-8 + = f.check_box :active + You can mark a garden as inactive if you no longer use it. Note: + this will mark all plantings in the garden as "finished". - .form-group - .form-actions.col-md-offset-2.col-md-8 - = f.submit 'Save Garden', class: 'btn btn-primary' + .form-group + .form-actions.col-md-offset-2.col-md-8 + = f.submit 'Save Garden', class: 'btn btn-primary' diff --git a/app/views/harvests/_form.html.haml b/app/views/harvests/_form.html.haml index 43f8dbc92..5a4aa2b0d 100644 --- a/app/views/harvests/_form.html.haml +++ b/app/views/harvests/_form.html.haml @@ -1,68 +1,74 @@ -= required_field_help_text +.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 + / Naked Form + .card-body + - if content_for? :title + %h1.h2-responsive.text-center + %strong=yield :title + = required_field_help_text -= form_for(@harvest, html: { class: "form-horizontal", role: :form }) do |f| - - if @harvest.errors.any? - #error_explanation - %h2 - = pluralize(@harvest.errors.size, "error") - prohibited this harvest from being saved:" - %ul - - @harvest.errors.full_messages.each do |msg| - %li= msg + = form_for(@harvest, html: { class: "form-horizontal", role: :form }) do |f| + - if @harvest.errors.any? + #error_explanation + %h2 + = pluralize(@harvest.errors.size, "error") + prohibited this harvest from being saved:" + %ul + - @harvest.errors.full_messages.each do |msg| + %li= msg - .form-group.required - = f.label :crop, 'What did you harvest?', class: 'control-label col-md-2' - - if @planting - .col-md-8 - = link_to @planting.crop.name, planting_path(@planting) - from - = link_to @planting.garden.name, garden_path(@planting.garden) - = f.hidden_field :planting_id, value: @planting.id - - else - .col-md-4 - = auto_suggest @harvest, :crop, class: 'form-control col-md-2', default: @crop + .form-group.required + = f.label :crop, 'What did you harvest?', class: 'control-label col-md-2' + - if @planting + .col-md-8 + = link_to @planting.crop.name, planting_path(@planting) + from + = link_to @planting.garden.name, garden_path(@planting.garden) + = f.hidden_field :planting_id, value: @planting.id + - else + .col-md-4 + = auto_suggest @harvest, :crop, class: 'form-control col-md-2', default: @crop - .col-md-4 - = collection_select(:harvest, :plant_part_id, PlantPart.all, - :id, :name, { selected: @harvest.plant_part_id }, - class: 'form-control', prompt: 'e.g. fruit', required: "required") - - unless @planting - %span.help-block.col-md-8 - Can't find what you're looking for? - = link_to "Request new crops.", new_crop_path + .col-md-4 + = collection_select(:harvest, :plant_part_id, PlantPart.all, + :id, :name, { selected: @harvest.plant_part_id }, + class: 'form-control', prompt: 'e.g. fruit', required: "required") + - unless @planting + %span.help-block.col-md-8 + Can't find what you're looking for? + = link_to "Request new crops.", new_crop_path - .form-group - = f.label :harvested_at, 'When?', class: 'control-label col-md-2' - .col-md-2 - = f.text_field :harvested_at, value: @harvest.harvested_at ? @harvest.harvested_at.to_s(:ymd) : '', - class: 'add-datepicker form-control' - = render partial: 'shared/form_optional' + .form-group + = f.label :harvested_at, 'When?', class: 'control-label col-md-2' + .col-md-2 + = f.text_field :harvested_at, value: @harvest.harvested_at ? @harvest.harvested_at.to_s(:ymd) : '', + class: 'add-datepicker form-control' + = render partial: 'shared/form_optional' - .form-group - = f.label :quantity, 'How many?', class: 'control-label col-md-2' - .col-md-2 - -# Some browsers (eg Firefox for Android) assume "number" means - -# "integer" unless you specify step="any": - -# http://blog.isotoma.com/2012/03/html5-input-typenumber-and-decimalsfloats-in-chrome/ - = f.number_field :quantity, class: 'input-small form-control', step: 'any' - = render partial: 'shared/form_optional' - .col-md-2 - = f.select(:unit, Harvest::UNITS_VALUES, { include_blank: false }, class: 'input-medium form-control') + .form-group + = f.label :quantity, 'How many?', class: 'control-label col-md-2' + .col-md-2 + -# Some browsers (eg Firefox for Android) assume "number" means + -# "integer" unless you specify step="any": + -# http://blog.isotoma.com/2012/03/html5-input-typenumber-and-decimalsfloats-in-chrome/ + = f.number_field :quantity, class: 'input-small form-control', step: 'any' + = render partial: 'shared/form_optional' + .col-md-2 + = f.select(:unit, Harvest::UNITS_VALUES, { include_blank: false }, class: 'input-medium form-control') - .form-group - = f.label :weight_quantity, 'Weighing (in total):', class: 'control-label col-md-2' - .col-md-2 - = f.number_field :weight_quantity, class: 'input-small form-control', step: 'any' - = render partial: 'shared/form_optional' - .col-md-2 - = f.select(:weight_unit, Harvest::WEIGHT_UNITS_VALUES, { include_blank: false }, class: 'form-control') - .form-group - = f.label :description, 'Notes', class: 'control-label col-md-2' - .col-md-8 - = f.text_area :description, rows: 6, class: 'form-control' - = render partial: 'shared/form_optional' + .form-group + = f.label :weight_quantity, 'Weighing (in total):', class: 'control-label col-md-2' + .col-md-2 + = f.number_field :weight_quantity, class: 'input-small form-control', step: 'any' + = render partial: 'shared/form_optional' + .col-md-2 + = f.select(:weight_unit, Harvest::WEIGHT_UNITS_VALUES, { include_blank: false }, class: 'form-control') + .form-group + = f.label :description, 'Notes', class: 'control-label col-md-2' + .col-md-8 + = f.text_area :description, rows: 6, class: 'form-control' + = render partial: 'shared/form_optional' - .form-group - .form-actions.col-md-offset-2.col-md-8 - = f.submit 'Save', class: 'btn btn-primary' + .form-group + .form-actions.col-md-offset-2.col-md-8 + = f.submit 'Save', class: 'btn btn-primary' diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml index 87f7ba16a..3ba54e619 100644 --- a/app/views/plantings/_form.html.haml +++ b/app/views/plantings/_form.html.haml @@ -1,79 +1,85 @@ -= required_field_help_text +.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 + / Naked Form + .card-body + - if content_for? :title + %h1.h2-responsive.text-center + %strong=yield :title + = required_field_help_text -= form_for(@planting, html: { class: "form-horizontal", role: "form" }) do |f| - - if @planting.errors.any? - #error_explanation - %h2 - = pluralize(@planting.errors.size, "error") - prohibited this planting from being saved: - %ul - - @planting.errors.full_messages.each do |msg| - %li= msg + = form_for(@planting, html: { class: "form-horizontal", role: "form" }) do |f| + - if @planting.errors.any? + #error_explanation + %h2 + = pluralize(@planting.errors.size, "error") + prohibited this planting from being saved: + %ul + - @planting.errors.full_messages.each do |msg| + %li= msg - .form-group.required - = f.label :crop, 'What did you plant?', class: 'control-label col-md-2' - .col-md-8 - - if @seed.present? - = link_to @seed, seed_path(@seed) - = f.hidden_field :parent_seed_id, value: @seed.id - - else - = auto_suggest @planting, :crop, class: 'form-control', default: @crop - %span.help-inline - Can't find what you're looking for? - = link_to "Request new crops.", new_crop_path - .form-group.required - = f.label :garden_id, 'Where did you plant it?', class: 'control-label col-md-2' - .col-md-8 - = collection_select(:planting, :garden_id, - current_member.gardens.active.order_by_name, - :id, :name, - selected: @planting.garden_id || @garden.id, - class: 'form-control') - %span.help-inline - = link_to "Add a garden.", new_garden_path - .form-group - = f.label :planted_at, 'When?', class: 'control-label col-md-2' - .col-md-2 - = f.text_field :planted_at, - value: @planting.planted_at ? @planting.planted_at.to_s(:ymd) : '', - class: 'add-datepicker form-control' - = render partial: 'shared/form_optional' - .form-group - = f.label :quantity, 'How many?', class: 'control-label col-md-2' - .col-md-2 - = f.number_field :quantity, class: 'form-control' - = render partial: 'shared/form_optional' - .form-group - = f.label :planted_from, 'Planted from:', class: 'control-label col-md-2' - .col-md-8 - = f.select(:planted_from, Planting::PLANTED_FROM_VALUES, { include_blank: '' }, class: 'form-control') - = render partial: 'shared/form_optional' - .form-group - = f.label :sunniness, 'Sun or shade?', class: 'control-label col-md-2' - .col-md-8 - = f.select(:sunniness, Planting::SUNNINESS_VALUES, { include_blank: '' }, class: 'form-control') - = render partial: 'shared/form_optional' - .form-group - = f.label :description, 'Tell us more about it', class: 'control-label col-md-2' - .col-md-8 - = f.text_area :description, rows: 6, class: 'form-control' - = render partial: 'shared/form_optional' - .form-group - = f.label :finished, 'Mark as finished', class: 'control-label col-md-2' - .col-md-8 - = f.check_box :finished - = render partial: 'shared/form_optional' - %span.help-block - = t('.finish_helper') + .form-group.required + = f.label :crop, 'What did you plant?', class: 'control-label col-md-2' + .col-md-8 + - if @seed.present? + = link_to @seed, seed_path(@seed) + = f.hidden_field :parent_seed_id, value: @seed.id + - else + = auto_suggest @planting, :crop, class: 'form-control', default: @crop + %span.help-inline + Can't find what you're looking for? + = link_to "Request new crops.", new_crop_path + .form-group.required + = f.label :garden_id, 'Where did you plant it?', class: 'control-label col-md-2' + .col-md-8 + = collection_select(:planting, :garden_id, + current_member.gardens.active.order_by_name, + :id, :name, + selected: @planting.garden_id || @garden.id, + class: 'form-control') + %span.help-inline + = link_to "Add a garden.", new_garden_path + .form-group + = f.label :planted_at, 'When?', class: 'control-label col-md-2' + .col-md-2 + = f.text_field :planted_at, + value: @planting.planted_at ? @planting.planted_at.to_s(:ymd) : '', + class: 'add-datepicker form-control' + = render partial: 'shared/form_optional' + .form-group + = f.label :quantity, 'How many?', class: 'control-label col-md-2' + .col-md-2 + = f.number_field :quantity, class: 'form-control' + = render partial: 'shared/form_optional' + .form-group + = f.label :planted_from, 'Planted from:', class: 'control-label col-md-2' + .col-md-8 + = f.select(:planted_from, Planting::PLANTED_FROM_VALUES, { include_blank: '' }, class: 'form-control') + = render partial: 'shared/form_optional' + .form-group + = f.label :sunniness, 'Sun or shade?', class: 'control-label col-md-2' + .col-md-8 + = f.select(:sunniness, Planting::SUNNINESS_VALUES, { include_blank: '' }, class: 'form-control') + = render partial: 'shared/form_optional' + .form-group + = f.label :description, 'Tell us more about it', class: 'control-label col-md-2' + .col-md-8 + = f.text_area :description, rows: 6, class: 'form-control' + = render partial: 'shared/form_optional' + .form-group + = f.label :finished, 'Mark as finished', class: 'control-label col-md-2' + .col-md-8 + = f.check_box :finished + = render partial: 'shared/form_optional' + %span.help-block + = t('.finish_helper') - .form-group - = f.label :finished_at, 'Finished date', class: 'control-label col-md-2' - .col-md-2 - = f.text_field :finished_at, - value: @planting.finished_at ? @planting.finished_at.to_s(:ymd) : '', - class: 'add-datepicker form-control', - placeholder: 'optional' - = render partial: 'shared/form_optional' - .form-group - .form-actions.col-md-offset-2.col-md-8 - = f.submit 'Save', class: 'btn btn-primary' + .form-group + = f.label :finished_at, 'Finished date', class: 'control-label col-md-2' + .col-md-2 + = f.text_field :finished_at, + value: @planting.finished_at ? @planting.finished_at.to_s(:ymd) : '', + class: 'add-datepicker form-control', + placeholder: 'optional' + = render partial: 'shared/form_optional' + .form-group + .form-actions.col-md-offset-2.col-md-8 + = f.submit 'Save', class: 'btn btn-primary' diff --git a/app/views/posts/_form.html.haml b/app/views/posts/_form.html.haml index c631a6eab..14392c78c 100644 --- a/app/views/posts/_form.html.haml +++ b/app/views/posts/_form.html.haml @@ -1,32 +1,38 @@ -= form_for(@post, html: { role: "form" }) do |f| - - if @post.errors.any? - #error_explanation - %h2 - = pluralize(@post.errors.size, "error") - prohibited this post from being saved: - %ul - - @post.errors.full_messages.each do |msg| - %li= msg +.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 + / Naked Form + .card-body + - if content_for? :title + %h1.h2-responsive.text-center + %strong=yield :title + = form_for(@post, html: { role: "form" }) do |f| + - if @post.errors.any? + #error_explanation + %h2 + = pluralize(@post.errors.size, "error") + prohibited this post from being saved: + %ul + - @post.errors.full_messages.each do |msg| + %li= msg - .form-group - = label_tag :post, "Subject", class: 'control-label' - = f.text_field :subject, class: 'form-control', autofocus: 'autofocus', maxlength: 255 + .form-group + = label_tag :post, "Subject", class: 'control-label' + = f.text_field :subject, class: 'form-control', autofocus: 'autofocus', maxlength: 255 - .form-group - - if @post.forum || @forum - = label_tag :body, "What's up?", class: 'control-label' - - else - = label_tag :body, "What's going on in your food garden?" - = f.text_area :body, rows: 12, class: 'form-control' - %span.help-block - = render partial: "shared/markdown_help" + .form-group + - if @post.forum || @forum + = label_tag :body, "What's up?", class: 'control-label' + - else + = label_tag :body, "What's going on in your food garden?" + = f.text_area :body, rows: 12, class: 'form-control' + %span.help-block + = render partial: "shared/markdown_help" - - if @post.forum || @forum - - forum = @post.forum || @forum - %p - This post will be posted in the forum - = link_to forum.name, forum - .field - = f.hidden_field :forum_id, value: forum.id + - if @post.forum || @forum + - forum = @post.forum || @forum + %p + This post will be posted in the forum + = link_to forum.name, forum + .field + = f.hidden_field :forum_id, value: forum.id - = f.submit "Post", class: 'btn btn-primary' + = f.submit "Post", class: 'btn btn-primary' diff --git a/app/views/seeds/_form.html.haml b/app/views/seeds/_form.html.haml index 9bd2dd280..9462023d7 100644 --- a/app/views/seeds/_form.html.haml +++ b/app/views/seeds/_form.html.haml @@ -1,98 +1,104 @@ -= required_field_help_text +.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 + / Naked Form + .card-body + - if content_for? :title + %h1.h2-responsive.text-center + %strong=yield :title + = required_field_help_text -= form_for(@seed, html: { class: "form-horizontal", role: "form" }) do |f| - - if @seed.errors.any? - #error_explanation - %h2 - = pluralize(@seed.errors.size, "error") - prohibited this seed from being saved: - %ul - - @seed.errors.full_messages.each do |msg| - %li= msg - .form-group.required - = f.label :crop, 'Crop:', class: 'control-label col-md-2' - .col-md-8 - - if @planting - = link_to @planting, planting_path(@planting) - = f.hidden_field :parent_planting_id, value: @planting.id - - else - = auto_suggest @seed, :crop, class: 'form-control', default: @crop - %span.help-inline - Can't find what you're looking for? - = link_to "Request new crops.", new_crop_path - .form-group - = f.label :quantity, 'Quantity:', class: 'control-label col-md-2' - .col-md-2 - = f.number_field :quantity, class: 'form-control' - = render partial: 'shared/form_optional' - .form-group - = f.label :plant_before, 'Plant before:', class: 'control-label col-md-2' - .col-md-2 - = f.text_field :plant_before, class: 'add-datepicker form-control', - value: @seed.plant_before ? @seed.plant_before.to_s(:ymd) : '' - = render partial: 'shared/form_optional' - .form-group - = f.label :finished, 'Mark as finished', class: 'control-label col-md-2' - .col-md-8 - = f.check_box :finished - = render partial: 'shared/form_optional' - %span.help-block - = t('.finish_helper') - .form-group - = f.label :finished_at, 'Finished at:', class: 'control-label col-md-2' - .col-md-2 - = f.text_field :finished_at, class: 'add-datepicker form-control', - value: @seed.finished_at ? @seed.finished_at.to_s(:ymd) : '' - = render partial: 'shared/form_optional' - .form-group - = f.label :days_until_maturity_min, 'Days until maturity:', class: 'control-label col-md-2' - %fieldset - .col-md-2 - = f.number_field :days_until_maturity_min, class: 'form-control' - = render partial: 'shared/form_optional' - .col-md-1 - = f.label :days_until_maturity_max, 'to', class: 'control-label' - .col-md-2 - = f.number_field :days_until_maturity_max, class: 'form-control' - = render partial: 'shared/form_optional' - .col-md-1 - = f.label :dummy, 'days', class: 'control-label' + = form_for(@seed, html: { class: "form-horizontal", role: "form" }) do |f| + - if @seed.errors.any? + #error_explanation + %h2 + = pluralize(@seed.errors.size, "error") + prohibited this seed from being saved: + %ul + - @seed.errors.full_messages.each do |msg| + %li= msg + .form-group.required + = f.label :crop, 'Crop:', class: 'control-label col-md-2' + .col-md-8 + - if @planting + = link_to @planting, planting_path(@planting) + = f.hidden_field :parent_planting_id, value: @planting.id + - else + = auto_suggest @seed, :crop, class: 'form-control', default: @crop + %span.help-inline + Can't find what you're looking for? + = link_to "Request new crops.", new_crop_path + .form-group + = f.label :quantity, 'Quantity:', class: 'control-label col-md-2' + .col-md-2 + = f.number_field :quantity, class: 'form-control' + = render partial: 'shared/form_optional' + .form-group + = f.label :plant_before, 'Plant before:', class: 'control-label col-md-2' + .col-md-2 + = f.text_field :plant_before, class: 'add-datepicker form-control', + value: @seed.plant_before ? @seed.plant_before.to_s(:ymd) : '' + = render partial: 'shared/form_optional' + .form-group + = f.label :finished, 'Mark as finished', class: 'control-label col-md-2' + .col-md-8 + = f.check_box :finished + = render partial: 'shared/form_optional' + %span.help-block + = t('.finish_helper') + .form-group + = f.label :finished_at, 'Finished at:', class: 'control-label col-md-2' + .col-md-2 + = f.text_field :finished_at, class: 'add-datepicker form-control', + value: @seed.finished_at ? @seed.finished_at.to_s(:ymd) : '' + = render partial: 'shared/form_optional' + .form-group + = f.label :days_until_maturity_min, 'Days until maturity:', class: 'control-label col-md-2' + %fieldset + .col-md-2 + = f.number_field :days_until_maturity_min, class: 'form-control' + = render partial: 'shared/form_optional' + .col-md-1 + = f.label :days_until_maturity_max, 'to', class: 'control-label' + .col-md-2 + = f.number_field :days_until_maturity_max, class: 'form-control' + = render partial: 'shared/form_optional' + .col-md-1 + = f.label :dummy, 'days', class: 'control-label' - .form-group.required - = f.label :organic, 'Organic?', class: 'control-label col-md-2' - .col-md-8 - = f.select(:organic, Seed::ORGANIC_VALUES, {}, class: 'form-control', default: 'unknown') - .form-group.required - = f.label :gmo, 'GMO?', class: 'control-label col-md-2' - .col-md-8 - = f.select(:gmo, Seed::GMO_VALUES, {}, class: 'form-control', default: 'unknown') - .form-group.required - = f.label :heirloom, 'Heirloom?', class: 'control-label col-md-2' - .col-md-8 - = f.select(:heirloom, Seed::HEIRLOOM_VALUES, {}, class: 'form-control', default: 'unknown') - .form-group - = f.label :description, 'Description:', class: 'control-label col-md-2' - .col-md-8 - = f.text_area :description, rows: 6, class: 'form-control' - = render partial: 'shared/form_optional' - .form-group - .col-md-offset-2.col-md-8 - %span.help-block - = t('.trade_help', site_name: ENV['GROWSTUFF_SITE_NAME']) - .form-group.required - = f.label :tradable_to, 'Will trade:', class: 'control-label col-md-2' - .col-md-8 - = f.select(:tradable_to, Seed::TRADABLE_TO_VALUES, {}, class: 'form-control') - %span.help_inline - - if current_member.location.blank? - Don't forget to - = succeed "." do - = link_to "set your location", edit_member_registration_path - - else - from - = succeed "." do - = link_to current_member.location, place_path(current_member.location) - = link_to "Change your location.", edit_member_registration_path - .form-group - .form-actions.col-md-offset-2.col-md-8 - = f.submit 'Save', class: 'btn btn-primary' + .form-group.required + = f.label :organic, 'Organic?', class: 'control-label col-md-2' + .col-md-8 + = f.select(:organic, Seed::ORGANIC_VALUES, {}, class: 'form-control', default: 'unknown') + .form-group.required + = f.label :gmo, 'GMO?', class: 'control-label col-md-2' + .col-md-8 + = f.select(:gmo, Seed::GMO_VALUES, {}, class: 'form-control', default: 'unknown') + .form-group.required + = f.label :heirloom, 'Heirloom?', class: 'control-label col-md-2' + .col-md-8 + = f.select(:heirloom, Seed::HEIRLOOM_VALUES, {}, class: 'form-control', default: 'unknown') + .form-group + = f.label :description, 'Description:', class: 'control-label col-md-2' + .col-md-8 + = f.text_area :description, rows: 6, class: 'form-control' + = render partial: 'shared/form_optional' + .form-group + .col-md-offset-2.col-md-8 + %span.help-block + = t('.trade_help', site_name: ENV['GROWSTUFF_SITE_NAME']) + .form-group.required + = f.label :tradable_to, 'Will trade:', class: 'control-label col-md-2' + .col-md-8 + = f.select(:tradable_to, Seed::TRADABLE_TO_VALUES, {}, class: 'form-control') + %span.help_inline + - if current_member.location.blank? + Don't forget to + = succeed "." do + = link_to "set your location", edit_member_registration_path + - else + from + = succeed "." do + = link_to current_member.location, place_path(current_member.location) + = link_to "Change your location.", edit_member_registration_path + .form-group + .form-actions.col-md-offset-2.col-md-8 + = f.submit 'Save', class: 'btn btn-primary' From 945d320a0aa529c4efd18323b3ef038ea868fc30 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 27 Apr 2019 19:11:49 +1200 Subject: [PATCH 038/549] Remove the title from every page - because sometimes we don't want it --- app/views/layouts/application.html.haml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 3e8130fe0..f081d970c 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -15,11 +15,8 @@ - if content_for?(:buttonbar) = yield(:buttonbar) - - if content_for?(:title) - %h1#title - = yield(:title) - - if content_for?(:subtitle) - %small= yield(:subtitle) + - if content_for?(:subtitle) + %small= yield(:subtitle) .col-md-6 From 45745a4e38a1b93cf761085affbd8b5e9662667b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 27 Apr 2019 19:11:59 +1200 Subject: [PATCH 039/549] Add crops#new to percy --- spec/features/percy/percy_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index e1927c5dc..c47db0f7d 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -178,6 +178,11 @@ describe 'Test with visual testing', type: :feature, js: true do visit new_post_path Percy.snapshot(page, name: "#{prefix}/posts#new") end + + it 'loads crops#new' do + visit new_crop_path + Percy.snapshot(page, name: "#{prefix}/crops#new") + end end describe '#edit' do From 9ecf210ffb41bf48fc246eecbd29f1daab276635 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 27 Apr 2019 19:19:42 +1200 Subject: [PATCH 040/549] More form tidy up --- app/views/alternate_names/_form.html.haml | 1 - app/views/comments/_form.html.haml | 44 +++++++++++++---------- app/views/crops/_form.html.haml | 1 - app/views/gardens/_form.html.haml | 1 - app/views/harvests/_form.html.haml | 1 - app/views/layouts/application.html.haml | 1 - app/views/plantings/_form.html.haml | 1 - app/views/posts/_form.html.haml | 1 - app/views/seeds/_form.html.haml | 1 - 9 files changed, 25 insertions(+), 27 deletions(-) diff --git a/app/views/alternate_names/_form.html.haml b/app/views/alternate_names/_form.html.haml index 879dc2b54..6c9bbf283 100644 --- a/app/views/alternate_names/_form.html.haml +++ b/app/views/alternate_names/_form.html.haml @@ -1,5 +1,4 @@ .card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 - / Naked Form .card-body - if content_for? :title %h1.h2-responsive.text-center diff --git a/app/views/comments/_form.html.haml b/app/views/comments/_form.html.haml index 047060b15..676d7f4fb 100644 --- a/app/views/comments/_form.html.haml +++ b/app/views/comments/_form.html.haml @@ -1,20 +1,26 @@ -= form_for(@comment, html: { class: "form-horizontal", role: "form" }) do |f| - - if @comment.errors.any? - #error_explanation - %h2 - = pluralize(@comment.errors.size, "error") - prohibited this comment from being saved: - %ul - - @comment.errors.full_messages.each do |msg| - %li= msg +.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 + .card-body + - if content_for? :title + %h1.h2-responsive.text-center + %strong=yield :title + = form_for(@comment, html: { class: "form-horizontal", role: "form" }) do |f| + - if @comment.errors.any? + #error_explanation + %h2 + = pluralize(@comment.errors.size, "error") + prohibited this comment from being saved: + %ul + - @comment.errors.full_messages.each do |msg| + %li= msg - .form-group - = f.label :body, "Your comment:" - = f.text_area :body, rows: 6, class: 'form-control', autofocus: 'autofocus' - %span.help-block - = render partial: "shared/markdown_help" - .actions - = f.submit 'Post comment', class: 'btn btn-primary' - - if defined?(@post) - .field - = f.hidden_field :post_id, value: @post.id + .md-form + = f.text_area :body, rows: 6, class: 'form-control md-textarea', autofocus: 'autofocus' + = f.label :body, "Your comment:" + + %span.help-block + = render partial: "shared/markdown_help" + .actions.pull-right + = f.submit 'Post comment', class: 'btn btn-primary' + - if defined?(@post) + .field + = f.hidden_field :post_id, value: @post.id diff --git a/app/views/crops/_form.html.haml b/app/views/crops/_form.html.haml index e95791797..5ae0b586b 100644 --- a/app/views/crops/_form.html.haml +++ b/app/views/crops/_form.html.haml @@ -1,5 +1,4 @@ .card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 - / Naked Form .card-body - if content_for? :title %h1.h2-responsive.text-center diff --git a/app/views/gardens/_form.html.haml b/app/views/gardens/_form.html.haml index ac2be11e4..3e14520d3 100644 --- a/app/views/gardens/_form.html.haml +++ b/app/views/gardens/_form.html.haml @@ -1,5 +1,4 @@ .card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 - / Naked Form .card-body - if content_for? :title %h1.h2-responsive.text-center diff --git a/app/views/harvests/_form.html.haml b/app/views/harvests/_form.html.haml index 5a4aa2b0d..c1e5af31f 100644 --- a/app/views/harvests/_form.html.haml +++ b/app/views/harvests/_form.html.haml @@ -1,5 +1,4 @@ .card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 - / Naked Form .card-body - if content_for? :title %h1.h2-responsive.text-center diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index f081d970c..42b6af851 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -11,7 +11,6 @@ #maincontainer .row .col-md-6 - - if content_for?(:buttonbar) = yield(:buttonbar) diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml index 3ba54e619..d7cadf83d 100644 --- a/app/views/plantings/_form.html.haml +++ b/app/views/plantings/_form.html.haml @@ -1,5 +1,4 @@ .card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 - / Naked Form .card-body - if content_for? :title %h1.h2-responsive.text-center diff --git a/app/views/posts/_form.html.haml b/app/views/posts/_form.html.haml index 14392c78c..aa115588a 100644 --- a/app/views/posts/_form.html.haml +++ b/app/views/posts/_form.html.haml @@ -1,5 +1,4 @@ .card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 - / Naked Form .card-body - if content_for? :title %h1.h2-responsive.text-center diff --git a/app/views/seeds/_form.html.haml b/app/views/seeds/_form.html.haml index 9462023d7..3746c0725 100644 --- a/app/views/seeds/_form.html.haml +++ b/app/views/seeds/_form.html.haml @@ -1,5 +1,4 @@ .card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 - / Naked Form .card-body - if content_for? :title %h1.h2-responsive.text-center From d039c68f8a159ad4dbd42ba22997fba79d7e5f32 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 27 Apr 2019 20:49:17 +1200 Subject: [PATCH 041/549] Tidy up crops#index on mobile --- app/views/crops/_crop.haml | 6 ++++++ app/views/crops/index.html.haml | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 app/views/crops/_crop.haml diff --git a/app/views/crops/_crop.haml b/app/views/crops/_crop.haml new file mode 100644 index 000000000..ca90eb588 --- /dev/null +++ b/app/views/crops/_crop.haml @@ -0,0 +1,6 @@ +- if local_assigns[:full] + - cache crop do + = render 'crops/card', crop: crop +- else + - cache crop do + = render 'crops/thumbnail', crop: crop \ No newline at end of file diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml index f850f9043..6e0258221 100644 --- a/app/views/crops/index.html.haml +++ b/app/views/crops/index.html.haml @@ -29,11 +29,7 @@ .pagination = will_paginate @crops -.row - - @crops.each do |crop| - .col-md-2.six-across - = render partial: "thumbnail", locals: { crop: crop } - +.card-row= render @crops .pagination = will_paginate @crops From 3cb6fb90f72a0f927d402a2863a2da69dadd1b21 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 29 Apr 2019 15:31:24 +1200 Subject: [PATCH 042/549] Fix crop display --- app/views/crops/_crop.haml | 6 --- ...{_index_card.html.haml => _crop.html.haml} | 8 ++-- app/views/crops/_thumbnail.html.haml | 2 +- app/views/crops/show.html.haml | 40 ++++++++++--------- app/views/harvests/show.html.haml | 3 +- app/views/home/_crops.html.haml | 5 ++- app/views/home/index.html.haml | 5 ++- app/views/layouts/_header.html.haml | 1 - app/views/layouts/application.html.haml | 2 +- app/views/photos/show.html.haml | 3 +- app/views/plantings/show.html.haml | 2 +- app/views/seeds/show.html.haml | 2 +- 12 files changed, 37 insertions(+), 42 deletions(-) delete mode 100644 app/views/crops/_crop.haml rename app/views/crops/{_index_card.html.haml => _crop.html.haml} (80%) diff --git a/app/views/crops/_crop.haml b/app/views/crops/_crop.haml deleted file mode 100644 index ca90eb588..000000000 --- a/app/views/crops/_crop.haml +++ /dev/null @@ -1,6 +0,0 @@ -- if local_assigns[:full] - - cache crop do - = render 'crops/card', crop: crop -- else - - cache crop do - = render 'crops/thumbnail', crop: crop \ No newline at end of file diff --git a/app/views/crops/_index_card.html.haml b/app/views/crops/_crop.html.haml similarity index 80% rename from app/views/crops/_index_card.html.haml rename to app/views/crops/_crop.html.haml index 4849e37fc..87c04ec80 100644 --- a/app/views/crops/_index_card.html.haml +++ b/app/views/crops/_crop.html.haml @@ -9,9 +9,7 @@ %h3{ style: 'padding-top: 0px; margin-top: 0px' } = link_to crop, crop - %p - %b Scientific name: - = crop.default_scientific_name + %p= crop.default_scientific_name - if crop.annual? && crop.median_lifespan.present? %p @@ -32,5 +30,5 @@ - if can? :create, Planting = link_to "Plant #{crop.name}", new_planting_path(params: { crop_id: crop.id }), class: 'btn btn-primary' - - if can? :create, Seed - = link_to "Add #{crop.name} seeds to stash", new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-primary' + -# - if can? :create, Seed + -# = link_to "Add #{crop.name} seeds to stash", new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-primary' diff --git a/app/views/crops/_thumbnail.html.haml b/app/views/crops/_thumbnail.html.haml index 2f50c8e91..93cf5a9a0 100644 --- a/app/views/crops/_thumbnail.html.haml +++ b/app/views/crops/_thumbnail.html.haml @@ -1,5 +1,5 @@ - cache cache_key_for(Crop, crop.id) do - .card.thumbnail + .thumbnail.card .crop-thumbnail = link_to image_tag(crop_image_path(crop), alt: crop.name, class: 'img'), diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 2ff6c8886..945087fd4 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -63,29 +63,33 @@ .col-md-3 = render 'wrangle', crop: @crop - %p - = link_to crop_plantings_path(@crop) do - View all #{@crop.name} plantings - (#{@crop.plantings.size}) - %p - = link_to crop_harvests_path(@crop) do - View all #{@crop.name} harvests - (#{@crop.harvests.size}) - %p - = link_to crop_seeds_path(@crop) do - View all #{@crop.name} seeds - (#{@crop.seeds.size}) - - - if member_signed_in? - %p - = link_to member_seeds_path(current_member, crop_slug: @crop.slug) do - = display_seed_availability(@current_member, @crop) - .card .card-body + = image_tag @crop.default_photo.fullsize_url, + class: 'card-img-top img-responsive', + alt: 'photo of crop' %h4 How to grow #{@crop.name.pluralize} = render 'grown_for', crop: @crop = render 'planting_advice', crop: @crop + .card + %p + = link_to crop_plantings_path(@crop), class: 'card-link' do + View all #{@crop.name} plantings + (#{@crop.plantings.size}) + %p + = link_to crop_harvests_path(@crop) do + View all #{@crop.name} harvests + (#{@crop.harvests.size}) + %p + = link_to crop_seeds_path(@crop) do + View all #{@crop.name} seeds + (#{@crop.seeds.size}) + + - if member_signed_in? + %p + = link_to member_seeds_path(current_member, crop_slug: @crop.slug) do + = display_seed_availability(@current_member, @crop) + .well = render 'scientific_names', crop: @crop diff --git a/app/views/harvests/show.html.haml b/app/views/harvests/show.html.haml index c2c5e88e4..952d145fa 100644 --- a/app/views/harvests/show.html.haml +++ b/app/views/harvests/show.html.haml @@ -36,8 +36,7 @@ = display_quantity(@harvest) - .col-md-6 - = render partial: "crops/index_card", locals: { crop: @harvest.crop } + .col-md-6= render @harvest.crop - if @harvest.description.present? %h2 Notes diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml index 09c77f139..6b0feb9d7 100644 --- a/app/views/home/_crops.html.haml +++ b/app/views/home/_crops.html.haml @@ -1,4 +1,5 @@ - cache cache_key_for(Crop, 'homepage'), expires_in: 1.day do - - Crop.interesting.includes(:scientific_names, :photos).shuffle.first(18).each do |c| - = render 'crops/thumbnail', crop: c + .row + - Crop.interesting.includes(:scientific_names, :photos).shuffle.first(12).each do |crop| + .col.md-2= render crop diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 9e3c6b01a..852c260f2 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -6,10 +6,11 @@ .hidden-xs .jumbotron= render 'blurb' -.row.shadow + +.row .col-md-8 %h2= t('.our_crops') - .row.homepage-thumbnails= render 'crops' + .shadow.mx-auto= render 'crops' .align-bottom %p.text-right= link_to "#{t('home.crops.view_all')} »", crops_path, class: 'btn' - cache cache_key_for(Crop, 'recent') do diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index d81b1d80a..1fb12004a 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -1,4 +1,3 @@ - .navbar.navbar-default.navbar-fixed-top{ role: "navigation" } .container-fluid .navbar-header diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 42b6af851..2555453dc 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -5,10 +5,10 @@ %body .sr-only= link_to t(".skip"), "#skipnav" = render partial: "layouts/header" - = render 'shared/global_actions' -# anchor tag for accessibility link to skip the navigation menu %a{ name: 'skipnav' } #maincontainer + = render 'shared/global_actions' .row .col-md-6 - if content_for?(:buttonbar) diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 592c89bbe..c39d17a05 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -16,8 +16,7 @@ = render 'photos/actions', photo: @photo = link_to "View on Flickr", @photo.link_url, class: 'btn' - if @crops.size.positive? - - @crops.each do |crop| - = render 'crops/index_card', crop: crop + = render @crop %p %i.fas.fa-camera-retro %strong Photo by diff --git a/app/views/plantings/show.html.haml b/app/views/plantings/show.html.haml index 68d69bd20..3cd42d5e1 100644 --- a/app/views/plantings/show.html.haml +++ b/app/views/plantings/show.html.haml @@ -27,7 +27,7 @@ = render 'plantings/photos', photos: @photos, planting: @planting %p.text-right= link_to 'more photos', planting_photos_path(@planting) .col-md-4.col-xs-12.pull-right - = render "crops/index_card", crop: @planting.crop + = render @planting.crop .row .col-md-12 = render 'plantings/harvests', planting: @planting diff --git a/app/views/seeds/show.html.haml b/app/views/seeds/show.html.haml index e55faec48..f47a59c69 100644 --- a/app/views/seeds/show.html.haml +++ b/app/views/seeds/show.html.haml @@ -73,7 +73,7 @@ = render 'photos/item_photos', item: @seed, type: 'seed', photos: @photos .col-md-6 - = render partial: "crops/index_card", locals: { crop: @seed.crop } + = render @seed.crop - if @seed.owner.location %p %small From d400e73ff678347c1719cbdb2a05ef259d1254b7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 29 Apr 2019 15:31:47 +1200 Subject: [PATCH 043/549] Move global actions --- app/assets/stylesheets/overrides.sass | 97 +++++++++++----------- app/views/shared/_global_actions.html.haml | 45 +++++----- 2 files changed, 71 insertions(+), 71 deletions(-) diff --git a/app/assets/stylesheets/overrides.sass b/app/assets/stylesheets/overrides.sass index 312f2257d..fd6ffcf1f 100644 --- a/app/assets/stylesheets/overrides.sass +++ b/app/assets/stylesheets/overrides.sass @@ -157,62 +157,61 @@ p.stats .text display: block -.thumbnail - // border: 1px solid lighten($green, 20%) - text-align: center - margin-bottom: 1.5em - max-width: 160px - //max-height: 220px - //height: 180px +// .thumbnail +// // border: 1px solid lighten($green, 20%) +// text-align: center +// margin-bottom: 1.5em +// max-width: 160px +// //max-height: 220px +// //height: 180px - .seed-thumbnail - height: 220px - .seedinfo - .seed-name - font-size: 120% - overflow: hidden +// .seed-thumbnail +// height: 220px +// .seedinfo +// .seed-name +// font-size: 120% +// overflow: hidden - .member-thumbnail - text-align: left - img - height: 85px - width: 85px - max-width: 85px +// .member-thumbnail +// text-align: left +// img +// height: 85px +// width: 85px +// max-width: 85px - .crop-thumbnail - .cropinfo - margin-top: 0.5em - display: inline-block - max-width: 100% - white-space: nowrap - line-height: 1em - padding-bottom: 2px +// .crop-thumbnail +// .cropinfo +// margin-top: 0.5em +// display: inline-block +// max-width: 100% +// white-space: nowrap +// line-height: 1em +// padding-bottom: 2px - .cropname - overflow: hidden - text-overflow: ellipsis - font-size: 120% +// .cropname +// overflow: hidden +// text-overflow: ellipsis +// font-size: 120% - .scientificname - font-size: small - font-style: italic - overflow: hidden - text-overflow: ellipsis - font-size: 70% +// .scientificname +// font-size: small +// font-style: italic +// overflow: hidden +// text-overflow: ellipsis +// font-size: 70% +// .plantingcount +// font-size: small +// .planting-lifespan +// font-size: 70% - .plantingcount - font-size: small - .planting-lifespan - font-size: 70% +// .crop-name a +// padding-top: 2px - .crop-name a - padding-top: 2px - - .scientific-name small - margin-bottom: -2px +// .scientific-name small +// margin-bottom: -2px li.crop-hierarchy list-style-type: disc @@ -374,9 +373,9 @@ ul.thumbnail-buttons width: 185px padding-left: 0 padding-right: 0 - .homepage - .thumbnail - height: 180px + //.homepage + // .thumbnail + // height: 180px #maincontainer padding: 10px diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index cf7bf1b81..7b602607b 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,26 +1,27 @@ -- if signed_in? - %ul.nav.nav-tabs.pull-right#global-actions - %li.nav-item - = link_to member_gardens_path(current_member), class: 'nav-link' do - = garden_icon - = t('links.my_gardens') +.row + .col-md-12 + %ul.nav.nav-tabs.pull-right#global-actions + %li.nav-item + = link_to member_gardens_path(current_member), class: 'nav-link' do + = garden_icon + = t('links.my_gardens') - %li.nav-item - = link_to new_planting_path, class: 'nav-link' do - = planting_icon - = t('plantings.plant') + %li.nav-item + = link_to new_planting_path, class: 'nav-link' do + = planting_icon + = t('plantings.plant') - %li.nav-item - = link_to new_harvest_path, class: 'nav-link' do - = harvest_icon - = t('harvests.harvest') + %li.nav-item + = link_to new_harvest_path, class: 'nav-link' do + = harvest_icon + = t('harvests.harvest') - %li.nav-item - = link_to new_seed_path, class: 'nav-link' do - = seed_icon - = t('buttons.save_seeds') + %li.nav-item + = link_to new_seed_path, class: 'nav-link' do + = seed_icon + = t('buttons.save_seeds') - %li.nav-item - = link_to new_post_path, class: 'nav-link' do - = blog_icon - = t 'posts.write_blog' \ No newline at end of file + %li.nav-item + = link_to new_post_path, class: 'nav-link' do + = blog_icon + = t 'posts.write_blog' \ No newline at end of file From 0c81f962aa11c95461b792a0de0b362ae3cbf67d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 29 Apr 2019 18:16:14 +1200 Subject: [PATCH 044/549] homepage tidy --- app/assets/stylesheets/homepage.sass | 1 + app/views/home/index.html.haml | 33 +++++++-------- app/views/shared/_global_actions.html.haml | 47 +++++++++++----------- 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/app/assets/stylesheets/homepage.sass b/app/assets/stylesheets/homepage.sass index 7fc1818e3..79512cd6c 100644 --- a/app/assets/stylesheets/homepage.sass +++ b/app/assets/stylesheets/homepage.sass @@ -20,6 +20,7 @@ display: flex flex: none flex-wrap: wrap + padding: 1em .card max-width: 200px margin: 1em diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 852c260f2..69df80fda 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -6,34 +6,35 @@ .hidden-xs .jumbotron= render 'blurb' - .row .col-md-8 - %h2= t('.our_crops') - .shadow.mx-auto= render 'crops' - .align-bottom - %p.text-right= link_to "#{t('home.crops.view_all')} »", crops_path, class: 'btn' - - cache cache_key_for(Crop, 'recent') do - .well - %h3= t('.recently_added') - != Crop.recent.limit(30).map { |c| link_to(c, c) }.join(", ") + .homepage-cards.shadow + %h2= t('.our_crops') + .mx-auto= render 'crops' + .align-bottom + %p.text-right= link_to "#{t('home.crops.view_all')} »", crops_path, class: 'btn' + - cache cache_key_for(Crop, 'recent') do + .well + %h3= t('.recently_added') + != Crop.recent.limit(30).map { |c| link_to(c, c) }.join(", ") - %h2= t('.seeds_available_to_trade') - .row.homepage-cards - = render Seed.current.tradable.recent.includes(:owner, :crop).limit(12), full: true - .align-bottom - %p.text-right= link_to "#{t('home.seeds.view_all')} »", seeds_path, class: 'btn' + .well + %h2.text-center= t('.seeds_available_to_trade') + .row.homepage-cards + .card-row.mx-auto= render Seed.current.tradable.recent.includes(:owner, :crop).limit(12), full: true + .align-bottom + %p.text-right= link_to "#{t('home.seeds.view_all')} »", seeds_path, class: 'btn' .col-md-2 %h2= t('.recently_planted') .row.homepage-thumbnails - = render Planting.has_photos.recent.includes(:crop, garden: :owner).limit(3), full: true + = render Planting.has_photos.recent.includes(:crop, garden: :owner).limit(4), full: true .col-md-2 %h2= t('.recently_harvested') .row.homepage-thumbnails - = render Harvest.has_photos.recent.includes(:crop, :owner, :photos).limit(3), full: true + = render Harvest.has_photos.recent.includes(:crop, :owner, :photos).limit(4), full: true /.row= render 'discuss' diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 7b602607b..1efd4e4c6 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,27 +1,28 @@ -.row - .col-md-12 - %ul.nav.nav-tabs.pull-right#global-actions - %li.nav-item - = link_to member_gardens_path(current_member), class: 'nav-link' do - = garden_icon - = t('links.my_gardens') +- if signed_in? + .row + .col-md-12 + %ul.nav.nav-tabs.pull-right#global-actions + %li.nav-item + = link_to member_gardens_path(member_slug: current_member.slug), class: 'nav-link' do + = garden_icon + = t('links.my_gardens') - %li.nav-item - = link_to new_planting_path, class: 'nav-link' do - = planting_icon - = t('plantings.plant') + %li.nav-item + = link_to new_planting_path, class: 'nav-link' do + = planting_icon + = t('plantings.plant') - %li.nav-item - = link_to new_harvest_path, class: 'nav-link' do - = harvest_icon - = t('harvests.harvest') + %li.nav-item + = link_to new_harvest_path, class: 'nav-link' do + = harvest_icon + = t('harvests.harvest') - %li.nav-item - = link_to new_seed_path, class: 'nav-link' do - = seed_icon - = t('buttons.save_seeds') + %li.nav-item + = link_to new_seed_path, class: 'nav-link' do + = seed_icon + = t('buttons.save_seeds') - %li.nav-item - = link_to new_post_path, class: 'nav-link' do - = blog_icon - = t 'posts.write_blog' \ No newline at end of file + %li.nav-item + = link_to new_post_path, class: 'nav-link' do + = blog_icon + = t 'posts.write_blog' \ No newline at end of file From 6dbf7a793239922482e29362e4c796ceb643a9f0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 29 Apr 2019 18:26:07 +1200 Subject: [PATCH 045/549] Fix typo --- app/views/photos/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index c39d17a05..cce196f5b 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -16,7 +16,7 @@ = render 'photos/actions', photo: @photo = link_to "View on Flickr", @photo.link_url, class: 'btn' - if @crops.size.positive? - = render @crop + = render @crops %p %i.fas.fa-camera-retro %strong Photo by From 0c61e72f860b5d01a0088742bf2172a4edd67c4f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 29 Apr 2019 18:32:28 +1200 Subject: [PATCH 046/549] Use full size crop images --- app/helpers/photos_helper.rb | 5 +++-- app/views/crops/show.html.haml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb index ccd8d99a0..a21db9589 100644 --- a/app/helpers/photos_helper.rb +++ b/app/helpers/photos_helper.rb @@ -1,7 +1,8 @@ module PhotosHelper - def crop_image_path(crop) + def crop_image_path(crop, full_size: false) if crop.default_photo.present? - crop.default_photo.thumbnail_url + photo = crop.default_photo + full_size ? photo.fullsize_url : photo.thumbnail_url else placeholder_image end diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 945087fd4..30bdb4cb4 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -65,7 +65,7 @@ = render 'wrangle', crop: @crop .card .card-body - = image_tag @crop.default_photo.fullsize_url, + = image_tag crop_image_path(@crop, full_size: true), class: 'card-img-top img-responsive', alt: 'photo of crop' %h4 How to grow #{@crop.name.pluralize} From e92f5392a1db43deb930dd2d8da239745fc4917b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 30 Apr 2019 13:11:45 +1200 Subject: [PATCH 047/549] Alphabetical gems --- Gemfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 69e996934..59981cda5 100644 --- a/Gemfile +++ b/Gemfile @@ -19,8 +19,10 @@ gem 'jsonapi-resources' gem 'bootstrap-sass' gem 'bootstrap', '4.1.1' gem 'material-sass', '4.1.1' -gem 'material_icons' + +# icons gem 'font-awesome-sass' +gem 'material_icons' gem 'uglifier' # JavaScript compressor From 126769bfada4ff51c56546b08e1a6f4b6da17ada Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 30 Apr 2019 13:14:24 +1200 Subject: [PATCH 048/549] Remove jquery roadmap --- app/assets/javascripts/jquery-roadmap.js | 212 ------------ app/assets/stylesheets/jquery-roadmap.scss | 381 --------------------- 2 files changed, 593 deletions(-) delete mode 100644 app/assets/javascripts/jquery-roadmap.js delete mode 100644 app/assets/stylesheets/jquery-roadmap.scss diff --git a/app/assets/javascripts/jquery-roadmap.js b/app/assets/javascripts/jquery-roadmap.js deleted file mode 100644 index cc8fd6a32..000000000 --- a/app/assets/javascripts/jquery-roadmap.js +++ /dev/null @@ -1,212 +0,0 @@ -;(function(factory) { - "use strict"; - - if (typeof define === 'function' && define.amd) { - define(['jquery'], factory); - } else if (typeof exports !== 'undefined') { - module.exports = factory(require('jquery'), window, document); - } else { - factory(jQuery, window, document); - } - -}(function($, window, document, undefined ) { - - "use strict"; - - // undefined is used here as the undefined global variable in ECMAScript 3 is - // mutable (ie. it can be changed by someone else). undefined isn't really being - // passed in so we can ensure the value of it is truly undefined. In ES5, undefined - // can no longer be modified. - - // window and document are passed through as local variables rather than global - // as this (slightly) quickens the resolution process and can be more efficiently - // minified (especially when both are regularly referenced in your plugin). - - /** - * jQuery custom plugin implement the roadmap functionality - */ - $.fn.roadmap = function(events, opts) { - if ( !events instanceof Array ) { - events = []; - } - - var defaults = { - slide: 1, - eventsPerSlide: 6, - rootClass: 'roadmap', - prevArrow: 'prev', - nextArrow: 'next', - orientation: 'auto', - eventTemplate: '
        ' + - '
        ####DATE###
        ' + - '
        ####CONTENT###
        ' + - '
        ' - }; - - var settings = $.extend({}, defaults, opts); - - var buildEvent = function(event, key) { - var html = '
      • ' + settings.eventTemplate + '
      • '; - html = html.replace('####DATE###', event.date); - html = html.replace('####CONTENT###', event.content); - - var left = (100/(settings.eventsPerSlide-1))*key; - - return $(html).css('left', left + '%'); - } - - return this.each(function() { - var _this = this; - var $this = $(this); - var currentSlide = settings.slide - 1; - - /** - * Store events and settings - */ - $this.data({ - events: events, - settings: settings, - currentSlide: currentSlide - }).addClass(settings.rootClass); - - var clear = function() { - $this.removeClass(settings.rootClass + '--initialized'); - - $this.find('.' + settings.rootClass + '__events').remove(); - $this.find('.' + settings.rootClass + '__navigation').remove(); - } - - var buildEvents = function() { - var currentSlide = $this.data('currentSlide'); - var settings = $this.data('settings'); - var events = $this.data('events'); - - $('
          ', {class: settings.rootClass + '__events'}).append(events.slice((currentSlide*settings.eventsPerSlide), ((currentSlide+1)*settings.eventsPerSlide)).map(buildEvent)).appendTo(_this); - } - - var buildNavigation = function() { - var currentSlide = $this.data('currentSlide'); - - var buildNav = function(nav) { - switch (nav) { - case 'prev': - if ( currentSlide > 0 ) { - return $('
        1. ' + settings.prevArrow + '
        2. '); - } - break; - - case 'next': - if ( (currentSlide+1)*settings.eventsPerSlide < events.length ) { - return $('
        3. ' + settings.nextArrow + '
        4. '); - } - break; - } - - return $('
        5. '); - } - - $('
            ', {class: settings.rootClass + '__navigation'}).append(['prev', 'next'].map(buildNav)).appendTo(_this); - } - - var setOrientation = function() { - - var getOrientation = function() { - switch (settings.orientation) { - case 'horizontal': - case 'vertical': - case 'auto': - return settings.orientation; - break; - } - - return 'auto'; - } - - $this.addClass(settings.rootClass + '--orientation-' + getOrientation()); - } - - var build = function() { - - clear(); - - /** - * Init events - */ - buildEvents(); - - /** - * Init navigation - */ - buildNavigation(); - - /** - * Set orientation - */ - setOrientation(); - - /** - * Initialize - */ - setTimeout(function() { - $this.addClass(settings.rootClass + '--initialized'); - }, 100); - } - - /** - * Build roadmap - */ - build(); - - /** - * Event Listeners - */ - $('body').on('click', '.' + settings.rootClass + ' .' + settings.rootClass + '__navigation li > *', function(e) { - e.preventDefault(); - - /** - * Handle prev click - */ - if ( $(this).hasClass('prev') ) { - - var currentSlide = $this.data('currentSlide'); - if ( currentSlide < 1 ) { - return false; - } - - $this.data({ - events: events, - settings: settings, - currentSlide: currentSlide-1 - }); - - build(); - } - - /** - * Handle next click - */ - else { - - var currentSlide = $this.data('currentSlide'); - if ( (currentSlide+1)*settings.eventsPerSlide >= events.length ) { - return false; - } - - $this.data({ - events: events, - settings: settings, - currentSlide: currentSlide+1 - }); - - build(); - } - }); - - $(window).on('resize', function () { - $this.removeClass(settings.rootClass + '--initialized'); - build(); - }); - }); - }; - -})); \ No newline at end of file diff --git a/app/assets/stylesheets/jquery-roadmap.scss b/app/assets/stylesheets/jquery-roadmap.scss deleted file mode 100644 index 4708a4f92..000000000 --- a/app/assets/stylesheets/jquery-roadmap.scss +++ /dev/null @@ -1,381 +0,0 @@ -// Config -@import 'base/variables'; -@import 'base/mixins'; - -@mixin roadmap-default { - position: relative; - width: 95%; - margin: 0 auto; - - .roadmap__events { - position: relative; - width: calc(100% - 200px); - margin: 0 auto; - padding: 200px 0; - - &:after { - position: absolute; - top: 50%; - left: 0; - display: block; - content: ""; - width: 0%; - height: 4px; - background-color: $primary-color; - // box-shadow: 0 0 30px -1px rgba($primary-color, 0.2); - border-radius: 2px; - - transition: all 0.5s linear; - } - - &__event { - position: absolute; - width: 280px; - height: 200px; - margin-left: -140px; - list-style: none; - font-size: 16px; - - &:before, - &:after { - position: absolute; - content: ""; - display: block; - background-color: $primary-color; - // box-shadow: 0 0 30px -1px rgba($primary-color, 0.2); - - transition: all 0.3s $transition-function; - } - - &:before { - width: 20px; - height: 20px; - border-radius: 20px; - left: 50%; - transform: translateX(-50%); - transform: scale(0); - } - - &:after { - width: 4px; - // height: 62px; - height: 0; - border-radius: 2px; - left: 50%; - transform: translateX(-50%); - } - - .event { - position: absolute; - display: block; - text-align: center; - width: 100%; - - transition: all 0.3s $transition-function; - transform: scale(0); - - .event__date { - font-weight: 600; - } - - .event__content { - - small { - display: block; - } - } - } - - /** - * Events showing on the bottom of the timeline - */ - &:nth-child(odd) { - bottom: 0; - - &:before { - top: -8px; - } - - &:after { - top: 0; - } - - .event { - top: 80px; - } - } - - /** - * Events showing on the top of the timeline - */ - &:nth-child(even) { - top: 0; - - &:before { - bottom: -12px; - } - - &:after { - bottom: -4px; - } - - .event { - bottom: 80px; - } - } - - @for $i from 1 through 15 { - &:nth-child(#{$i}n) { - - &:before, - &:after, - .event { - transition-delay: #{$i * 0.13}s; - } - } - } - } - } - - .roadmap__navigation { - margin: 0; - - &>* { - position: absolute; - top: 50%; - transform: translateY(-46%); - z-index: 100; - list-style: none; - - a { - display: block; - color: #000; - line-height: 0; - - i { - font-size: 44px; - } - - &:hover { - text-decoration: none; - box-shadow: none; - } - } - - &:first-child { - left: 40px; - } - - &:last-child { - right: 40px; - } - } - - .prev {} - .next {} - } - - &.roadmap--initialized { - - .roadmap__events { - - &:after { - width: 100%; - } - - .roadmap__events__event { - - /** - * Dot - */ - &:before { - transform: scale(1) translateX(-50%); - } - - /** - * Line - */ - &:after { - height: 62px; - } - - .event { - transform: scale(1); - } - } - } - } -} - -@mixin roadmap-vertical { - margin: $gap*2 auto; - - .roadmap__events { - padding: 0; - width: 80%; - max-width: 640px; - min-height: 400px; - - &:after { - left: 50%; - top: 0; - width: 4px; - height: calc(0% - 0px); - transform: translateX(-50%); - } - - &__event { - position: relative; - left: auto !important; - top: auto; - bottom: auto; - margin-left: 0; - width: auto; - height: auto; - min-height: 120px; - - &:before { - top: -8px; - bottom: auto; - } - - &:after { - top: 0; - bottom: auto; - // width: 48px; - width: 0; - height: 4px !important; - } - - .event { - top: -15px; - bottom: auto; - width: 40%; - - @include sm-down { - width: 50%; - } - } - - /** - * Events showing on the left of the timeline - */ - &:nth-child(odd) { - - &:before {} - - &:after { - transform: translateX(-100%); - } - - .event { - @include sm-down { - margin-left: -10%; - } - } - } - - /** - * Events showing on the right of the timeline - */ - &:nth-child(even) { - - &:before { - // margin-left: -12px; - } - - &:after { - transform: translateX(0%); - } - - .event { - right: 0; - - @include sm-down { - margin-right: -10%; - } - } - } - } - } - - &.roadmap--initialized { - - .roadmap__events { - - &:after { - width: 4px; - height: calc(100% - 120px); - } - - .roadmap__events__event { - - /** - * Dot - */ - &:before {} - - /** - * Line - */ - &:after { - width: 48px; - - @include sm-down { - width: 32px; - } - } - - .event {} - - /** - * Events showing on the left of the timeline - */ - &:nth-child(odd) { - - &:before {} - - &:after { - transform: translateX(-100%); - } - - .event {} - } - - /** - * Events showing on the right of the timeline - */ - &:nth-child(even) { - - &:before {} - - &:after { - transform: translateX(0%); - } - - .event {} - } - } - } - } -} - -.roadmap { - - &.roadmap--orientation-auto { - @include roadmap-default; - - @include md-down { - @include roadmap-vertical; - } - } - - &.roadmap--orientation-horizontal { - @include roadmap-default; - } - - &.roadmap--orientation-vertical { - @include roadmap-default; - @include roadmap-vertical; - } -} \ No newline at end of file From 75f14aecc0203a2fbad03c9a1daf600d07cee838 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 30 Apr 2019 13:15:19 +1200 Subject: [PATCH 049/549] Crop page tidy --- app/assets/stylesheets/predictions.sass | 5 +- app/views/crops/_actions.html.haml | 11 ++-- app/views/crops/_crop.html.haml | 51 +++++++++------- app/views/crops/_predictions.html.haml | 81 ++++++++++++------------- app/views/crops/index.html.haml | 2 +- app/views/crops/search.html.haml | 5 +- app/views/crops/show.html.haml | 7 ++- app/views/home/index.html.haml | 5 +- app/views/seeds/_card.html.haml | 15 ++--- 9 files changed, 94 insertions(+), 88 deletions(-) diff --git a/app/assets/stylesheets/predictions.sass b/app/assets/stylesheets/predictions.sass index f33a8e73e..0cea3bdf2 100644 --- a/app/assets/stylesheets/predictions.sass +++ b/app/assets/stylesheets/predictions.sass @@ -1,6 +1,7 @@ .predictions - .prediction-metric + .predictions-card text-align: center + max-width: 200px border: 1px solid lighten($green, 20%) border-radius: 5% background: $white @@ -10,4 +11,4 @@ font-align: center h3 span - display: block \ No newline at end of file + display: block diff --git a/app/views/crops/_actions.html.haml b/app/views/crops/_actions.html.haml index 7b292e3d3..8060884d1 100644 --- a/app/views/crops/_actions.html.haml +++ b/app/views/crops/_actions.html.haml @@ -1,18 +1,17 @@ - if signed_in? - .crop-actions .btn-group - if can? :create, Planting - = link_to new_planting_path(crop_id: crop.id), class: 'btn btn-default' do + = link_to new_planting_path(crop_id: crop.id), class: 'btn btn-sm' do = planting_icon = t('buttons.plant_crop', crop_name: crop.name) - if can? :create, Harvest - = link_to new_harvest_path(crop_id: crop.id), class: 'btn btn-default' do + = link_to new_harvest_path(crop_id: crop.id), class: 'btn btn-sm' do = harvest_icon = t('buttons.harvest_crop', crop_name: crop.name) - + - if can? :create, Seed - = link_to new_seed_path(crop_id: crop.id), class: 'btn btn-default' do + = link_to new_seed_path(crop_id: crop.id), class: 'btn btn-sm' do = seed_icon - = t('buttons.add_seed_to_stash', crop_name: crop.name) + = t('buttons.save_seeds', crop_name: crop.name) diff --git a/app/views/crops/_crop.html.haml b/app/views/crops/_crop.html.haml index 87c04ec80..56f0443bd 100644 --- a/app/views/crops/_crop.html.haml +++ b/app/views/crops/_crop.html.haml @@ -1,34 +1,43 @@ -.well - .row - .col - = link_to image_tag(crop_image_path(crop), - alt: '', - class: 'img crop-image rounded'), - crop - .col - %h3{ style: 'padding-top: 0px; margin-top: 0px' } - = link_to crop, crop +.well.crop-thumbnail.row + .col + = link_to image_tag(crop_image_path(crop), + alt: '', + class: 'img crop-image rounded'), + crop + .col + %h3{ style: 'padding-top: 0px; margin-top: 0px' } + = link_to crop, crop - %p= crop.default_scientific_name - - if crop.annual? && crop.median_lifespan.present? - %p + + %p= crop.default_scientific_name + + - if crop.annual? && crop.median_lifespan.present? + %p + %small Median Lifespan %b= crop.median_lifespan days - - unless crop.median_days_to_first_harvest.nil? - %p + - unless crop.median_days_to_first_harvest.nil? + %p + %small First harvest expected %b= crop.median_days_to_first_harvest days after planting - - if crop.annual? && crop.median_days_to_last_harvest.present? - %p + - if crop.annual? && crop.median_days_to_last_harvest.present? + %p + %small Last harvest expected %b= crop.median_days_to_last_harvest days after planting - - if can? :create, Planting - = link_to "Plant #{crop.name}", new_planting_path(params: { crop_id: crop.id }), class: 'btn btn-primary' - -# - if can? :create, Seed - -# = link_to "Add #{crop.name} seeds to stash", new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-primary' + - if can? :create, Planting + = link_to new_planting_path(params: { crop_id: crop.id }), class: 'btn btn-sm' do + = planting_icon + -# "Plant #{crop.name}" + + - if can? :create, Seed + = link_to new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-sm' do + -# "Add #{crop.name} seeds to stash" + = seed_icon \ No newline at end of file diff --git a/app/views/crops/_predictions.html.haml b/app/views/crops/_predictions.html.haml index 60ec32f18..15625464e 100644 --- a/app/views/crops/_predictions.html.haml +++ b/app/views/crops/_predictions.html.haml @@ -1,50 +1,47 @@ %h3 Predictions -.predictions - .row - - unless crop.perennial.nil? - .col-md-3.col-xs-5 - .card - .card-body.text-center - %h3 - = link_to 'https://en.wikipedia.org/wiki/Annual_vs._perennial_plant_evolution' do - - if crop.perennial == true - Perennial - - elsif crop.perennial == false - Annual +.card-deck.mx-auto.predictions + - unless crop.perennial.nil? + .col + .card.predictions-card + .card-body.text-center + %h3 + = link_to 'https://en.wikipedia.org/wiki/Annual_vs._perennial_plant_evolution' do + - if crop.perennial == true + Perennial + - elsif crop.perennial == false + Annual - .d-flex.justify-content-between - %p.display-1 - %i.far.fa-calendar + %p.display-1 + %i.far.fa-calendar - - if crop.perennial == true - %small living more than two years - - elsif crop.perennial == false - %small living and reproducing in a single year or less + - if crop.perennial == true + %small living more than two years + - elsif crop.perennial == false + %small living and reproducing in a single year or less - - if crop.annual? && crop.median_lifespan.present? - .col-md-3.col-xs-5 - .card - .card-body.text-center - %h3 Median lifespan - .d-flex.justify-content-between - %p.display-1= crop.median_lifespan - %i.fas.fa-sun-o.fa-5x.pt-3.amber-text - %span days + - if crop.annual? && crop.median_lifespan.present? + .col + .card.predictions-card + .card-body.text-center + %h3 Median lifespan + %p.display-1= crop.median_lifespan + %i.fas.fa-sun-o.fa-5x.pt-3.amber-text + %span days - - if crop.median_days_to_first_harvest.present? - .col-md-3.col-xs-5 - .card - .card-body.text-center - %h3 First harvest expected - %p.display-1= crop.median_days_to_first_harvest - %span days after planting + - if crop.median_days_to_first_harvest.present? + .col + .card.predictions-card + .card-body.text-center + %h3 First harvest expected + %p.display-1= crop.median_days_to_first_harvest + %span days after planting - - if crop.annual? && crop.median_days_to_last_harvest.present? - .col-md-3.col-xs-5 - .card - .card-body.text-center - %h3 Last harvest expected - %p.display-1= crop.median_days_to_last_harvest - %span days after planting + - if crop.annual? && crop.median_days_to_last_harvest.present? + .col + .card.predictions-card + .card-body.text-center + %h3 Last harvest expected + %p.display-1= crop.median_days_to_last_harvest + %span days after planting diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml index 6e0258221..e826465d1 100644 --- a/app/views/crops/index.html.haml +++ b/app/views/crops/index.html.haml @@ -29,7 +29,7 @@ .pagination = will_paginate @crops -.card-row= render @crops +.card-deck.mx-auto= render @crops .pagination = will_paginate @crops diff --git a/app/views/crops/search.html.haml b/app/views/crops/search.html.haml index 468339bc8..470ae0366 100644 --- a/app/views/crops/search.html.haml +++ b/app/views/crops/search.html.haml @@ -28,10 +28,7 @@ .pagination = will_paginate @crops - #paginated_matches - .row - - @crops.each do |c| - .col-md-2.six-across= render partial: "thumbnail", locals: { crop: c } + .mx-auto= render @crops .pagination = will_paginate @crops diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 30bdb4cb4..5a178b72a 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -1,5 +1,4 @@ - content_for :title, @crop.name -- content_for :subtitle, @crop.default_scientific_name - content_for :opengraph do - @crop.photos.each do |photo| = tag("meta", property: "og:image", content: photo.fullsize_url) @@ -11,7 +10,11 @@ - content_for :scripts do = javascript_include_tag "charts" -= render partial: 'approval_status_message', locals: { crop: @crop } +%h1 + = @crop.name + %small= @crop.default_scientific_name + += render 'approval_status_message', crop: @crop - if @crop.approved? - content_for :buttonbar do diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 69df80fda..a884f4e26 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1,5 +1,8 @@ +- content_for :title do + ENV['GROWSTUFF_SITE_NAME'] + - if member_signed_in? - - content_for :title, t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) + %h1= t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) = render 'stats' - else diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index 4d07f4598..d805032d0 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -33,15 +33,12 @@ .card - .view.overlay - = link_to seed do - = image_tag(seed_image_path(seed, full_size: true), alt: seed, class: 'card-img-top img-responsive') - .card-body.p-3 - %h5.card-title.font-weight-bold.fuchsia-rose-text.mb-0 - = link_to seed, seed - %p - %i #{seed.owner.location} - %p Will trade #{seed.tradable_to} + = link_to seed do + = image_tag(seed_image_path(seed, full_size: true), alt: seed, class: 'card-img-top img-responsive') + .card-body + %span.badge.badge-pill.badge-secondary Will trade #{seed.tradable_to} + %h5.card-title= link_to seed, seed + %span.badge.badge-pill.badge-warning=seed.owner.location %p.float-right = link_to seed.owner do = image_tag(avatar_uri(seed.owner, 50), alt: '', class: 'img img-responsive avatar rounded') \ No newline at end of file From f5d48d1b568baac4b823ac055ddc54ab44045610 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 13 May 2019 07:52:38 +1200 Subject: [PATCH 050/549] Removing bootstrap 3 - only bootstrap 4 because both isn't particularly clever --- .ruby-version | 2 +- Gemfile | 7 +-- Gemfile.lock | 18 +++---- app/assets/stylesheets/application.sass | 6 ++- app/assets/stylesheets/crops.sass | 10 ++++ app/assets/stylesheets/graphs.sass | 2 - app/assets/stylesheets/homepage.sass | 12 +++-- app/assets/stylesheets/overrides.sass | 64 +++++++++++++++++-------- app/assets/stylesheets/variables.sass | 2 +- app/helpers/buttons_helper.rb | 10 +++- app/models/application_record.rb | 1 + app/views/comments/index.html.haml | 10 ++-- app/views/crops/_crop.html.haml | 61 +++++++++-------------- app/views/crops/_find_seeds.html.haml | 8 ++-- app/views/crops/_photos.html.haml | 2 +- app/views/crops/_posts.html.haml | 4 +- app/views/crops/_search_bar.haml | 13 +++-- app/views/crops/_thumbnail.html.haml | 25 ++++------ app/views/crops/index.html.haml | 7 +-- app/views/crops/search.html.haml | 10 ++-- app/views/crops/show.html.haml | 59 ++++++++++------------- app/views/harvests/_card.html.haml | 5 +- app/views/harvests/show.html.haml | 5 +- app/views/home/_crops.html.haml | 5 +- app/views/home/index.html.haml | 40 ++++++++-------- app/views/layouts/_header.html.haml | 8 ++-- app/views/layouts/_pagination.html.haml | 1 + app/views/layouts/application.html.haml | 15 +++--- app/views/members/_member.haml | 2 +- app/views/photos/new.html.haml | 25 +++++----- app/views/plantings/_card.html.haml | 6 +-- app/views/plantings/_facts.haml | 5 +- app/views/plantings/_photos.haml | 2 +- app/views/plantings/index.html.haml | 4 +- app/views/plantings/show.html.haml | 23 +++++---- app/views/seeds/_card.html.haml | 2 +- config/locales/en.yml | 1 + 37 files changed, 252 insertions(+), 230 deletions(-) create mode 100644 app/assets/stylesheets/crops.sass delete mode 100644 app/assets/stylesheets/graphs.sass create mode 100644 app/views/layouts/_pagination.html.haml diff --git a/.ruby-version b/.ruby-version index e70b4523a..ec1cf33c3 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.0 +2.6.3 diff --git a/Gemfile b/Gemfile index 59981cda5..38fff2a3c 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' -ruby '2.6.0' +ruby '2.6.3' gem 'rails', '5.2.2.1' @@ -16,13 +16,13 @@ gem 'sass-rails' gem 'jsonapi-resources' # CSS framework -gem 'bootstrap-sass' +# gem 'bootstrap-sass' gem 'bootstrap', '4.1.1' gem 'material-sass', '4.1.1' # icons gem 'font-awesome-sass' -gem 'material_icons' +gem 'material_design_icons' gem 'uglifier' # JavaScript compressor @@ -66,6 +66,7 @@ gem 'bluecloth' # Pagination gem 'will_paginate' +gem 'will_paginate-bootstrap4' # user signup/login/etc gem 'devise' diff --git a/Gemfile.lock b/Gemfile.lock index 65fc085e4..7163ca100 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -75,9 +75,6 @@ GEM bootstrap-kaminari-views (0.0.5) kaminari (>= 0.13) rails (>= 3.1) - bootstrap-sass (3.4.1) - autoprefixer-rails (>= 5.2.1) - sassc (>= 2.0.0) builder (3.2.3) bullet (6.0.0) activesupport (>= 3.0.0) @@ -237,6 +234,9 @@ GEM rails-i18n rainbow (>= 2.2.2, < 4.0) terminal-table (>= 1.5.1) + inline_svg (1.4.0) + activesupport (>= 3.0) + nokogiri (>= 1.6) isotope-rails (2.2.2) jquery-rails rails (>= 4.0) @@ -290,8 +290,8 @@ GEM material-sass (4.1.1) autoprefixer-rails (>= 6.0.3) sass (>= 3.5.2) - material_icons (2.2.1) - railties (>= 3.2) + material_design_icons (3.5.95) + inline_svg (~> 1.0) memcachier (0.0.2) method_source (0.9.2) mime-types (3.2.2) @@ -521,6 +521,8 @@ GEM websocket-extensions (>= 0.1.0) websocket-extensions (0.1.3) will_paginate (3.1.7) + will_paginate-bootstrap4 (0.2.2) + will_paginate (~> 3.0, >= 3.0.0) xmlrpc (0.3.0) xpath (3.2.0) nokogiri (~> 1.8) @@ -537,7 +539,6 @@ DEPENDENCIES bootstrap (= 4.1.1) bootstrap-datepicker-rails bootstrap-kaminari-views - bootstrap-sass bullet bundler (>= 1.1.5) byebug @@ -580,7 +581,7 @@ DEPENDENCIES listen loofah (>= 2.2.1) material-sass (= 4.1.1) - material_icons + material_design_icons memcachier newrelic_rpm oj @@ -616,10 +617,11 @@ DEPENDENCIES unicorn webrat will_paginate + will_paginate-bootstrap4 xmlrpc RUBY VERSION - ruby 2.6.0p0 + ruby 2.6.3p62 BUNDLED WITH 1.17.2 diff --git a/app/assets/stylesheets/application.sass b/app/assets/stylesheets/application.sass index 31588fd99..e3e81f50a 100644 --- a/app/assets/stylesheets/application.sass +++ b/app/assets/stylesheets/application.sass @@ -1,19 +1,21 @@ @import 'material' -@import 'material_icons' @import 'variables' @import 'overrides' +@import 'materialdesignicons' @import 'jquery-ui/autocomplete' @import 'bootstrap-datepicker' @import 'leaflet' @import 'leaflet.markercluster' -@import 'graphs' + @import 'predictions' @import 'plantings' @import 'members' @import 'harvests' @import 'seeds' +@import 'crops' + @import 'homepage' @import 'photos' diff --git a/app/assets/stylesheets/crops.sass b/app/assets/stylesheets/crops.sass new file mode 100644 index 000000000..896fa7050 --- /dev/null +++ b/app/assets/stylesheets/crops.sass @@ -0,0 +1,10 @@ +.planting + .crop-card + width: 100px + min-height: 300px + margin: 0.1em + height: 100% + + + .img-thumbnail + width: 100% \ No newline at end of file diff --git a/app/assets/stylesheets/graphs.sass b/app/assets/stylesheets/graphs.sass deleted file mode 100644 index cf47a7476..000000000 --- a/app/assets/stylesheets/graphs.sass +++ /dev/null @@ -1,2 +0,0 @@ -.bar rect:hover - fill: $graph-hover diff --git a/app/assets/stylesheets/homepage.sass b/app/assets/stylesheets/homepage.sass index 79512cd6c..bc0b46962 100644 --- a/app/assets/stylesheets/homepage.sass +++ b/app/assets/stylesheets/homepage.sass @@ -20,10 +20,16 @@ display: flex flex: none flex-wrap: wrap - padding: 1em + margin: 0.5em .card - max-width: 200px - margin: 1em + width: 200px + min-height: 100px + margin: 0.5em + padding: 0 + + %h3.crop-name + font-size: 2.0em + .thumbnail margin: 0.5em diff --git a/app/assets/stylesheets/overrides.sass b/app/assets/stylesheets/overrides.sass index fd6ffcf1f..ca9697fba 100644 --- a/app/assets/stylesheets/overrides.sass +++ b/app/assets/stylesheets/overrides.sass @@ -1,13 +1,24 @@ -@import "bootstrap-sprockets" -@import "bootstrap" +//@import "bootstrap-sprockets" +//@import "bootstrap" // this padding needs to be done before the responsive stuff is imported body - padding-top: $navbar-height + // padding-top: $navbar-height // Font Awesome @import "font-awesome-sprockets" @import "font-awesome" +a + color: $green +a:hover + color: $white + background-color: $green + +span.badge + background-color: $brown + a + color: $white + .list-inline > li.first padding-left: 0px @@ -24,18 +35,28 @@ h3 .main padding-right: 1em -.navbar .navbar-form - padding-top: 0 - padding-bottom: 0 - margin-right: 0 - margin-left: 15px - border: 0 - -webkit-box-shadow: none - box-shadow: none +// .navbar .navbar-form +// padding-top: 0 +// padding-bottom: 0 +// margin-right: 0 +// margin-left: 15px +// border: 0 +// -webkit-box-shadow: none +// box-shadow: none + +.img-square + object-fit: cover + height: 150px + width: 150px + +.img-card + object-fit: cover + height: 150px + width: 100% .img-responsive max-width: 100% - height: auto + .avatar border-radius: 50% @@ -248,8 +269,8 @@ footer a:active color: $navbar-default-link-active-color - .navbar-bottom.navbar - border-radius: 0 + //.navbar-bottom.navbar + // border-radius: 0 // ensure footer is pushed to bottom of browser window @@ -269,7 +290,7 @@ html, body // Autosuggest .ui-autocomplete background: white - z-index: $zindex-tooltip + //z-index: $zindex-tooltip .alert a @@ -333,7 +354,7 @@ ul.thumbnail-buttons .homepage-listing padding-bottom: 6px -@media (min-width: $screen-md-min) +@include media-breakpoint-up(md) .planting-thumbnail dl.planting-attributes width: 100% @@ -345,8 +366,8 @@ ul.thumbnail-buttons padding-left: 120px margin-left: auto - .navbar .navbar-form - width: 250px + //.navbar .navbar-form + // width: 250px .form-page text-align: center @@ -357,7 +378,7 @@ ul.thumbnail-buttons padding: 1em // Overrides applying only to mobile view. This must be at the end of the overrides file. -@media only screen and (max-width: 767px) +@include media-breakpoint-up(sm) .sidebar margin-left: 0 border-left: none @@ -370,9 +391,12 @@ ul.thumbnail-buttons display: block .navbar .navbar-form - width: 185px + //width: 185px padding-left: 0 padding-right: 0 + .navbar-search + width: auto + //.homepage // .thumbnail // height: 180px diff --git a/app/assets/stylesheets/variables.sass b/app/assets/stylesheets/variables.sass index c306fe18f..6b03469bd 100644 --- a/app/assets/stylesheets/variables.sass +++ b/app/assets/stylesheets/variables.sass @@ -1,7 +1,7 @@ // Use this file to override Twitter Bootstrap variables or define own variables. // Import original variables so they can be used in overrides -//@import 'bootstrap/variables.scss' +@import 'bootstrap/variables.scss' //$screen-md-min: 1028px // Base colours diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 491ee82bb..6dd45990c 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -19,6 +19,14 @@ module ButtonsHelper data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } end + def crop_plant_button(crop) + return unless can? :create, Planting + + link_to new_planting_path(params: { crop_id: crop.id }), class: 'btn btn-sm' do + planting_icon.html_safe + end + end + def crop_edit_button(crop) edit_button(edit_crop_path(crop)) end @@ -50,7 +58,7 @@ module ButtonsHelper def seed_finish_button(seed) return unless can?(:create, Planting) && seed.active? - + link_to seed_path(seed, seed: { finished: 1 }), method: :put, class: 'btn btn-default append-date' do finished_icon + ' ' + t('buttons.mark_as_finished') end diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 10a4cba84..31fc9c587 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,3 +1,4 @@ class ApplicationRecord < ActiveRecord::Base self.abstract_class = true + self.per_page = 12 end diff --git a/app/views/comments/index.html.haml b/app/views/comments/index.html.haml index d57c1c33b..c87781b16 100644 --- a/app/views/comments/index.html.haml +++ b/app/views/comments/index.html.haml @@ -1,8 +1,7 @@ = content_for :title, "Recent comments" -.pagination - = page_entries_info @comments - = will_paginate @comments += page_entries_info @comments += render 'layouts/pagination', collection: @comments - @comments.each do |comment| %h2 @@ -10,9 +9,8 @@ = link_to comment.post.subject, comment.post = render partial: "single", locals: { comment: comment } -.pagination - = page_entries_info @comments - = will_paginate @comments += page_entries_info @comments += render 'layouts/pagination', collection: @comments %p Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} diff --git a/app/views/crops/_crop.html.haml b/app/views/crops/_crop.html.haml index 56f0443bd..b4d2343cc 100644 --- a/app/views/crops/_crop.html.haml +++ b/app/views/crops/_crop.html.haml @@ -1,43 +1,28 @@ -.well.crop-thumbnail.row - .col - = link_to image_tag(crop_image_path(crop), - alt: '', - class: 'img crop-image rounded'), - crop - .col - %h3{ style: 'padding-top: 0px; margin-top: 0px' } - = link_to crop, crop - - - - %p= crop.default_scientific_name +.card.card-crop + .crop-image + = link_to image_tag(crop_image_path(crop, full_size: true), + alt: '', + class: 'img img-card'), + crop + .card-body + %h3.card-title= link_to crop, crop + %p.crop-sci-name= crop.default_scientific_name + .card-footer - if crop.annual? && crop.median_lifespan.present? - %p - %small - Median Lifespan - %b= crop.median_lifespan - days + %p.card-text + Median Lifespan + %b= crop.median_lifespan + days - unless crop.median_days_to_first_harvest.nil? - %p - %small - First harvest expected - %b= crop.median_days_to_first_harvest - days after planting + %p.card-text + First harvest expected + %b= crop.median_days_to_first_harvest + days after planting - if crop.annual? && crop.median_days_to_last_harvest.present? - %p - %small - Last harvest expected - %b= crop.median_days_to_last_harvest - days after planting - - - if can? :create, Planting - = link_to new_planting_path(params: { crop_id: crop.id }), class: 'btn btn-sm' do - = planting_icon - -# "Plant #{crop.name}" - - - if can? :create, Seed - = link_to new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-sm' do - -# "Add #{crop.name} seeds to stash" - = seed_icon \ No newline at end of file + %p.card-text + Last harvest expected + %b= crop.median_days_to_last_harvest + days after planting + = crop_plant_button(crop) diff --git a/app/views/crops/_find_seeds.html.haml b/app/views/crops/_find_seeds.html.haml index d05bf40c4..ea530ba71 100644 --- a/app/views/crops/_find_seeds.html.haml +++ b/app/views/crops/_find_seeds.html.haml @@ -12,17 +12,15 @@ = render partial: 'members/location', locals: { member: seed.owner } %p = link_to "View all #{crop.name} seeds", crop_seeds_path(crop) - .card-actions.flex-column + .card-footer.flex-column = link_to "Purchase seeds via Ebay", crop_ebay_seeds_url(crop), target: "_blank", - rel: "noopener noreferrer", - class: 'btn btn-outline-primary' + rel: "noopener noreferrer" - if crop.approved? - if current_member = link_to "List #{crop.name} seeds to trade", - new_seed_path(crop_id: crop.id), - class: 'btn btn-outline-primary' + new_seed_path(crop_id: crop.id) - else = render partial: 'shared/signin_signup', locals: { to: 'list your seeds to trade' } diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index 9960027f5..8d237275f 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -6,6 +6,6 @@ .row - photos.by_model(model_name).limit(6).each do |photo| .col-md-2.six-across - .thumbnail= link_to image_tag(photo.thumbnail_url, alt: photo.title, class: 'img'), photo + .thumbnail= link_to image_tag(photo.thumbnail_url, alt: photo.title, class: 'img img-square'), photo %p.text-right= link_to 'more photos »', crop_photos_path(@crop), class: 'btn' diff --git a/app/views/crops/_posts.html.haml b/app/views/crops/_posts.html.haml index 2d486e14e..2df22c34d 100644 --- a/app/views/crops/_posts.html.haml +++ b/app/views/crops/_posts.html.haml @@ -13,10 +13,10 @@ - else .pagination = page_entries_info @posts - = will_paginate @posts, params: { anchor: "posts" } + = render 'layouts/pagination', collection: @posts - @posts.each do |post| = render partial: "posts/single", locals: { post: post, subject: true } .pagination = page_entries_info @posts - = will_paginate @posts, params: { anchor: "posts" } \ No newline at end of file + = render 'layouts/pagination', collection: @posts \ No newline at end of file diff --git a/app/views/crops/_search_bar.haml b/app/views/crops/_search_bar.haml index 4c25ea530..6d0d412f7 100644 --- a/app/views/crops/_search_bar.haml +++ b/app/views/crops/_search_bar.haml @@ -1,8 +1,7 @@ = form_tag search_crops_path, method: :get, class: 'navbar-form navbar-left', id: 'navbar-search' do - = label_tag :term, "Search crop database:", class: 'sr-only' - .input.text-white - .input-group - = text_field_tag 'term', nil, class: 'search-query input-medium form-control', placeholder: t('.search_crops') - .input-group-btn - %button.btn.btn-default{ style: "height: 34px;" } - %span.glyphicon.glyphicon-search + .input-group.navbar-search + = label_tag :term, "Search crop database:", class: 'sr-only' + = text_field_tag 'term', nil, class: 'search-query input-medium form-control text-white', placeholder: t('crops.search') + .input-group-btn + %button.btn.btn-default{ style: "height: 34px;" } + %span.glyphicon.glyphicon-search diff --git a/app/views/crops/_thumbnail.html.haml b/app/views/crops/_thumbnail.html.haml index 93cf5a9a0..3b1988283 100644 --- a/app/views/crops/_thumbnail.html.haml +++ b/app/views/crops/_thumbnail.html.haml @@ -1,17 +1,10 @@ -- cache cache_key_for(Crop, crop.id) do - .thumbnail.card - .crop-thumbnail - = link_to image_tag(crop_image_path(crop), - alt: crop.name, class: 'img'), +.card.card-crop + .crop-image + = link_to image_tag(crop_image_path(crop, full_size: true), + alt: crop.name, + class: 'img img-card'), crop - .cropinfo - .cropname - = link_to crop.name, crop - - unless crop.scientific_names.empty? - .scientificname - = crop.scientific_names.first.name - - if crop.annual? && crop.median_lifespan.present? - .planting-lifespan - lifespan - %strong= crop.median_lifespan - days + + .card-body + %h3.text-center.crop-name= link_to crop, crop + %p.small.crop-sci-name.text-center= crop.default_scientific_name diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml index e826465d1..ac2dba563 100644 --- a/app/views/crops/index.html.haml +++ b/app/views/crops/index.html.haml @@ -26,10 +26,11 @@ class: 'form-control' = submit_tag "Show", class: 'btn btn-primary' -.pagination - = will_paginate @crops +.pagination= render 'layouts/pagination', collection: @crops -.card-deck.mx-auto= render @crops +.row + - @crops.each do |crop| + .col-md-2= render 'crops/thumbnail', crop: crop .pagination = will_paginate @crops diff --git a/app/views/crops/search.html.haml b/app/views/crops/search.html.haml index 470ae0366..b20273807 100644 --- a/app/views/crops/search.html.haml +++ b/app/views/crops/search.html.haml @@ -25,10 +25,10 @@ instead. - else - .pagination - = will_paginate @crops + = will_paginate @crops - .mx-auto= render @crops + .row + - @crops.each do |crop| + .col-md-2= render 'crops/thumbnail', crop: crop - .pagination - = will_paginate @crops + = will_paginate @crops diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 5a178b72a..70f41f93a 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -67,49 +67,42 @@ .col-md-3 = render 'wrangle', crop: @crop .card - .card-body + .crop-image = image_tag crop_image_path(@crop, full_size: true), - class: 'card-img-top img-responsive', - alt: 'photo of crop' + class: 'img-card', alt: 'photo of crop' + .card-header %h4 How to grow #{@crop.name.pluralize} + .card-body = render 'grown_for', crop: @crop = render 'planting_advice', crop: @crop - .card - %p - = link_to crop_plantings_path(@crop), class: 'card-link' do - View all #{@crop.name} plantings - (#{@crop.plantings.size}) - %p - = link_to crop_harvests_path(@crop) do - View all #{@crop.name} harvests - (#{@crop.harvests.size}) - %p - = link_to crop_seeds_path(@crop) do - View all #{@crop.name} seeds - (#{@crop.seeds.size}) + .card-footer + %p.card-text + = link_to crop_plantings_path(@crop), class: 'card-link' do + #{@crop.name} plantings + (#{@crop.plantings.size}) + %p.card-text + = link_to crop_harvests_path(@crop) do + #{@crop.name} harvests + (#{@crop.harvests.size}) + %p.card-text + = link_to crop_seeds_path(@crop) do + #{@crop.name} seeds + (#{@crop.seeds.size}) - - if member_signed_in? - %p - = link_to member_seeds_path(current_member, crop_slug: @crop.slug) do - = display_seed_availability(@current_member, @crop) + - if member_signed_in? + %p.card-text + = link_to member_seeds_path(current_member, crop_slug: @crop.slug) do + = display_seed_availability(@current_member, @crop) - - .well - = render 'scientific_names', crop: @crop - = render 'alternate_names', crop: @crop + = render 'scientific_names', crop: @crop + = render 'alternate_names', crop: @crop - if @crop.parent - .parent-crop + %hr/ + %p.parent-crop = @crop.name is a variety of - %span.chip - %img.chip-img{alt: "Chip Image", src: "/material/apple-touch-icon.png"}>/ - Chip Label - - = succeed "." do - = link_to @crop.parent, @crop.parent - = render 'crops/thumbnail', crop: @crop.parent - + = link_to @crop.parent, @crop.parent = render 'find_seeds', crop: @crop diff --git a/app/views/harvests/_card.html.haml b/app/views/harvests/_card.html.haml index 8f5a513d7..8e7c2f1ac 100644 --- a/app/views/harvests/_card.html.haml +++ b/app/views/harvests/_card.html.haml @@ -2,10 +2,9 @@ = link_to harvest do = image_tag harvest_image_path(harvest, full_size: true), alt: harvest, class: 'img-fluid card-img-top' .card-body.text-center - %h5.card-title + %h5 %strong= link_to "#{harvest.crop} #{harvest.plant_part}", harvest - %p.card-text - = link_to harvest.plant_part, harvest.plant_part + %span.badge.badge-pill.badge-info= link_to harvest.plant_part, harvest.plant_part - if harvest.planting.present? %p.card-text diff --git a/app/views/harvests/show.html.haml b/app/views/harvests/show.html.haml index 952d145fa..c59dfc9fd 100644 --- a/app/views/harvests/show.html.haml +++ b/app/views/harvests/show.html.haml @@ -49,5 +49,6 @@ .col-md-6= render @harvest.default_photo .col-md-6 = link_to 'View all photos >>', planting_photos_path(@harvest), class: 'pull-right' - - @harvest.photos.order(date_taken: :desc).limit(3).each do |photo| - = render('photos/thumbnail', photo: photo) \ No newline at end of file + .row + - @harvest.photos.order(date_taken: :desc).limit(3).each do |photo| + .col-md-3= render('photos/thumbnail', photo: photo) \ No newline at end of file diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml index 6b0feb9d7..6aabdc6db 100644 --- a/app/views/home/_crops.html.haml +++ b/app/views/home/_crops.html.haml @@ -1,5 +1,4 @@ - cache cache_key_for(Crop, 'homepage'), expires_in: 1.day do - .row - - Crop.interesting.includes(:scientific_names, :photos).shuffle.first(12).each do |crop| - .col.md-2= render crop + - Crop.interesting.includes(:scientific_names, :photos).shuffle.first(12).each do |crop| + = render 'crops/thumbnail', crop: crop diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index a884f4e26..a365850dd 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1,45 +1,43 @@ - content_for :title do - ENV['GROWSTUFF_SITE_NAME'] + = ENV['GROWSTUFF_SITE_NAME'] - if member_signed_in? %h1= t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) - = render 'stats' + %p= render 'stats' - else .hidden-xs .jumbotron= render 'blurb' .row - .col-md-8 - .homepage-cards.shadow - %h2= t('.our_crops') - .mx-auto= render 'crops' - .align-bottom - %p.text-right= link_to "#{t('home.crops.view_all')} »", crops_path, class: 'btn' - - cache cache_key_for(Crop, 'recent') do - .well - %h3= t('.recently_added') - != Crop.recent.limit(30).map { |c| link_to(c, c) }.join(", ") + .col-xl-8.col-md-12 + %h2= t('.our_crops') + .homepage-cards= render 'crops' + .align-bottom + %p.text-right= link_to "#{t('home.crops.view_all')} »", crops_path, class: 'btn' + - cache cache_key_for(Crop, 'recent') do + .well + %h3= t('.recently_added') + != Crop.recent.limit(30).map { |c| link_to(c, c) }.join(", ") .well %h2.text-center= t('.seeds_available_to_trade') - .row.homepage-cards + .homepage-cards .card-row.mx-auto= render Seed.current.tradable.recent.includes(:owner, :crop).limit(12), full: true .align-bottom %p.text-right= link_to "#{t('home.seeds.view_all')} »", seeds_path, class: 'btn' - .col-md-2 - %h2= t('.recently_planted') + .col-xl-2.col-md-6 + %h4.h4= t('.recently_planted') .row.homepage-thumbnails - = render Planting.has_photos.recent.includes(:crop, garden: :owner).limit(4), full: true + = render Planting.has_photos.recent.includes(:crop, garden: :owner).limit(3), full: true - .col-md-2 - %h2= t('.recently_harvested') + .col-xl-2.col-md-6 + %h4.h4= t('.recently_harvested') .row.homepage-thumbnails - = render Harvest.has_photos.recent.includes(:crop, :owner, :photos).limit(4), full: true + = render Harvest.has_photos.recent.includes(:crop, :owner, :photos).limit(3), full: true /.row= render 'discuss' -.row - .col-md-12.text-center= render 'members' += render 'members' diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 1fb12004a..0270cd280 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -1,4 +1,5 @@ -.navbar.navbar-default.navbar-fixed-top{ role: "navigation" } +-# .navbar.navbar-default.navbar-fixed-top{ role: "navigation" } +%nav.navbar.navbar-dark.default-color.bg-dark .container-fluid .navbar-header %button.navbar-toggle{"data-target" => ".navbar-responsive-collapse", "data-toggle" => "collapse", type: "button"} @@ -7,12 +8,11 @@ = image_tag("growstuff-brand.png", size: "200x50", alt: ENV['GROWSTUFF_SITE_NAME']) %a.navbar-brand.visible-xs{ href: root_path } = image_tag("growstuff-apple-touch-icon-precomposed.png", - size: "50x50", - class: "img-responsive", + size: "40x40", alt: ENV['GROWSTUFF_SITE_NAME']) + = render 'crops/search_bar' .navbar-collapse.collapse.navbar-responsive-collapse - = render 'crops/search_bar' %ul.nav.navbar-nav.navbar-right %li.dropdown< diff --git a/app/views/layouts/_pagination.html.haml b/app/views/layouts/_pagination.html.haml new file mode 100644 index 000000000..186c6b32e --- /dev/null +++ b/app/views/layouts/_pagination.html.haml @@ -0,0 +1 @@ += will_paginate collection, renderer: WillPaginate::ActionView::BootstrapLinkRenderer \ No newline at end of file diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 2555453dc..86aa1485b 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -7,17 +7,14 @@ = render partial: "layouts/header" -# anchor tag for accessibility link to skip the navigation menu %a{ name: 'skipnav' } - #maincontainer - = render 'shared/global_actions' - .row - .col-md-6 - - if content_for?(:buttonbar) - = yield(:buttonbar) + #maincontainer.container + .pull-right= render 'shared/global_actions' + - if content_for?(:buttonbar) + = yield(:buttonbar) - - if content_for?(:subtitle) - %small= yield(:subtitle) + - if content_for?(:subtitle) + %small= yield(:subtitle) - .col-md-6 .row .col-md-12 diff --git a/app/views/members/_member.haml b/app/views/members/_member.haml index ca7f08078..9b1ef3728 100644 --- a/app/views/members/_member.haml +++ b/app/views/members/_member.haml @@ -14,7 +14,7 @@ = distance_of_time_in_words(member.created_at, Time.zone.now) ago. %p - %ul.nav.md-pills.nav-justified.pills-pink.small + %ul.nav.md-pills.nav-justified.small %li.nav-item= link_to localize_plural(member.plantings, Planting), member_plantings_path(member) %li.nav-item= link_to localize_plural(member.harvests, Harvest), member_harvests_path(member) %li.nav-item= link_to localize_plural(member.seeds, Seed), member_seeds_path(member) diff --git a/app/views/photos/new.html.haml b/app/views/photos/new.html.haml index 31023b694..bac4952a9 100644 --- a/app/views/photos/new.html.haml +++ b/app/views/photos/new.html.haml @@ -23,20 +23,21 @@ = hidden_field_tag :id, @id = submit_tag "Search", class: 'btn btn-primary' - .pagination - = page_entries_info @photos - = will_paginate @photos + .row.pagination + .col-md-12= page_entries_info @photos + .col-md-12= render 'layouts/pagination', collection: @photos .row - - @photos.each do |p| - .col-md-2.six-across - .thumbnail{ style: 'height: 220px' } - = link_to image_tag(FlickRaw.url_q(p), alt: '', class: 'img'), - photos_path(photo: { flickr_photo_id: p.id }, type: @type, id: @id), - method: :post - %p - = p.title - + - @photos.each do |p| + .col-md-2.six-across + .thumbnail{ style: 'height: 220px' } + = link_to image_tag(FlickRaw.url_q(p), alt: '', class: 'img'), + photos_path(photo: { flickr_photo_id: p.id }, type: @type, id: @id), + method: :post + %p + = p.title + .row.pagination + .col-md-12= render 'layouts/pagination', collection: @photos - else .alert You must diff --git a/app/views/plantings/_card.html.haml b/app/views/plantings/_card.html.haml index 0241aae44..2455a34d7 100644 --- a/app/views/plantings/_card.html.haml +++ b/app/views/plantings/_card.html.haml @@ -1,6 +1,6 @@ .card = link_to planting do - = image_tag planting_image_path(planting, full_size: true), class: 'card-img-top img-fluid', alt: planting - .card-body.card-body-cascade.text-center - %h4.card-title + = image_tag planting_image_path(planting, full_size: true), class: 'img-card', alt: planting + .card-body.text-center + %h5 %strong= link_to planting, planting diff --git a/app/views/plantings/_facts.haml b/app/views/plantings/_facts.haml index e95afd56b..45cc28381 100644 --- a/app/views/plantings/_facts.haml +++ b/app/views/plantings/_facts.haml @@ -3,7 +3,10 @@ .fact.card %h3 Parent seed %strong - = link_to @planting.parent_seed, seed_path(@planting.parent_seed) + = link_to seed_path(planting.parent_seed) do + = seed_icon + %span=planting.parent_seed + - if planting.finished .fact.card.grid-sizer diff --git a/app/views/plantings/_photos.haml b/app/views/plantings/_photos.haml index a78ee55fc..00141c76f 100644 --- a/app/views/plantings/_photos.haml +++ b/app/views/plantings/_photos.haml @@ -3,7 +3,7 @@ = render 'photos/gallery', photos: photos - if can?(:edit, planting) && can?(:create, Photo) %p.text-right= add_photo_button(planting) - %hr + %p.text-right= link_to 'more photos', planting_photos_path(@planting), class: 'btn' - else %p No photos. - if can?(:edit, planting) && can?(:create, Photo) diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index c438d7403..03bb660af 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -11,13 +11,13 @@ .pagination = page_entries_info @plantings - = will_paginate @plantings + = render 'layouts/pagination', collection: @plantings .row= render(@plantings) || "empty_list" .pagination = page_entries_info @plantings - = will_paginate @plantings + = render 'layouts/pagination', collection: @plantings %ul.list-inline %li= t('.the_data_on_this_page_is_available_in_the_following_formats') diff --git a/app/views/plantings/show.html.haml b/app/views/plantings/show.html.haml index 3cd42d5e1..f8febae8a 100644 --- a/app/views/plantings/show.html.haml +++ b/app/views/plantings/show.html.haml @@ -15,21 +15,24 @@ .planting .row .col-md-8.col-xs-12 + %h2.h1= @planting = render 'facts', planting: @planting + - if @planting.description.present? + %hr/ + .card + .card-header + %h2 Notes + .card-body + :growstuff_markdown + #{strip_tags(@planting.description)} + %hr/ + = render 'plantings/photos', photos: @photos, planting: @planting .col-md-4.col-xs-12.pull-right = render 'plantings/owner', planting: @planting - .row - .col-md-8.col-xs-12 - - if @planting.description.present? - %h2 Notes - :growstuff_markdown - #{strip_tags(@planting.description)} - = render 'plantings/photos', photos: @photos, planting: @planting - %p.text-right= link_to 'more photos', planting_photos_path(@planting) - .col-md-4.col-xs-12.pull-right = render @planting.crop .row .col-md-12 + %hr/ = render 'plantings/harvests', planting: @planting - .col-md-12 + %hr/ = render 'plantings/descendants', planting: @planting diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index d805032d0..945d4209f 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -34,7 +34,7 @@ .card = link_to seed do - = image_tag(seed_image_path(seed, full_size: true), alt: seed, class: 'card-img-top img-responsive') + = image_tag(seed_image_path(seed, full_size: true), alt: seed, class: 'img-card') .card-body %span.badge.badge-pill.badge-secondary Will trade #{seed.tradable_to} %h5.card-title= link_to seed, seed diff --git a/config/locales/en.yml b/config/locales/en.yml index d1076dc0c..35884fb05 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -85,6 +85,7 @@ en: save_seeds: Save seeds write_blog_post: Write blog post crops: + search: Search crops index: subtitle: "%{crops_size} total" title: Browse Crops From ddaa4319ec289ae0c53f43e4afe1f925079bac98 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 13 May 2019 07:52:52 +1200 Subject: [PATCH 051/549] Fix time freezer for percy specs --- spec/features/percy/percy_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 0b64877b0..fd0e855c3 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -10,6 +10,8 @@ describe 'Test with visual testing', type: :feature, js: true do let(:gravatar2) { 'http://www.gravatar.com/avatar/353d83d3677b142520987e1936fd093c?size=150&default=identicon' } let!(:tomato) { FactoryBot.create :tomato, creator: someone_else } before do + # Freeze time, so we don't have variations in timestamps on the page + Timecop.freeze(Time.local(2019, 1, 1)) { chard: 'https://farm9.staticflickr.com/8516/8519911893_1759c28965_q.jpg', apple: 'https://farm5.staticflickr.com/4748/38932178855_6fe9bcdb48_q.jpg', @@ -29,8 +31,6 @@ describe 'Test with visual testing', type: :feature, js: true do harvest.photos << photo end - # Freeze time, so we don't have variations in timestamps on the page - Timecop.freeze(Time.local(2019, 1, 1)) end after { Timecop.return } From f47b22505c689b9e2df13af13ee19d6204376e00 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 13 May 2019 07:53:08 +1200 Subject: [PATCH 052/549] Comment out global actions until it is prettier --- app/views/shared/_global_actions.html.haml | 49 +++++++++++----------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 1efd4e4c6..5d9254622 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,28 +1,27 @@ -- if signed_in? - .row - .col-md-12 - %ul.nav.nav-tabs.pull-right#global-actions - %li.nav-item - = link_to member_gardens_path(member_slug: current_member.slug), class: 'nav-link' do - = garden_icon - = t('links.my_gardens') +-# - if signed_in? +-# .row +-# .col-md-12 +-# .btn-group +-# = link_to member_gardens_path(member_slug: current_member.slug), +-# class: 'btn btn-default' do +-# = garden_icon +-# -# = t('.my_gardens') +-# = link_to new_planting_path, +-# class: 'btn btn-default' do +-# = planting_icon +-# -# = t('plantings.plant') - %li.nav-item - = link_to new_planting_path, class: 'nav-link' do - = planting_icon - = t('plantings.plant') +-# = link_to new_harvest_path, +-# class: 'btn btn-default' do +-# = harvest_icon +-# -# = t('harvests.harvest') - %li.nav-item - = link_to new_harvest_path, class: 'nav-link' do - = harvest_icon - = t('harvests.harvest') +-# = link_to new_seed_path, +-# class: 'btn btn-default' do +-# = seed_icon +-# -# = t('buttons.save_seeds') - %li.nav-item - = link_to new_seed_path, class: 'nav-link' do - = seed_icon - = t('buttons.save_seeds') - - %li.nav-item - = link_to new_post_path, class: 'nav-link' do - = blog_icon - = t 'posts.write_blog' \ No newline at end of file +-# = link_to new_post_path, +-# class: 'btn btn-default' do +-# = blog_icon +-# -# = t 'posts.write_blog' \ No newline at end of file From 69531f232dc4517437c11ed3643f5b4a2d752e89 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Sun, 12 May 2019 19:56:07 +0000 Subject: [PATCH 053/549] [CodeFactor] Apply fixes --- app/helpers/buttons_helper.rb | 14 +++++++------- spec/factories/member.rb | 2 +- spec/features/percy/percy_spec.rb | 11 ++++------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 6dd45990c..5a4573fcf 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -8,15 +8,15 @@ module ButtonsHelper def garden_mark_active_button(garden) link_to t('buttons.mark_as_active'), - garden_path(garden, garden: { active: 1 }), - method: :put, class: 'btn' + garden_path(garden, garden: { active: 1 }), + method: :put, class: 'btn' end def garden_mark_inactive_button(garden) link_to t('buttons.mark_as_inactive'), - garden_path(garden, garden: { active: 0 }), - method: :put, class: 'btn', - data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } + garden_path(garden, garden: { active: 0 }), + method: :put, class: 'btn', + data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } end def crop_plant_button(crop) @@ -51,7 +51,7 @@ module ButtonsHelper return unless can?(:edit, planting) || planting.finished link_to planting_path(planting, planting: { finished: 1 }), - method: :put, class: 'btn btn-default btn-secondary append-date' do + method: :put, class: 'btn btn-default btn-secondary append-date' do finished_icon + ' ' + t('buttons.mark_as_finished') end end @@ -84,7 +84,7 @@ module ButtonsHelper return unless can?(:edit, model) && can?(:create, Photo) link_to new_photo_path(id: model.id, type: model_type_for_photo(model)), - class: "btn btn-default" do + class: "btn btn-default" do photo_icon + ' ' + t('buttons.add_photo') end end diff --git a/spec/factories/member.rb b/spec/factories/member.rb index 5d6abd712..9495aa4ec 100644 --- a/spec/factories/member.rb +++ b/spec/factories/member.rb @@ -7,7 +7,7 @@ FactoryBot.define do confirmed_at { Time.zone.now } show_email { false } bio { 'I love seeds' } - preferred_avatar_uri { 'http://www.gravatar.com/avatar/d021434aac03a7f7c7c0de60d07dad1c?size=150&default=identicon' } + preferred_avatar_uri { 'http://www.gravatar.com/avatar/d021434aac03a7f7c7c0de60d07dad1c?size=150&default=identicon' } # cropbot is needed for certain tests, eg. Crop.create_from_csv factory :cropbot do diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index fd0e855c3..8d56e3777 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -1,8 +1,6 @@ require 'rails_helper' describe 'Test with visual testing', type: :feature, js: true do - - let(:member) { FactoryBot.create :member, login_name: 'percy', preferred_avatar_uri: gravatar } let(:someone_else) { FactoryBot.create :member, login_name: 'ruby', preferred_avatar_uri: gravatar2 } @@ -30,7 +28,6 @@ describe 'Test with visual testing', type: :feature, js: true do harvest = FactoryBot.create :harvest, crop: crop, owner: owner harvest.photos << photo end - end after { Timecop.return } @@ -94,10 +91,10 @@ describe 'Test with visual testing', type: :feature, js: true do describe 'photos' do it 'loads photos#show' do photo = FactoryBot.create :photo, - title: 'look at my tomatoes', - owner: member, - fullsize_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_z.jpg', - thumbnail_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_q.jpg' + title: 'look at my tomatoes', + owner: member, + fullsize_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_z.jpg', + thumbnail_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_q.jpg' photo.plantings << FactoryBot.create(:planting, owner: member, crop: tomato) visit photo_path(photo) Percy.snapshot(page, name: "#{prefix}/photos#show") From e0294257856bad50a59422496a86ffd8972c0738 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 13 May 2019 07:58:05 +1200 Subject: [PATCH 054/549] Lint --- app/models/crop.rb | 10 +++++----- app/models/garden.rb | 18 +++++++++--------- app/models/member.rb | 28 ++++++++++++++-------------- app/models/photo.rb | 6 +++--- app/models/planting.rb | 2 +- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/app/models/crop.rb b/app/models/crop.rb index 51ba8c149..fa82bd50d 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -47,11 +47,11 @@ class Crop < ApplicationRecord validate :must_have_meaningful_reason_for_rejection ## Wikipedia urls are only necessary when approving a crop validates :en_wikipedia_url, - format: { - with: %r{\Ahttps?:\/\/en\.wikipedia\.org\/wiki\/[[:alnum:]%_\.()-]+\z}, - message: 'is not a valid English Wikipedia URL' - }, - if: :approved? + format: { + with: %r{\Ahttps?:\/\/en\.wikipedia\.org\/wiki\/[[:alnum:]%_\.()-]+\z}, + message: 'is not a valid English Wikipedia URL' + }, + if: :approved? #################################### # Elastic search configuration diff --git a/app/models/garden.rb b/app/models/garden.rb index fcbb32ea6..b45c5ed54 100644 --- a/app/models/garden.rb +++ b/app/models/garden.rb @@ -26,17 +26,17 @@ class Garden < ApplicationRecord validates :name, uniqueness: { scope: :owner_id } validates :name, - format: { - with: /\A\w+[\w ()]+\z/ - }, - length: { maximum: 255 } + format: { + with: /\A\w+[\w ()]+\z/ + }, + length: { maximum: 255 } validates :area, - numericality: { - only_integer: false, - greater_than_or_equal_to: 0 - }, - allow_nil: true + numericality: { + only_integer: false, + greater_than_or_equal_to: 0 + }, + allow_nil: true AREA_UNITS_VALUES = { "square metres" => "square metre", diff --git a/app/models/member.rb b/app/models/member.rb index 834989eef..175ee4a6c 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -54,8 +54,8 @@ class Member < ApplicationRecord # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, - :recoverable, :rememberable, :trackable, :validatable, - :confirmable, :lockable, :timeoutable, :omniauthable + :recoverable, :rememberable, :trackable, :validatable, + :confirmable, :lockable, :timeoutable, :omniauthable # set up geocoding geocoded_by :location @@ -69,18 +69,18 @@ class Member < ApplicationRecord # Requires acceptance of the Terms of Service validates :tos_agreement, acceptance: { allow_nil: true, accept: true } validates :login_name, - length: { - minimum: 2, maximum: 25, message: "should be between 2 and 25 characters long" - }, - exclusion: { - in: %w(growstuff admin moderator staff nearby), message: "name is reserved" - }, - format: { - with: /\A\w+\z/, message: "may only include letters, numbers, or underscores" - }, - uniqueness: { - case_sensitive: false - } + length: { + minimum: 2, maximum: 25, message: "should be between 2 and 25 characters long" + }, + exclusion: { + in: %w(growstuff admin moderator staff nearby), message: "name is reserved" + }, + format: { + with: /\A\w+\z/, message: "may only include letters, numbers, or underscores" + }, + uniqueness: { + case_sensitive: false + } # # Triggers diff --git a/app/models/photo.rb b/app/models/photo.rb index cd51d15b1..053581e77 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -9,9 +9,9 @@ class Photo < ApplicationRecord # creates a relationship for each assignee type PHOTO_CAPABLE.each do |type| has_many type.downcase.pluralize.to_s.to_sym, - through: :photographings, - source: :photographable, - source_type: type + through: :photographings, + source: :photographable, + source_type: type end default_scope { joins(:owner) } # Ensures the owner still exists diff --git a/app/models/planting.rb b/app/models/planting.rb index 9c4a59be5..5924ea2ef 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -45,7 +45,7 @@ class Planting < ApplicationRecord ## ## Delegations delegate :name, :en_wikipedia_url, :default_scientific_name, :plantings_count, - to: :crop, prefix: true + to: :crop, prefix: true ## ## Validations From 8db6d06283972ac095e74693fa38ef08fb682513 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 14 May 2019 20:36:20 +1200 Subject: [PATCH 055/549] Restoring colours --- app/assets/stylesheets/overrides.sass | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/overrides.sass b/app/assets/stylesheets/overrides.sass index ca9697fba..2cf6e88bb 100644 --- a/app/assets/stylesheets/overrides.sass +++ b/app/assets/stylesheets/overrides.sass @@ -2,6 +2,7 @@ //@import "bootstrap" // this padding needs to be done before the responsive stuff is imported body + background-color: $beige // padding-top: $navbar-height // Font Awesome @@ -88,6 +89,8 @@ h3 // let's condense the hero unit a little .jumbotron + background-color: darken($beige, 10%) + text-color: $white padding-top: 30px padding-bottom: 30px @@ -97,10 +100,6 @@ h3 padding: 0.5em text-align: center - p - - - // signup widget on homepage .jumbotron .signup background-color: lighten($green, 40%) From b7ac04fc451aefe801ab2b24c7187870a3b03246 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 14 May 2019 20:36:49 +1200 Subject: [PATCH 056/549] Restory homepage text --- app/views/home/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index a365850dd..a655efb89 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -11,7 +11,7 @@ .row .col-xl-8.col-md-12 - %h2= t('.our_crops') + %h2= t('.some_of_our_crops') .homepage-cards= render 'crops' .align-bottom %p.text-right= link_to "#{t('home.crops.view_all')} »", crops_path, class: 'btn' From e9013a57dd0ac66320fc26df1e6cf10a1ccbe2b1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 14 May 2019 21:00:34 +1200 Subject: [PATCH 057/549] more --- app/helpers/buttons_helper.rb | 10 +++++++++- app/views/crops/_crop.html.haml | 1 + app/views/crops/_photos.html.haml | 9 +++++---- app/views/crops/show.html.haml | 2 +- app/views/photos/_thumbnail.html.haml | 2 +- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 5a4573fcf..628799555 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -23,7 +23,15 @@ module ButtonsHelper return unless can? :create, Planting link_to new_planting_path(params: { crop_id: crop.id }), class: 'btn btn-sm' do - planting_icon.html_safe + planting_icon + ' ' + t('buttons.plant') + end + end + + def crop_save_seeds_button(crop) + return unless can?(:create, Seed) + + link_to new_seed_path(params: { crop_id: crop.id }), class: "btn btn-sm" do + seed_icon + ' ' + t('buttons.save_seeds') end end diff --git a/app/views/crops/_crop.html.haml b/app/views/crops/_crop.html.haml index b4d2343cc..ac7c6b694 100644 --- a/app/views/crops/_crop.html.haml +++ b/app/views/crops/_crop.html.haml @@ -26,3 +26,4 @@ %b= crop.median_days_to_last_harvest days after planting = crop_plant_button(crop) + = crop_save_seeds_button(crop) diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index 8d237275f..d998700a0 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -2,10 +2,11 @@ %h2 Photos - [Planting, Harvest, Seed].each do |model_name| - if photos.by_model(model_name).size.positive? - %h3 #{@crop.name} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} + %h3.text-right #{@crop.name} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} .row - - photos.by_model(model_name).limit(6).each do |photo| - .col-md-2.six-across - .thumbnail= link_to image_tag(photo.thumbnail_url, alt: photo.title, class: 'img img-square'), photo + - photos.by_model(model_name).limit(4).each do |photo| + /.thumbnail= link_to image_tag(photo.thumbnail_url, alt: photo.title, class: 'img img-square'), photo + %p.mx-auto= render 'photos/thumbnail', photo: photo %p.text-right= link_to 'more photos »', crop_photos_path(@crop), class: 'btn' + %hr/ diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 70f41f93a..574f7e6da 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -33,7 +33,7 @@ = render 'predictions', crop: @crop %hr/ - .well= render 'crops/photos', photos: @photos + = render 'crops/photos', photos: @photos .card-deck.text-center .col-md-4 diff --git a/app/views/photos/_thumbnail.html.haml b/app/views/photos/_thumbnail.html.haml index 003ab7a6d..01384ee67 100644 --- a/app/views/photos/_thumbnail.html.haml +++ b/app/views/photos/_thumbnail.html.haml @@ -1,6 +1,6 @@ .thumbnail .photo-thumbnail - = link_to image_tag(photo.thumbnail_url, alt: photo.title, class: 'img img-responsive'), photo + = link_to image_tag(photo.thumbnail_url, alt: photo.title, class: 'img img-responsive shadow'), photo .text %p = link_to photo.title, photo From b5c88d8f33a585454cbc21bdf4991a9137f4cd5b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 14 May 2019 21:08:23 +1200 Subject: [PATCH 058/549] set plant part in percy spec --- spec/features/percy/percy_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 8d56e3777..abb71f978 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -7,6 +7,7 @@ describe 'Test with visual testing', type: :feature, js: true do let(:gravatar) { 'http://www.gravatar.com/avatar/d021434aac03a7f7c7c0de60d07dad1c?size=150&default=identicon' } let(:gravatar2) { 'http://www.gravatar.com/avatar/353d83d3677b142520987e1936fd093c?size=150&default=identicon' } let!(:tomato) { FactoryBot.create :tomato, creator: someone_else } + let(:plant_part) { FactoryBot.create :plant_part, name: 'fruit' } before do # Freeze time, so we don't have variations in timestamps on the page Timecop.freeze(Time.local(2019, 1, 1)) @@ -25,7 +26,7 @@ describe 'Test with visual testing', type: :feature, js: true do thumbnail_url: "#{photo_url}_q.jpg", fullsize_url: "#{photo_url}_z.jpg") planting.photos << photo - harvest = FactoryBot.create :harvest, crop: crop, owner: owner + harvest = FactoryBot.create :harvest, crop: crop, owner: owner, plant_part: plant_part harvest.photos << photo end end From 2165dc4e17c0ea00e105dce5d967e4fce00c9c95 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 14 May 2019 21:13:06 +1200 Subject: [PATCH 059/549] Tidy --- app/views/plantings/_card.html.haml | 3 +-- app/views/seeds/_card.html.haml | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/plantings/_card.html.haml b/app/views/plantings/_card.html.haml index 2455a34d7..f02729e21 100644 --- a/app/views/plantings/_card.html.haml +++ b/app/views/plantings/_card.html.haml @@ -2,5 +2,4 @@ = link_to planting do = image_tag planting_image_path(planting, full_size: true), class: 'img-card', alt: planting .card-body.text-center - %h5 - %strong= link_to planting, planting + %h5= link_to planting.crop, planting diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index 945d4209f..da2a45203 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -38,7 +38,7 @@ .card-body %span.badge.badge-pill.badge-secondary Will trade #{seed.tradable_to} %h5.card-title= link_to seed, seed - %span.badge.badge-pill.badge-warning=seed.owner.location + %span.badge.badge-pill.badge-secondary=seed.owner.location %p.float-right = link_to seed.owner do = image_tag(avatar_uri(seed.owner, 50), alt: '', class: 'img img-responsive avatar rounded') \ No newline at end of file From 569e2bb9a33e213feced46d23f49095a56e0b1ce Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 15 May 2019 08:46:37 +1200 Subject: [PATCH 060/549] tidy up crops#show --- app/views/crops/_find_seeds.html.haml | 26 ++++----- app/views/crops/show.html.haml | 77 +++++++++++++++------------ app/views/seeds/_card.html.haml | 1 + 3 files changed, 58 insertions(+), 46 deletions(-) diff --git a/app/views/crops/_find_seeds.html.haml b/app/views/crops/_find_seeds.html.haml index ea530ba71..a24101751 100644 --- a/app/views/crops/_find_seeds.html.haml +++ b/app/views/crops/_find_seeds.html.haml @@ -1,26 +1,28 @@ .card + .card-header + %h5.card-title Find #{crop.name} seeds .card-body - %h4 Find #{crop.name} seeds - if crop.seeds.empty? %p There are no seeds available to trade on Growstuff right now. - else - %ul + %ul.list-group - crop.seeds.tradable.each do |seed| - %li + %li.list-group-item = link_to "#{seed.owner} will trade #{seed.tradable_to}.", seed_path(seed) = render partial: 'members/location', locals: { member: seed.owner } - %p - = link_to "View all #{crop.name} seeds", crop_seeds_path(crop) - .card-footer.flex-column - = link_to "Purchase seeds via Ebay", - crop_ebay_seeds_url(crop), - target: "_blank", - rel: "noopener noreferrer" + %p= link_to "View all #{crop.name} seeds", crop_seeds_path(crop) + + %ul.list-group + %li.list-group-item + = link_to "Purchase seeds via Ebay", + crop_ebay_seeds_url(crop), + target: "_blank", + rel: "noopener noreferrer" - if crop.approved? - if current_member - = link_to "List #{crop.name} seeds to trade", - new_seed_path(crop_id: crop.id) + %li.list-group-item + = link_to "List #{crop.name} seeds to trade", new_seed_path(crop_id: crop.id) - else = render partial: 'shared/signin_signup', locals: { to: 'list your seeds to trade' } diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 574f7e6da..6b28ada91 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -53,16 +53,15 @@ = pie_chart crop_harvested_for_path(@crop, format: :json), legend: "bottom" .varieties= render 'varieties', crop: @crop + + %h3 Crop Map + %p + Only plantings by members who have set their locations are shown on this map. + - if current_member && current_member.location.blank? + = link_to "Set your location.", edit_member_registration_path + #cropmap - .well - %h3 Crop Map - %p - Only plantings by members who have set their locations are shown on this map. - - if current_member && current_member.location.blank? - = link_to "Set your location.", edit_member_registration_path - #cropmap - - .well= render 'crops/posts', crop: @crop + = render 'crops/posts', crop: @crop .col-md-3 = render 'wrangle', crop: @crop @@ -70,55 +69,65 @@ .crop-image = image_tag crop_image_path(@crop, full_size: true), class: 'img-card', alt: 'photo of crop' - .card-header - %h4 How to grow #{@crop.name.pluralize} .card-body + %h4 How to grow #{@crop.name.pluralize} = render 'grown_for', crop: @crop = render 'planting_advice', crop: @crop - .card-footer - %p.card-text + - if @crop.parent + %hr/ + %p.parent-crop + = @crop.name + is a variety of + = link_to @crop.parent, @crop.parent + .list-group + .list-group-item.list-group-flush.d-flex.justify-content-between.align-items-center = link_to crop_plantings_path(@crop), class: 'card-link' do #{@crop.name} plantings - (#{@crop.plantings.size}) - %p.card-text + %span.badge.badge-primary.badge-pill=@crop.plantings.size + .list-group-item.d-flex.justify-content-between.align-items-center = link_to crop_harvests_path(@crop) do #{@crop.name} harvests - (#{@crop.harvests.size}) - %p.card-text + %span.badge.badge-primary.badge-pill=@crop.harvests.size + + .list-group-item.d-flex.justify-content-between.align-items-center = link_to crop_seeds_path(@crop) do #{@crop.name} seeds - (#{@crop.seeds.size}) + %span.badge.badge-primary.badge-pill=@crop.seeds.size - if member_signed_in? - %p.card-text + .list-group-item.d-flex.justify-content-between.align-items-center = link_to member_seeds_path(current_member, crop_slug: @crop.slug) do = display_seed_availability(@current_member, @crop) - = render 'scientific_names', crop: @crop - = render 'alternate_names', crop: @crop + .card-body + = render 'scientific_names', crop: @crop + = render 'alternate_names', crop: @crop + + %hr/ - - if @crop.parent - %hr/ - %p.parent-crop - = @crop.name - is a variety of - = link_to @crop.parent, @crop.parent = render 'find_seeds', crop: @crop - .well - %h4 Learn more about #{@crop.name.pluralize} - %ul - %li= link_to 'Wikipedia (English)', @crop.en_wikipedia_url, target: "_blank", rel: "noopener noreferrer" - %li + %hr/ + .card + .card-body + %h5.card-title Learn more about #{@crop.name.pluralize} + %h6.card-subtitle.mb-2.text-muted resources outside #{ENV['GROWSTUFF_SITE_NAME']} + + %ul.list-group.list-group-flush + %li.list-group-item + = link_to @crop.en_wikipedia_url, target: "_blank", rel: "noopener noreferrer" do + Wikipedia (English) + + %li.list-group-item = link_to "OpenFarm - Growing guide", "https://openfarm.cc/en/crops/#{CGI.escape @crop.name}", target: "_blank", rel: "noopener noreferrer" - %li + %li.list-group-item = link_to "Gardenate - Planting reminders", "http://www.gardenate.com/plant/#{CGI.escape @crop.name}", target: "_blank", rel: "noopener noreferrer" - if current_member && current_member.location - %li + %li.list-group-item = link_to "Google", 'http://www.google.com/search?q=' + CGI.escape(['Growing', @crop.name, diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index da2a45203..198e2f075 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -38,6 +38,7 @@ .card-body %span.badge.badge-pill.badge-secondary Will trade #{seed.tradable_to} %h5.card-title= link_to seed, seed + .card-footer %span.badge.badge-pill.badge-secondary=seed.owner.location %p.float-right = link_to seed.owner do From 0ee13c3320a0f8f6ea05b1bb9d6f13f4b5efd522 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 15 May 2019 09:32:27 +1200 Subject: [PATCH 061/549] Tidy up posts on crops#show --- app/views/crops/_find_seeds.html.haml | 3 +-- app/views/crops/_photos.html.haml | 6 +++--- app/views/crops/_posts.html.haml | 6 ++++-- app/views/crops/show.html.haml | 5 ++++- app/views/photos/_gallery.haml | 2 ++ app/views/photos/_thumbnail.html.haml | 5 ++--- app/views/posts/_preview.haml | 14 ++++++++++++++ 7 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 app/views/posts/_preview.haml diff --git a/app/views/crops/_find_seeds.html.haml b/app/views/crops/_find_seeds.html.haml index a24101751..4594f33ec 100644 --- a/app/views/crops/_find_seeds.html.haml +++ b/app/views/crops/_find_seeds.html.haml @@ -3,8 +3,7 @@ %h5.card-title Find #{crop.name} seeds .card-body - if crop.seeds.empty? - %p - There are no seeds available to trade on Growstuff right now. + %p There are no seeds available to trade on Growstuff right now. - else %ul.list-group - crop.seeds.tradable.each do |seed| diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index d998700a0..84a3445db 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -2,11 +2,11 @@ %h2 Photos - [Planting, Harvest, Seed].each do |model_name| - if photos.by_model(model_name).size.positive? - %h3.text-right #{@crop.name} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} + %h3 + %i #{@crop.name} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} .row - photos.by_model(model_name).limit(4).each do |photo| - /.thumbnail= link_to image_tag(photo.thumbnail_url, alt: photo.title, class: 'img img-square'), photo - %p.mx-auto= render 'photos/thumbnail', photo: photo + = render 'photos/thumbnail', photo: photo %p.text-right= link_to 'more photos »', crop_photos_path(@crop), class: 'btn' %hr/ diff --git a/app/views/crops/_posts.html.haml b/app/views/crops/_posts.html.haml index 2df22c34d..304eb6c82 100644 --- a/app/views/crops/_posts.html.haml +++ b/app/views/crops/_posts.html.haml @@ -15,8 +15,10 @@ = page_entries_info @posts = render 'layouts/pagination', collection: @posts - @posts.each do |post| - = render partial: "posts/single", locals: { post: post, subject: true } + -# = render partial: "posts/single", locals: { post: post, subject: true } + = render 'posts/preview', post: post .pagination = page_entries_info @posts - = render 'layouts/pagination', collection: @posts \ No newline at end of file + = render 'layouts/pagination', collection: @posts + diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 6b28ada91..ccac474aa 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -53,7 +53,7 @@ = pie_chart crop_harvested_for_path(@crop, format: :json), legend: "bottom" .varieties= render 'varieties', crop: @crop - + %h3 Crop Map %p Only plantings by members who have set their locations are shown on this map. @@ -82,15 +82,18 @@ .list-group .list-group-item.list-group-flush.d-flex.justify-content-between.align-items-center = link_to crop_plantings_path(@crop), class: 'card-link' do + = planting_icon #{@crop.name} plantings %span.badge.badge-primary.badge-pill=@crop.plantings.size .list-group-item.d-flex.justify-content-between.align-items-center = link_to crop_harvests_path(@crop) do + = harvest_icon #{@crop.name} harvests %span.badge.badge-primary.badge-pill=@crop.harvests.size .list-group-item.d-flex.justify-content-between.align-items-center = link_to crop_seeds_path(@crop) do + = seed_icon #{@crop.name} seeds %span.badge.badge-primary.badge-pill=@crop.seeds.size diff --git a/app/views/photos/_gallery.haml b/app/views/photos/_gallery.haml index 7c8090bce..31c0fb32c 100644 --- a/app/views/photos/_gallery.haml +++ b/app/views/photos/_gallery.haml @@ -4,3 +4,5 @@ .photo-grid-item = link_to photo do = render 'photos/thumbnail', photo: photo + - if photo.date_taken.present? + %small= I18n.l(photo.date_taken.to_date) diff --git a/app/views/photos/_thumbnail.html.haml b/app/views/photos/_thumbnail.html.haml index 01384ee67..1e7d0044d 100644 --- a/app/views/photos/_thumbnail.html.haml +++ b/app/views/photos/_thumbnail.html.haml @@ -1,6 +1,6 @@ .thumbnail .photo-thumbnail - = link_to image_tag(photo.thumbnail_url, alt: photo.title, class: 'img img-responsive shadow'), photo + = link_to image_tag(photo.thumbnail_url, alt: photo.title, class: 'img img-responsive rounded shadow'), photo .text %p = link_to photo.title, photo @@ -9,5 +9,4 @@ %i by = link_to photo.owner, photo.owner - - if photo.date_taken.present? - %small= I18n.l(photo.date_taken.to_date) + diff --git a/app/views/posts/_preview.haml b/app/views/posts/_preview.haml new file mode 100644 index 000000000..87c24456c --- /dev/null +++ b/app/views/posts/_preview.haml @@ -0,0 +1,14 @@ +%section + .row + .col-md-12 + .card.card-cascade.wider.reverse + .card-body.card-body-cascade.text-center + %h2.font-weight-bold + = link_to post.subject, post + %p + Written by + %strong= link_to post.author, post.author + + %p + :growstuff_markdown + #{ strip_tags post.body } From 2ef7c7df19fcab8433c3899e3eb18541635824eb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 15 May 2019 11:25:39 +1200 Subject: [PATCH 062/549] tidy more crops#show --- app/assets/stylesheets/overrides.sass | 4 +++ app/views/crops/_find_seeds.html.haml | 33 +++++++++++++--------- app/views/crops/_photos.html.haml | 6 ++-- app/views/crops/_predictions.html.haml | 4 ++- app/views/crops/show.html.haml | 26 +++++++++-------- app/views/home/_blurb.html.haml | 2 +- app/views/home/index.html.haml | 39 +++++++++++++++----------- app/views/posts/_preview.haml | 3 +- 8 files changed, 70 insertions(+), 47 deletions(-) diff --git a/app/assets/stylesheets/overrides.sass b/app/assets/stylesheets/overrides.sass index 2cf6e88bb..6447db516 100644 --- a/app/assets/stylesheets/overrides.sass +++ b/app/assets/stylesheets/overrides.sass @@ -3,12 +3,16 @@ // this padding needs to be done before the responsive stuff is imported body background-color: $beige + font-family: $font-family-sans-serif // padding-top: $navbar-height // Font Awesome @import "font-awesome-sprockets" @import "font-awesome" +section + padding-top: 1em + margin: 0 a color: $green a:hover diff --git a/app/views/crops/_find_seeds.html.haml b/app/views/crops/_find_seeds.html.haml index 4594f33ec..9db1b6f1b 100644 --- a/app/views/crops/_find_seeds.html.haml +++ b/app/views/crops/_find_seeds.html.haml @@ -1,27 +1,34 @@ .card .card-header %h5.card-title Find #{crop.name} seeds - .card-body - - if crop.seeds.empty? + - if crop.seeds.empty? + .card-body %p There are no seeds available to trade on Growstuff right now. - - else - %ul.list-group - - crop.seeds.tradable.each do |seed| - %li.list-group-item - = link_to "#{seed.owner} will trade #{seed.tradable_to}.", seed_path(seed) - = render partial: 'members/location', locals: { member: seed.owner } - %p= link_to "View all #{crop.name} seeds", crop_seeds_path(crop) + - else + %ul.list-group + - crop.seeds.tradable.each do |seed| + %li.list-group-item + = link_to "#{seed.owner} will trade #{seed.tradable_to}.", seed_path(seed) + = render 'members/location', member: seed.owner + %li.list-group-item.d-flex.justify-content-between.align-items-center + = link_to crop_seeds_path(crop) do + = seed_icon + View all #{crop.name} seeds + %span.badge.badge-primary.badge-pill=crop.seeds.size %ul.list-group %li.list-group-item - = link_to "Purchase seeds via Ebay", - crop_ebay_seeds_url(crop), + = link_to crop_ebay_seeds_url(crop), target: "_blank", - rel: "noopener noreferrer" + rel: "noopener noreferrer" do + = icon 'fas', 'money-check-alt' + Purchase seeds via Ebay - if crop.approved? - if current_member %li.list-group-item = link_to "List #{crop.name} seeds to trade", new_seed_path(crop_id: crop.id) - else - = render partial: 'shared/signin_signup', locals: { to: 'list your seeds to trade' } + %li.list-group-item.active + = icon 'fas', 'user' + = render partial: 'shared/signin_signup', locals: { to: 'list your seeds to trade' } diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index 84a3445db..016cf665b 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -1,5 +1,7 @@ - if @crop.photos.size.positive? - %h2 Photos + %h2 + = photo_icon + Photos - [Planting, Harvest, Seed].each do |model_name| - if photos.by_model(model_name).size.positive? %h3 @@ -8,5 +10,5 @@ - photos.by_model(model_name).limit(4).each do |photo| = render 'photos/thumbnail', photo: photo - %p.text-right= link_to 'more photos »', crop_photos_path(@crop), class: 'btn' + %p.text-right= link_to 'more photos »', crop_photos_path(@crop), class: 'btn btn-info' %hr/ diff --git a/app/views/crops/_predictions.html.haml b/app/views/crops/_predictions.html.haml index 15625464e..82df172df 100644 --- a/app/views/crops/_predictions.html.haml +++ b/app/views/crops/_predictions.html.haml @@ -1,4 +1,6 @@ -%h3 Predictions +%h3 + = icon 'fas', 'magic' + Predictions .card-deck.mx-auto.predictions - unless crop.perennial.nil? .col diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index ccac474aa..912e00047 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -54,7 +54,9 @@ .varieties= render 'varieties', crop: @crop - %h3 Crop Map + %h3 + = icon 'fas', 'map' + Crop Map %p Only plantings by members who have set their locations are shown on this map. - if current_member && current_member.location.blank? @@ -120,20 +122,22 @@ %ul.list-group.list-group-flush %li.list-group-item = link_to @crop.en_wikipedia_url, target: "_blank", rel: "noopener noreferrer" do + = icon 'fas', 'external-link-alt' Wikipedia (English) %li.list-group-item - = link_to "OpenFarm - Growing guide", "https://openfarm.cc/en/crops/#{CGI.escape @crop.name}", + = link_to "https://openfarm.cc/en/crops/#{CGI.escape @crop.name}", target: "_blank", - rel: "noopener noreferrer" + rel: "noopener noreferrer" do + = icon 'fas', 'external-link-alt' + OpenFarm - Growing guide %li.list-group-item - = link_to "Gardenate - Planting reminders", "http://www.gardenate.com/plant/#{CGI.escape @crop.name}", - target: "_blank", rel: "noopener noreferrer" + = link_to "http://www.gardenate.com/plant/#{CGI.escape @crop.name}", + target: "_blank", rel: "noopener noreferrer" do + = icon 'fas', 'external-link-alt' + Gardenate - Planting reminders - if current_member && current_member.location %li.list-group-item - = link_to "Google", - 'http://www.google.com/search?q=' + CGI.escape(['Growing', - @crop.name, - current_member.location].join(' ')), - target: "_blank", - rel: "noopener noreferrer" + = link_to 'http://www.google.com/search?q=' + CGI.escape(['Growing', @crop.name, current_member.location].join(' ')), target: "_blank", rel: "noopener noreferrer" do + = icon 'fas', 'external-link-alt' + Google diff --git a/app/views/home/_blurb.html.haml b/app/views/home/_blurb.html.haml index f4120ce64..ab1e27651 100644 --- a/app/views/home/_blurb.html.haml +++ b/app/views/home/_blurb.html.haml @@ -6,7 +6,7 @@ .col-md-4 .signup %p= t('.perks') - %p= link_to(t('.sign_up'), new_member_registration_path, class: 'btn btn-primary btn-lg') + %p= link_to(t('.sign_up'), new_member_registration_path, class: 'btn btn-success btn-lg') %p %small = t('.already_html', sign_in: link_to(t('.sign_in_linktext'), new_member_session_path)) diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index a655efb89..4e705f4f0 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -11,33 +11,38 @@ .row .col-xl-8.col-md-12 - %h2= t('.some_of_our_crops') - .homepage-cards= render 'crops' - .align-bottom - %p.text-right= link_to "#{t('home.crops.view_all')} »", crops_path, class: 'btn' - - cache cache_key_for(Crop, 'recent') do - .well + %section.crops + %h2= t('.some_of_our_crops') + .homepage-cards= render 'crops' + .align-bottom + %p.text-right= link_to "#{t('home.crops.view_all')} »", crops_path, class: 'btn' + - cache cache_key_for(Crop, 'recent') do %h3= t('.recently_added') != Crop.recent.limit(30).map { |c| link_to(c, c) }.join(", ") - .well + %section.seeds %h2.text-center= t('.seeds_available_to_trade') .homepage-cards .card-row.mx-auto= render Seed.current.tradable.recent.includes(:owner, :crop).limit(12), full: true .align-bottom %p.text-right= link_to "#{t('home.seeds.view_all')} »", seeds_path, class: 'btn' - .col-xl-2.col-md-6 - %h4.h4= t('.recently_planted') - .row.homepage-thumbnails - = render Planting.has_photos.recent.includes(:crop, garden: :owner).limit(3), full: true + .col-xl-4 + .row + .col-md-6 + %section.plantings + %h4.h4= t('.recently_planted') + .row.homepage-thumbnails + = render Planting.has_photos.recent.includes(:crop, garden: :owner).limit(3), full: true - .col-xl-2.col-md-6 - %h4.h4= t('.recently_harvested') - .row.homepage-thumbnails - = render Harvest.has_photos.recent.includes(:crop, :owner, :photos).limit(3), full: true + .col-md-6 + %section.harvests + %h4.h4= t('.recently_harvested') + .row.homepage-thumbnails + = render Harvest.has_photos.recent.includes(:crop, :owner, :photos).limit(3), full: true + + %section.members= render 'discuss' -/.row= render 'discuss' -= render 'members' +%section.members= render 'members' diff --git a/app/views/posts/_preview.haml b/app/views/posts/_preview.haml index 87c24456c..e6623a6c9 100644 --- a/app/views/posts/_preview.haml +++ b/app/views/posts/_preview.haml @@ -10,5 +10,4 @@ %strong= link_to post.author, post.author %p - :growstuff_markdown - #{ strip_tags post.body } + = truncate(strip_tags(post.body), length: 200) From 89ad44e5daf2dae8f46cbdb95fee026a6fd9d1ad Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 15 May 2019 11:25:59 +1200 Subject: [PATCH 063/549] Coloured button --- app/views/devise/registrations/new.html.haml | 2 +- app/views/devise/sessions/new.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index 5cb413d4d..5668b3b52 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -32,6 +32,6 @@ Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} newsletter %p= render partial: 'newsletter_blurb' - = f.submit "Sign up", class: 'btn btn-block my-4 btn-primary' + = f.submit "Sign up", class: 'btn btn-block my-4 btn-success' = render "devise/shared/links" diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index cb3764270..f9f7afed1 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -15,6 +15,6 @@ - if devise_mapping.recoverable? && controller_name != 'passwords' %p = link_to "Forgot password?", new_password_path(resource_name) - = f.submit "Sign in", class: 'btn btn-block my-4 btn-primary' + = f.submit "Sign in", class: 'btn btn-block my-4 btn-success' = render "devise/shared/links" From 599cc349b800d42f5c8f2d12729266eef11a6c49 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 16 May 2019 19:58:37 +1200 Subject: [PATCH 064/549] Home page tidy for plantings, harvests, and discussion --- app/assets/stylesheets/overrides.sass | 7 +++-- app/views/crops/_crop.html.haml | 7 +++-- app/views/home/_discuss.html.haml | 3 +- app/views/home/index.html.haml | 40 +++++++++++++++++++------ app/views/layouts/application.html.haml | 7 ++--- 5 files changed, 43 insertions(+), 21 deletions(-) diff --git a/app/assets/stylesheets/overrides.sass b/app/assets/stylesheets/overrides.sass index 6447db516..ff87e8255 100644 --- a/app/assets/stylesheets/overrides.sass +++ b/app/assets/stylesheets/overrides.sass @@ -75,8 +75,6 @@ h3 background: white padding: 2em margin-top: 2em - .container - width: 100% .sidebar border-left: 1px solid darken($beige, 10%) @@ -279,7 +277,7 @@ footer #maincontainer min-height: 80% - padding: 50px + //padding: 50px #global-actions padding-top: 10px @@ -357,6 +355,9 @@ ul.thumbnail-buttons .homepage-listing padding-bottom: 6px +.container + max-width: 1700px + @include media-breakpoint-up(md) .planting-thumbnail dl.planting-attributes diff --git a/app/views/crops/_crop.html.haml b/app/views/crops/_crop.html.haml index ac7c6b694..40bd4e508 100644 --- a/app/views/crops/_crop.html.haml +++ b/app/views/crops/_crop.html.haml @@ -8,7 +8,6 @@ .card-body %h3.card-title= link_to crop, crop %p.crop-sci-name= crop.default_scientific_name - .card-footer - if crop.annual? && crop.median_lifespan.present? %p.card-text Median Lifespan @@ -25,5 +24,7 @@ Last harvest expected %b= crop.median_days_to_last_harvest days after planting - = crop_plant_button(crop) - = crop_save_seeds_button(crop) + - if member_signed_in? + .card-footer + = crop_plant_button(crop) + = crop_save_seeds_button(crop) diff --git a/app/views/home/_discuss.html.haml b/app/views/home/_discuss.html.haml index 101b4c7e4..54d627214 100644 --- a/app/views/home/_discuss.html.haml +++ b/app/views/home/_discuss.html.haml @@ -19,12 +19,13 @@ .list-group - Post.order(created_at: :desc).limit(3).each do |post| - %a.list-group-item.list-group-item-action.flex-column.align-items-start{:href => post_path(post)} + = link_to post, class: 'list-group-item list-group-item-action flex-column align-items-start' do .d-flex.w-100.justify-content-between %h5.mb-2.h5= truncate(strip_tags(post.subject)) %small = time_ago_in_words(post.created_at) ago + = image_tag avatar_uri(post.author, 50), align: :right, class: 'avatar' %p.mb-2 = truncate(strip_tags(post.body), length: 200) %small diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 4e705f4f0..9d5df9bc1 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -30,18 +30,40 @@ .col-xl-4 .row - .col-md-6 + .col-6 %section.plantings - %h4.h4= t('.recently_planted') - .row.homepage-thumbnails - = render Planting.has_photos.recent.includes(:crop, garden: :owner).limit(3), full: true + %h5= t('.recently_planted') - .col-md-6 + - Planting.has_photos.recent.includes(:crop, garden: :owner).limit(3).each do |planting| + .card + = link_to planting, class: 'list-group-item list-group-item-action flex-column align-items-start' do + .d-flex.w-100.justify-content-between + %p.mb-2= image_tag planting_image_path(planting), width: 75 + %div + %h5.mb-2.h5 + = planting.crop.name + - if !planting.finished? && planting.finish_is_predicatable? + %span.badge.badge-success #{sprintf '%.0f', planting.percentage_grown}% + %small.text-muted + - if planting.planted_from.present? + = display_planting(planting) + + + + .col-6 %section.harvests - %h4.h4= t('.recently_harvested') - .row.homepage-thumbnails - = render Harvest.has_photos.recent.includes(:crop, :owner, :photos).limit(3), full: true - + %h5= t('.recently_harvested') + - Harvest.has_photos.recent.includes(:crop, :owner, :photos).limit(3).each do |harvest| + .card + = link_to harvest, class: 'list-group-item list-group-item-action flex-column align-items-start' do + .d-flex.w-100.justify-content-between + %div + %h5.mb-2.h5= harvest.crop.name + %span.badge.badge-success=harvest.plant_part + %small.text-muted=display_human_quantity(harvest) + %p.mb-2= image_tag harvest_image_path(harvest), width: 75 + + %section.members= render 'discuss' diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 86aa1485b..0362fca92 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -15,11 +15,8 @@ - if content_for?(:subtitle) %small= yield(:subtitle) - - .row - .col-md-12 - = render partial: "shared/flash_messages", flash: flash - = yield + = render partial: "shared/flash_messages", flash: flash + = yield %footer = render "layouts/footer" From e26fff6d237d303b60a6bf99cefb328ac7042149 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 16 May 2019 21:50:03 +1200 Subject: [PATCH 065/549] Add icon to find seeds --- app/views/crops/_find_seeds.html.haml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/crops/_find_seeds.html.haml b/app/views/crops/_find_seeds.html.haml index 9db1b6f1b..d13764f7c 100644 --- a/app/views/crops/_find_seeds.html.haml +++ b/app/views/crops/_find_seeds.html.haml @@ -27,7 +27,9 @@ - if crop.approved? - if current_member %li.list-group-item - = link_to "List #{crop.name} seeds to trade", new_seed_path(crop_id: crop.id) + = link_to new_seed_path(crop_id: crop.id) do + = seed_icon + List #{crop.name} seeds to trade - else %li.list-group-item.active = icon 'fas', 'user' From c999715ab0f21c786f170ae265b99965e69fb0a2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 16 May 2019 21:53:27 +1200 Subject: [PATCH 066/549] Restoring the nav bar --- app/views/layouts/_header.html.haml | 151 ++++++++++++++-------------- 1 file changed, 76 insertions(+), 75 deletions(-) diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 0270cd280..13cac3141 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -1,80 +1,81 @@ --# .navbar.navbar-default.navbar-fixed-top{ role: "navigation" } -%nav.navbar.navbar-dark.default-color.bg-dark - .container-fluid - .navbar-header - %button.navbar-toggle{"data-target" => ".navbar-responsive-collapse", "data-toggle" => "collapse", type: "button"} - %span.glyphicon.glyphicon-menu-hamburger.text-white - %a.navbar-brand.hidden-xs{ href: root_path } - = image_tag("growstuff-brand.png", size: "200x50", alt: ENV['GROWSTUFF_SITE_NAME']) - %a.navbar-brand.visible-xs{ href: root_path } - = image_tag("growstuff-apple-touch-icon-precomposed.png", - size: "40x40", - alt: ENV['GROWSTUFF_SITE_NAME']) - = render 'crops/search_bar' +%nav.navbar.navbar-expand-lg.navbar-dark.default-color.bg-dark + %a.navbar-brand.d-xs-none{ href: root_path } + = image_tag("growstuff-brand.png", size: "200x50", alt: ENV['GROWSTUFF_SITE_NAME']) + %a.navbar-brand.d-none.d-xs{ href: root_path } + = image_tag("growstuff-apple-touch-icon-precomposed.png", + size: "40x40", alt: ENV['GROWSTUFF_SITE_NAME']) + %button.navbar-toggler{"aria-controls" => "navbarSupportedContent", "aria-expanded" => "false", "aria-label" => "Toggle navigation", "data-target" => "#navbarSupportedContent", "data-toggle" => "collapse", type: "button"} + %span.navbar-toggler-icon + #navbarSupportedContent.collapse.navbar-collapse + %ul.navbar-nav.mr-auto + %li.nav-item.dropdown + %a.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :href => "#", :role => "button"}= t('.crops') + .dropdown-menu + -# %a.dropdown-item{:href => "#"} Action + -# %a.dropdown-item{:href => "#"} Another action + -# %a.dropdown-item{:href => "#"} Something else here + -# .dropdown-divider + -# %a.dropdown-item{:href => "#"} Separated link + = link_to t('.browse_crops'), crops_path, class: 'dropdown-item' + = link_to t('.seeds'), seeds_path, class: 'dropdown-item' + = link_to t('.plantings'), plantings_path, class: 'dropdown-item' + = link_to t('.harvests'), harvests_path, class: 'dropdown-item' - .navbar-collapse.collapse.navbar-responsive-collapse + %li.nav-item.dropdown + %a#navbarDropdown.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", href: "#", role: "button"}= t('.community') + .dropdown-menu{"aria-labelledby" => "navbarDropdown"} + = link_to t('.community_map'), places_path, class: 'dropdown-item' + = link_to t('.browse_members'), members_path, class: 'dropdown-item' + = link_to t('.posts'), posts_path, class: 'dropdown-item' + = link_to t('.forums'), forums_path, class: 'dropdown-item' - %ul.nav.navbar-nav.navbar-right - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path }= t('.crops') - %ul.dropdown-menu - %li= link_to t('.browse_crops'), crops_path - %li= link_to t('.seeds'), seeds_path - %li= link_to t('.plantings'), plantings_path - %li= link_to t('.harvests'), harvests_path - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: members_path } - = t('.community') - %ul.dropdown-menu - %li= link_to t('.community_map'), places_path - %li= link_to t('.browse_members'), members_path - %li= link_to t('.posts'), posts_path - %li= link_to t('.forums'), forums_path - - if member_signed_in? - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: root_path } - - if current_member.notifications.unread_count.positive? - = t('.your_stuff', unread_count: current_member.notifications.unread_count) - - else - = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) - %ul.dropdown-menu - %li - = link_to member_path(current_member) do - = member_icon - = t('.profile') - %li - = link_to member_gardens_path(current_member) do - = garden_icon - = t('.gardens') - %li - = link_to member_plantings_path(current_member) do - = planting_icon - = t('.plantings') - %li - = link_to member_harvests_path(current_member) do - = harvest_icon - = t('.harvest') - %li - = link_to member_seeds_path(current_member) do - = seed_icon - = t('.seeds') - %li= link_to t('.posts'), member_posts_path(current_member) - %li - - if current_member.notifications.unread_count.positive? - = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), - notifications_path) - - else - = link_to(t('.inbox'), notifications_path) - - if current_member.role?(:crop_wrangler) || current_member.role?(:admin) - %li.divider{ role: 'presentation' } - - if current_member.role?(:crop_wrangler) - %li= link_to t('.crop_wrangling'), wrangle_crops_path - - if current_member.role?(:admin) - %li= link_to t('.admin'), admin_path - %li= link_to t('.sign_out'), destroy_member_session_path, method: :delete + - if member_signed_in? + %li.nav-item.dropdown + %a#navbarDropdown.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", href: "#", role: "button"} + - if current_member.notifications.unread_count.positive? + = t('.your_stuff', unread_count: current_member.notifications.unread_count) + - else + = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) + .dropdown-menu{"aria-labelledby" => "navbarDropdown"} + = link_to member_path(current_member) do + = member_icon + = t('.profile') + = link_to member_gardens_path(current_member) do + = garden_icon + = t('.gardens') + = link_to member_plantings_path(current_member) do + = planting_icon + = t('.plantings') + = link_to member_harvests_path(current_member) do + = harvest_icon + = t('.harvest') + = link_to member_seeds_path(current_member) do + = seed_icon + = t('.seeds') + = link_to t('.posts'), member_posts_path(current_member) - - else - %li= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' - %li= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' + - if current_member.notifications.unread_count.positive? + = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), + notifications_path) + - else + = link_to(t('.inbox'), notifications_path) + - if current_member.role?(:crop_wrangler) || current_member.role?(:admin) + %li.divider{ role: 'presentation' } + - if current_member.role?(:crop_wrangler) + %li= link_to t('.crop_wrangling'), wrangle_crops_path + - if current_member.role?(:admin) + %li= link_to t('.admin'), admin_path + %li= link_to t('.sign_out'), destroy_member_session_path, method: :delete + + - else + = link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' + = link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' + + + = form_tag search_crops_path, method: :get, class: 'form-inline my-2 my-lg-0' do + .input-group + %input.form-control.mr-sm-2{name: 'term', "aria-label" => "Search", placeholder: "Search", type: "search"}/ + %button.btn.btn-default.text-white{type: "submit"}< + = icon 'fas', 'search' From 2cfcfffcccb48579f97321c850b751db22fa2e99 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 16 May 2019 21:53:46 +1200 Subject: [PATCH 067/549] tidy up sciname display on crops#show --- app/views/crops/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 912e00047..e99100022 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -81,7 +81,7 @@ = @crop.name is a variety of = link_to @crop.parent, @crop.parent - .list-group + .list-group.list-group-flush .list-group-item.list-group-flush.d-flex.justify-content-between.align-items-center = link_to crop_plantings_path(@crop), class: 'card-link' do = planting_icon From 3deb01d98377e65cc17b071bd64b069e3e6ef55e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 16 May 2019 21:53:55 +1200 Subject: [PATCH 068/549] Reduce max width --- app/assets/stylesheets/overrides.sass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/overrides.sass b/app/assets/stylesheets/overrides.sass index ff87e8255..07bf5371d 100644 --- a/app/assets/stylesheets/overrides.sass +++ b/app/assets/stylesheets/overrides.sass @@ -356,7 +356,7 @@ ul.thumbnail-buttons padding-bottom: 6px .container - max-width: 1700px + max-width: 1500px @include media-breakpoint-up(md) .planting-thumbnail From a65d2ba7b5e8aae543f22e9fe76f9b1f17af2eb6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 16 May 2019 21:57:12 +1200 Subject: [PATCH 069/549] Addings gardens#show to percy spec --- spec/features/percy/percy_spec.rb | 36 +++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index abb71f978..f545aeb1c 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -8,9 +8,18 @@ describe 'Test with visual testing', type: :feature, js: true do let(:gravatar2) { 'http://www.gravatar.com/avatar/353d83d3677b142520987e1936fd093c?size=150&default=identicon' } let!(:tomato) { FactoryBot.create :tomato, creator: someone_else } let(:plant_part) { FactoryBot.create :plant_part, name: 'fruit' } + + let(:tomato_photo) do + FactoryBot.create :photo, + title: 'look at my tomatoes', + owner: member, + fullsize_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_z.jpg', + thumbnail_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_q.jpg' + end before do # Freeze time, so we don't have variations in timestamps on the page Timecop.freeze(Time.local(2019, 1, 1)) + { chard: 'https://farm9.staticflickr.com/8516/8519911893_1759c28965_q.jpg', apple: 'https://farm5.staticflickr.com/4748/38932178855_6fe9bcdb48_q.jpg', @@ -70,8 +79,14 @@ describe 'Test with visual testing', type: :feature, js: true do Percy.snapshot(page, name: "#{prefix}/gardens#index") end - it 'load some one else\'s gardens#show' do - garden = FactoryBot.create :garden, name: 'paraside', owner: someone_else + it 'gardens#show' do + # a garden + garden = FactoryBot.create :garden, name: 'paraside', owner: member + #with some lettuce (finished) + FactoryBot.create :planting, crop: FactoryBot.create(:crop, name: 'lettuce'), garden: garden, owner: member, finished_at: 2.weeks.ago + #tomato still growing + tomato_planting = FactoryBot.create :planting, garden: garden, owner: member, crop: tomato + tomato_photo.plantings << tomato_planting visit garden_path(garden) Percy.snapshot(page, name: "#{prefix}/gardens#show") end @@ -89,15 +104,18 @@ describe 'Test with visual testing', type: :feature, js: true do end end + describe 'posts' do + let(:post) { FactoryBot.create :post, author: member } + it 'loads posts#show' do + visit post_path(post) + Percy.snapshot(page, name: "#{prefix}/posts#show") + end + end + describe 'photos' do it 'loads photos#show' do - photo = FactoryBot.create :photo, - title: 'look at my tomatoes', - owner: member, - fullsize_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_z.jpg', - thumbnail_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_q.jpg' - photo.plantings << FactoryBot.create(:planting, owner: member, crop: tomato) - visit photo_path(photo) + tomato_photo.plantings << FactoryBot.create(:planting, owner: member, crop: tomato) + visit photo_path(tomato_photo) Percy.snapshot(page, name: "#{prefix}/photos#show") end end From 758bfacb4fe371e064a5fe597b3673d286a9d280 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 16 May 2019 22:16:58 +1200 Subject: [PATCH 070/549] Restore title on photos#show page --- app/views/photos/show.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index cce196f5b..2d133168a 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -9,6 +9,7 @@ .row .col-md-8 + %h1.text-center=@photo.title %p.text-center = image_tag(@photo.fullsize_url, alt: @photo.title, class: 'rounded img-fluid shadow-sm') .col-md-4 From e21e5d59605b9d77d290d3c2ec4f577c1273d6e8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 16 May 2019 22:18:56 +1200 Subject: [PATCH 071/549] Fixed padding on photos#show --- app/views/photos/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 2d133168a..806284e6f 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -17,7 +17,7 @@ = render 'photos/actions', photo: @photo = link_to "View on Flickr", @photo.link_url, class: 'btn' - if @crops.size.positive? - = render @crops + %p= render @crops %p %i.fas.fa-camera-retro %strong Photo by From 4c0bca4b86abbc4fb3d0f3d69abccb94859f8d61 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 17 May 2019 09:49:57 +1200 Subject: [PATCH 072/549] Removing isotope we don't need it anymore --- Gemfile | 4 +--- Gemfile.lock | 6 +----- app/assets/javascripts/application.js | 1 - app/assets/javascripts/plantings.js | 8 -------- app/assets/stylesheets/crops.sass | 3 ++- 5 files changed, 4 insertions(+), 18 deletions(-) delete mode 100644 app/assets/javascripts/plantings.js diff --git a/Gemfile b/Gemfile index 38fff2a3c..2abe0470a 100644 --- a/Gemfile +++ b/Gemfile @@ -20,6 +20,7 @@ gem 'jsonapi-resources' gem 'bootstrap', '4.1.1' gem 'material-sass', '4.1.1' + # icons gem 'font-awesome-sass' gem 'material_design_icons' @@ -37,9 +38,6 @@ gem 'jquery-rails' gem 'jquery-ui-rails' gem 'js-routes' # provides access to Rails routes in Javascript -# Boostrap friendly layout for photo galleries -gem 'isotope-rails' - gem 'cancancan' # for checking member privileges gem 'csv_shaper' # CSV export gem 'figaro' # for handling config via ENV variables diff --git a/Gemfile.lock b/Gemfile.lock index fb4165865..53ac8eeb5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -237,9 +237,6 @@ GEM inline_svg (1.4.0) activesupport (>= 3.0) nokogiri (>= 1.6) - isotope-rails (2.2.2) - jquery-rails - rails (>= 4.0) jaro_winkler (1.5.2) jquery-rails (4.3.3) rails-dom-testing (>= 1, < 3) @@ -570,7 +567,6 @@ DEPENDENCIES haml_lint (>= 0.25.1) hashie (>= 3.5.3) i18n-tasks - isotope-rails jquery-rails jquery-ui-rails js-routes @@ -624,4 +620,4 @@ RUBY VERSION ruby 2.6.3p62 BUNDLED WITH - 1.17.2 + 1.17.3 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 02533a8b9..b60820bf7 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -21,5 +21,4 @@ // = require popper // = require bootstrap // = require material -// = require isotope // = require_tree . diff --git a/app/assets/javascripts/plantings.js b/app/assets/javascripts/plantings.js deleted file mode 100644 index 58da36b6c..000000000 --- a/app/assets/javascripts/plantings.js +++ /dev/null @@ -1,8 +0,0 @@ -$('.planting-facts').isotope({ - layoutMode: 'fitRows', - percentPosition: true, - itemSelector: '.fact', - fitRows: { - gutter: 10, - }, -}); diff --git a/app/assets/stylesheets/crops.sass b/app/assets/stylesheets/crops.sass index 896fa7050..ec288c6d6 100644 --- a/app/assets/stylesheets/crops.sass +++ b/app/assets/stylesheets/crops.sass @@ -7,4 +7,5 @@ .img-thumbnail - width: 100% \ No newline at end of file + width: 100% + From 42764602ffc256b170205abd8e45033b6c9628d8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 17 May 2019 09:50:25 +1200 Subject: [PATCH 073/549] Use flex instead of isotope --- app/assets/stylesheets/plantings.sass | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/plantings.sass b/app/assets/stylesheets/plantings.sass index a1709b17d..e19e0c5b7 100644 --- a/app/assets/stylesheets/plantings.sass +++ b/app/assets/stylesheets/plantings.sass @@ -46,19 +46,26 @@ dd margin-left: auto +.planting-facts + display: flex + flex: none + flex-wrap: wrap + margin: 0.5em .fact text-align: center - height: 180px + height: 160px width: 160px border: 1px solid lighten($green, 20%) border-radius: 5% background: $white padding: 1em - margin: 0.3em + margin: 0.5em + left: -0.5em strong font-size: 3em font-align: center h3 + padding-top: 1em span display: block img From c5c73767598f0b10f21d3499a460e563b2ed9b85 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 17 May 2019 10:09:29 +1200 Subject: [PATCH 074/549] Tidy up the small screen display of harvest and plantings on the homepage --- app/assets/stylesheets/homepage.sass | 2 ++ app/helpers/plantings_helper.rb | 2 +- app/views/home/_harvests.html.haml | 12 +++++++++ app/views/home/_plantings.html.haml | 13 ++++++++++ app/views/home/index.html.haml | 38 +++------------------------- 5 files changed, 32 insertions(+), 35 deletions(-) create mode 100644 app/views/home/_harvests.html.haml create mode 100644 app/views/home/_plantings.html.haml diff --git a/app/assets/stylesheets/homepage.sass b/app/assets/stylesheets/homepage.sass index bc0b46962..9c2b3a0c9 100644 --- a/app/assets/stylesheets/homepage.sass +++ b/app/assets/stylesheets/homepage.sass @@ -21,11 +21,13 @@ flex: none flex-wrap: wrap margin: 0.5em + left: -0.5em .card width: 200px min-height: 100px margin: 0.5em padding: 0 + left: -0.5em %h3.crop-name font-size: 2.0em diff --git a/app/helpers/plantings_helper.rb b/app/helpers/plantings_helper.rb index ffa271f43..537ae7631 100644 --- a/app/helpers/plantings_helper.rb +++ b/app/helpers/plantings_helper.rb @@ -25,7 +25,7 @@ module PlantingsHelper elsif planting.planted_from.present? "#{planting.owner} planted #{planting.planted_from.pluralize}." else - "#{planting.owner}." + "#{planting.owner} planted #{planting.crop}." end end diff --git a/app/views/home/_harvests.html.haml b/app/views/home/_harvests.html.haml new file mode 100644 index 000000000..fc2656ccb --- /dev/null +++ b/app/views/home/_harvests.html.haml @@ -0,0 +1,12 @@ +%section.harvests + %h5= t('.recently_harvested') + - Harvest.has_photos.recent.includes(:crop, :owner, :photos).limit(3).each do |harvest| + .card + = link_to harvest, class: 'list-group-item list-group-item-action flex-column align-items-start' do + .d-flex.w-100.justify-content-between + %div + %h5.mb-2.h5= harvest.crop.name + %span.badge.badge-success=harvest.plant_part + %small.text-muted + harvested by #{harvest.owner} + %p.mb-2= image_tag harvest_image_path(harvest), width: 75 \ No newline at end of file diff --git a/app/views/home/_plantings.html.haml b/app/views/home/_plantings.html.haml new file mode 100644 index 000000000..d96961b79 --- /dev/null +++ b/app/views/home/_plantings.html.haml @@ -0,0 +1,13 @@ +%section.plantings + %h5= t('.recently_planted') + + - Planting.has_photos.recent.includes(:crop, garden: :owner).limit(3).each do |planting| + .card + = link_to planting, class: 'list-group-item list-group-item-action flex-column align-items-start' do + .d-flex.w-100.justify-content-between + %p.mb-2= image_tag planting_image_path(planting), width: 75 + .text-right + %h5.mb-2.h5= planting.crop.name + - if planting.planted_from.present? + %span.badge.badge-success= planting.planted_from.pluralize + %small.text-muted= display_planting(planting) \ No newline at end of file diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 9d5df9bc1..0b1e6965b 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -10,7 +10,7 @@ .jumbotron= render 'blurb' .row - .col-xl-8.col-md-12 + .col-xl-7.col-md-12 %section.crops %h2= t('.some_of_our_crops') .homepage-cards= render 'crops' @@ -28,40 +28,10 @@ .align-bottom %p.text-right= link_to "#{t('home.seeds.view_all')} »", seeds_path, class: 'btn' - .col-xl-4 + .col-xl-5 .row - .col-6 - %section.plantings - %h5= t('.recently_planted') - - - Planting.has_photos.recent.includes(:crop, garden: :owner).limit(3).each do |planting| - .card - = link_to planting, class: 'list-group-item list-group-item-action flex-column align-items-start' do - .d-flex.w-100.justify-content-between - %p.mb-2= image_tag planting_image_path(planting), width: 75 - %div - %h5.mb-2.h5 - = planting.crop.name - - if !planting.finished? && planting.finish_is_predicatable? - %span.badge.badge-success #{sprintf '%.0f', planting.percentage_grown}% - %small.text-muted - - if planting.planted_from.present? - = display_planting(planting) - - - - .col-6 - %section.harvests - %h5= t('.recently_harvested') - - Harvest.has_photos.recent.includes(:crop, :owner, :photos).limit(3).each do |harvest| - .card - = link_to harvest, class: 'list-group-item list-group-item-action flex-column align-items-start' do - .d-flex.w-100.justify-content-between - %div - %h5.mb-2.h5= harvest.crop.name - %span.badge.badge-success=harvest.plant_part - %small.text-muted=display_human_quantity(harvest) - %p.mb-2= image_tag harvest_image_path(harvest), width: 75 + .col-md-6.col-sm-12=render 'plantings' + .col-md-6.col-sm-12= render 'harvests' %section.members= render 'discuss' From 8d451b968780dcfc5797a8c53048c871123dfbee Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 17 May 2019 11:06:29 +1200 Subject: [PATCH 075/549] Only show tradeable badge is actually tradeable --- app/views/seeds/_card.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index 198e2f075..fe59c0cbd 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -36,8 +36,9 @@ = link_to seed do = image_tag(seed_image_path(seed, full_size: true), alt: seed, class: 'img-card') .card-body - %span.badge.badge-pill.badge-secondary Will trade #{seed.tradable_to} %h5.card-title= link_to seed, seed + - if seed.tradable? + %span.badge.badge-pill.badge-secondary Will trade #{seed.tradable_to} .card-footer %span.badge.badge-pill.badge-secondary=seed.owner.location %p.float-right From d55af1b77d7d7578bb44fd21831b290d5e603925 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 17 May 2019 11:53:32 +1200 Subject: [PATCH 076/549] Fix droppdown/dropup menus --- app/assets/javascripts/application.js | 2 +- app/assets/javascripts/nav.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/nav.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index b60820bf7..c3ca8e29f 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -13,12 +13,12 @@ // = require leaflet // = require leaflet.markercluster // = require js-routes +// = require popper // = require jquery // = require jquery_ujs // = require jquery-ui/widgets/autocomplete // = require bootstrap-sprockets // = require bootstrap-datepicker -// = require popper // = require bootstrap // = require material // = require_tree . diff --git a/app/assets/javascripts/nav.js b/app/assets/javascripts/nav.js new file mode 100644 index 000000000..34ce99672 --- /dev/null +++ b/app/assets/javascripts/nav.js @@ -0,0 +1 @@ +$('.dropdown-toggle').dropdown() \ No newline at end of file From 83be51691804a3470111b15a28c118b7c91188ed Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 17 May 2019 11:53:43 +1200 Subject: [PATCH 077/549] Align crop photos better --- app/assets/stylesheets/crops.sass | 2 ++ app/views/crops/_photos.html.haml | 27 ++++++++++++++------------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/assets/stylesheets/crops.sass b/app/assets/stylesheets/crops.sass index ec288c6d6..b5cc39b5e 100644 --- a/app/assets/stylesheets/crops.sass +++ b/app/assets/stylesheets/crops.sass @@ -9,3 +9,5 @@ .img-thumbnail width: 100% +.crop-photos + margin-left: 3em \ No newline at end of file diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index 016cf665b..a32ef2099 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -1,14 +1,15 @@ -- if @crop.photos.size.positive? - %h2 - = photo_icon - Photos - - [Planting, Harvest, Seed].each do |model_name| - - if photos.by_model(model_name).size.positive? - %h3 - %i #{@crop.name} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} - .row - - photos.by_model(model_name).limit(4).each do |photo| - = render 'photos/thumbnail', photo: photo +.crop-photos + - if @crop.photos.size.positive? + %h2 + = photo_icon + Photos + - [Planting, Harvest, Seed].each do |model_name| + - if photos.by_model(model_name).size.positive? + %h3 + %i #{@crop.name} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} + .row + - photos.by_model(model_name).limit(4).each do |photo| + = render 'photos/thumbnail', photo: photo - %p.text-right= link_to 'more photos »', crop_photos_path(@crop), class: 'btn btn-info' - %hr/ + %p.text-right= link_to 'more photos »', crop_photos_path(@crop), class: 'btn btn-info' + %hr/ From 0b9a0609bcedb1081fc5ee88654c5fafa532549b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 17 May 2019 11:54:39 +1200 Subject: [PATCH 078/549] Pretty shadows on photos --- app/views/gardens/show.html.haml | 2 +- app/views/home/_harvests.html.haml | 2 +- app/views/home/_plantings.html.haml | 2 +- app/views/members/_avatar.html.haml | 2 +- app/views/members/_member.haml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index e89c739e7..5d7349e7b 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -48,7 +48,7 @@ - if @current_plantings.size.positive? - @current_plantings.each do |planting| .col-xs-12.col-md-6 - = render partial: "plantings/card", locals: { planting: planting } + = render "plantings/card", planting: planting - else .col-md-12 %p Nothing is currently planted here. diff --git a/app/views/home/_harvests.html.haml b/app/views/home/_harvests.html.haml index fc2656ccb..e83a7698e 100644 --- a/app/views/home/_harvests.html.haml +++ b/app/views/home/_harvests.html.haml @@ -9,4 +9,4 @@ %span.badge.badge-success=harvest.plant_part %small.text-muted harvested by #{harvest.owner} - %p.mb-2= image_tag harvest_image_path(harvest), width: 75 \ No newline at end of file + %p.mb-2= image_tag harvest_image_path(harvest), width: 75, class: 'rounded shadow' \ No newline at end of file diff --git a/app/views/home/_plantings.html.haml b/app/views/home/_plantings.html.haml index d96961b79..ecbcc23de 100644 --- a/app/views/home/_plantings.html.haml +++ b/app/views/home/_plantings.html.haml @@ -5,7 +5,7 @@ .card = link_to planting, class: 'list-group-item list-group-item-action flex-column align-items-start' do .d-flex.w-100.justify-content-between - %p.mb-2= image_tag planting_image_path(planting), width: 75 + %p.mb-2= image_tag planting_image_path(planting), width: 75, class: 'rounded shadow' .text-right %h5.mb-2.h5= planting.crop.name - if planting.planted_from.present? diff --git a/app/views/members/_avatar.html.haml b/app/views/members/_avatar.html.haml index 484b8575a..a576186d9 100644 --- a/app/views/members/_avatar.html.haml +++ b/app/views/members/_avatar.html.haml @@ -1,4 +1,4 @@ = link_to image_tag(avatar_uri(member, 150), alt: member, - class: 'img img-responsive avatar mr-3'), + class: 'img img-responsive avatar mr-3 shadow'), member_path(member) diff --git a/app/views/members/_member.haml b/app/views/members/_member.haml index 9b1ef3728..69d879f7c 100644 --- a/app/views/members/_member.haml +++ b/app/views/members/_member.haml @@ -2,7 +2,7 @@ .card.text-center .avatar.mx-auto = link_to member do - = image_tag(avatar_uri(member, 150), class: 'rounded-circle img-fluid', alt: member) + = image_tag(avatar_uri(member, 150), class: 'rounded-circle img-fluid shadow member-avatar', alt: member) .card-body / Name %h4.card-title From 707dc2e15686ddc50bbffbdd7e03b3fb594d433b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 17 May 2019 11:54:49 +1200 Subject: [PATCH 079/549] Fix display of member menu --- app/views/layouts/_header.html.haml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 13cac3141..c493063d4 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -11,11 +11,6 @@ %li.nav-item.dropdown %a.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :href => "#", :role => "button"}= t('.crops') .dropdown-menu - -# %a.dropdown-item{:href => "#"} Action - -# %a.dropdown-item{:href => "#"} Another action - -# %a.dropdown-item{:href => "#"} Something else here - -# .dropdown-divider - -# %a.dropdown-item{:href => "#"} Separated link = link_to t('.browse_crops'), crops_path, class: 'dropdown-item' = link_to t('.seeds'), seeds_path, class: 'dropdown-item' = link_to t('.plantings'), plantings_path, class: 'dropdown-item' @@ -38,19 +33,19 @@ - else = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) .dropdown-menu{"aria-labelledby" => "navbarDropdown"} - = link_to member_path(current_member) do + = link_to member_path(current_member), class: 'dropdown-item' do = member_icon = t('.profile') - = link_to member_gardens_path(current_member) do + = link_to member_gardens_path(current_member), class: 'dropdown-item' do = garden_icon = t('.gardens') - = link_to member_plantings_path(current_member) do + = link_to member_plantings_path(current_member), class: 'dropdown-item' do = planting_icon = t('.plantings') - = link_to member_harvests_path(current_member) do + = link_to member_harvests_path(current_member), class: 'dropdown-item' do = harvest_icon = t('.harvest') - = link_to member_seeds_path(current_member) do + = link_to member_seeds_path(current_member), class: 'dropdown-item' do = seed_icon = t('.seeds') = link_to t('.posts'), member_posts_path(current_member) From a21366a098be1f23a0a8c73653cf8677db80694b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 17 May 2019 12:18:36 +1200 Subject: [PATCH 080/549] fix icons on header nav --- Gemfile | 3 ++- Gemfile.lock | 9 +++------ app/assets/stylesheets/application.sass | 2 +- app/views/layouts/_header.html.haml | 26 +++++++++++-------------- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/Gemfile b/Gemfile index 2abe0470a..2e890b014 100644 --- a/Gemfile +++ b/Gemfile @@ -20,10 +20,11 @@ gem 'jsonapi-resources' gem 'bootstrap', '4.1.1' gem 'material-sass', '4.1.1' +# Icons used by bootstrap/material-sass +gem 'material_icons' # icons gem 'font-awesome-sass' -gem 'material_design_icons' gem 'uglifier' # JavaScript compressor diff --git a/Gemfile.lock b/Gemfile.lock index 53ac8eeb5..37f02b6a8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -234,9 +234,6 @@ GEM rails-i18n rainbow (>= 2.2.2, < 4.0) terminal-table (>= 1.5.1) - inline_svg (1.4.0) - activesupport (>= 3.0) - nokogiri (>= 1.6) jaro_winkler (1.5.2) jquery-rails (4.3.3) rails-dom-testing (>= 1, < 3) @@ -287,8 +284,8 @@ GEM material-sass (4.1.1) autoprefixer-rails (>= 6.0.3) sass (>= 3.5.2) - material_design_icons (3.5.95) - inline_svg (~> 1.0) + material_icons (2.2.1) + railties (>= 3.2) memcachier (0.0.2) method_source (0.9.2) mime-types (3.2.2) @@ -577,7 +574,7 @@ DEPENDENCIES listen loofah (>= 2.2.1) material-sass (= 4.1.1) - material_design_icons + material_icons memcachier newrelic_rpm oj diff --git a/app/assets/stylesheets/application.sass b/app/assets/stylesheets/application.sass index e3e81f50a..cba18af5c 100644 --- a/app/assets/stylesheets/application.sass +++ b/app/assets/stylesheets/application.sass @@ -2,7 +2,6 @@ @import 'variables' @import 'overrides' -@import 'materialdesignicons' @import 'jquery-ui/autocomplete' @import 'bootstrap-datepicker' @@ -22,4 +21,5 @@ // Font Awesome @import 'font-awesome-sprockets' @import 'font-awesome' +@import 'material_icons' diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index c493063d4..7f214803d 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -17,7 +17,7 @@ = link_to t('.harvests'), harvests_path, class: 'dropdown-item' %li.nav-item.dropdown - %a#navbarDropdown.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", href: "#", role: "button"}= t('.community') + %a.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", href: "#", role: "button"}= t('.community') .dropdown-menu{"aria-labelledby" => "navbarDropdown"} = link_to t('.community_map'), places_path, class: 'dropdown-item' = link_to t('.browse_members'), members_path, class: 'dropdown-item' @@ -27,50 +27,46 @@ - if member_signed_in? %li.nav-item.dropdown - %a#navbarDropdown.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", href: "#", role: "button"} + %a.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", href: "#", role: "button"} - if current_member.notifications.unread_count.positive? = t('.your_stuff', unread_count: current_member.notifications.unread_count) - else = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) .dropdown-menu{"aria-labelledby" => "navbarDropdown"} = link_to member_path(current_member), class: 'dropdown-item' do - = member_icon = t('.profile') = link_to member_gardens_path(current_member), class: 'dropdown-item' do - = garden_icon = t('.gardens') = link_to member_plantings_path(current_member), class: 'dropdown-item' do - = planting_icon = t('.plantings') = link_to member_harvests_path(current_member), class: 'dropdown-item' do - = harvest_icon = t('.harvest') = link_to member_seeds_path(current_member), class: 'dropdown-item' do - = seed_icon = t('.seeds') - = link_to t('.posts'), member_posts_path(current_member) + = link_to t('.posts'), member_posts_path(current_member), class: 'dropdown-item' - if current_member.notifications.unread_count.positive? = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), notifications_path) - else - = link_to(t('.inbox'), notifications_path) + = link_to t('.inbox'), notifications_path, class: 'dropdown-item' - if current_member.role?(:crop_wrangler) || current_member.role?(:admin) %li.divider{ role: 'presentation' } - if current_member.role?(:crop_wrangler) - %li= link_to t('.crop_wrangling'), wrangle_crops_path + = link_to t('.crop_wrangling'), wrangle_crops_path, class: 'dropdown-item' - if current_member.role?(:admin) - %li= link_to t('.admin'), admin_path + = link_to t('.admin'), admin_path, class: 'dropdown-item' - %li= link_to t('.sign_out'), destroy_member_session_path, method: :delete + %li.nav-item + = link_to t('.sign_out'), destroy_member_session_path, method: :delete, class: 'nav-link' - else - = link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' - = link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' + %li.nav-item= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin', class: 'nav-link' + %li.nav-item= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup', class: 'nav-link' = form_tag search_crops_path, method: :get, class: 'form-inline my-2 my-lg-0' do .input-group %input.form-control.mr-sm-2{name: 'term', "aria-label" => "Search", placeholder: "Search", type: "search"}/ - %button.btn.btn-default.text-white{type: "submit"}< + %button.btn.btn-default.text-white{type: "submit"} = icon 'fas', 'search' From d4eaacf11e594c42402dfda63937f946f1cd998d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 17 May 2019 12:18:48 +1200 Subject: [PATCH 081/549] Add menus to percy spec --- spec/features/percy/percy_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index f545aeb1c..27b7f5a36 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -226,5 +226,17 @@ describe 'Test with visual testing', type: :feature, js: true do Percy.snapshot(page, name: "#{prefix}/posts#edit") end end + + describe 'expand menus' do + it 'expands crop menu' do + visit root_path + click_on 'Crops' + Percy.snapshot(page, name: "#{prefix}/crops-menu") + click_on 'Community' + Percy.snapshot(page, name: "#{prefix}/community-menu") + click_on 'percy' + Percy.snapshot(page, name: "#{prefix}/menu-menu") + end + end end end From 72479eb44f10412c65269368137f076d5a7e355c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 17 May 2019 12:26:50 +1200 Subject: [PATCH 082/549] Another gardens#show test --- spec/features/percy/percy_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 27b7f5a36..22faf8ffb 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -88,7 +88,7 @@ describe 'Test with visual testing', type: :feature, js: true do tomato_planting = FactoryBot.create :planting, garden: garden, owner: member, crop: tomato tomato_photo.plantings << tomato_planting visit garden_path(garden) - Percy.snapshot(page, name: "#{prefix}/gardens#show") + Percy.snapshot(page, name: "#{prefix}/gardens#show-2") end end @@ -235,7 +235,7 @@ describe 'Test with visual testing', type: :feature, js: true do click_on 'Community' Percy.snapshot(page, name: "#{prefix}/community-menu") click_on 'percy' - Percy.snapshot(page, name: "#{prefix}/menu-menu") + Percy.snapshot(page, name: "#{prefix}/member-menu") end end end From 77c0dea122d837858409c811c8bf23318142cd94 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 May 2019 20:14:25 +1200 Subject: [PATCH 083/549] Tidy up posts#show --- app/views/posts/show.html.haml | 82 ++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 24 deletions(-) diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index cca0f813d..01438393c 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -18,33 +18,67 @@ = link_to 'hundreds of different crops', crops_url and a community from all around the world. - = render partial: "shared/signin_signup", - locals: { to: "or to start using #{ENV['GROWSTUFF_SITE_NAME']} to track what you're planting and harvesting" } + = render "shared/signin_signup", + to: "or to start using #{ENV['GROWSTUFF_SITE_NAME']} to track what you're planting and harvesting" -= render partial: "single", locals: { post: @post, subject: false, hide_comments: true } +.row + .col-8.col-xs-12 -- unless @post.crops.empty? - %h3 Crops mentioned in this post - - @post.crops.each do |c| - .col-md-2 - = render partial: 'crops/thumbnail', locals: { crop: c } + / Section: Blog v.4 + %section.blog-post + .card.post{ id: "post-#{@post.id}" } + .card-header + %h2.display-3= @post.subject + .card-body + %p + Posted by + - if @post.author + = link_to @post.author.login_name, member_path(@post.author) + - else + Member Deleted + - if @post.forum + in + = link_to @post.forum, @post.forum + on + = @post.created_at + - if @post.updated_at > @post.created_at + and edited at + = @post.updated_at + :growstuff_markdown + #{ strip_tags @post.body } -.col-md-11 - - if can?(:edit, @post) || can?(:destroy, @post) - .post-actions - - if can? :edit, @post - = link_to 'Edit Post', edit_post_path(@post), class: 'btn btn-default btn-xs' - - if can? :destroy, @post - = link_to 'Delete Post', @post, method: :delete, - data: { confirm: 'Are you sure?' }, - class: 'btn btn-default btn-xs' + .card-footer + - if can? :create, Comment + = link_to new_comment_path(post_id: @post.id), class: 'btn' do + = icon 'fas', 'comment' + Comment - - if @post.comments.count > 10 && can?(:create, Comment) - .post-actions - = link_to 'Comment', new_comment_path(post_id: @post.id), class: 'btn btn-primary' + - if can?(:edit, @post) || can?(:destroy, @post) + - if can? :edit, @post + = link_to 'Edit Post', edit_post_path(@post), class: 'btn' - = render partial: "comments", locals: { post: @post } + - if can? :destroy, @post + = link_to 'Delete Post', @post, method: :delete, + data: { confirm: 'Are you sure?' }, + class: 'btn' + + - if @post.comments.count > 10 && can?(:create, Comment) + = link_to 'Comment', new_comment_path(post_id: @post.id), class: 'btn' + + + .col-4.col-xs-12 + = render @post.author + + - unless @post.crops.empty? + %hr/ + .row + .col-md-12 + %h3 Crops mentioned in this post + - @post.crops.each do |c| + .col-md-6= render 'crops/thumbnail', crop: c + + + + .col-md-12 + = render "comments", post: @post - - if can? :create, Comment - .post-actions - = link_to 'Comment', new_comment_path(post_id: @post.id), class: 'btn btn-primary' From 2046d733303cbd8be79bae9d172cefaeb99049dd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 May 2019 21:12:36 +1200 Subject: [PATCH 084/549] Tidy up posts#index --- app/views/posts/index.html.haml | 43 +++++++++++++++------------------ 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index aa11d529b..c5996019c 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -1,30 +1,27 @@ - content_for :title, @author ? t('.title.author_posts', author: @author) : t('.title.default') -%p - - if can? :create, Post - - if @author - %p - - if @author == current_member - = link_to 'Post something', new_post_path, class: 'btn btn-primary' - = link_to "View everyone's posts", posts_path, class: 'btn btn-default' - - else # everyone's posts - = link_to 'Post something', new_post_path, class: 'btn btn-primary' - - if current_member - = link_to 'View your posts', member_posts_path(current_member), class: 'btn btn-default' - - else - = render partial: 'shared/signin_signup', locals: { to: 'write a post' } +.pagination= render 'layouts/pagination', collection: @posts +.row + .card-deck + - @posts.each do |post| + .col-6.col-xs-12 + .card + .card-body + .row + .col-4= render 'members/avatar', member: post.author + .col-8 + %h5.card-title + = link_to post.subject, post + - if post.comments.size.positive? + %span.badge.badge-pill.badge-info.float-right + = icon 'fas', 'comment' + = post.comments.size + %p.card-text= display_post_truncated(post) + - post.crops.each do |crop| + %span.badge.badge-pill.badge-primary= link_to crop, crop -.pagination - = page_entries_info @posts - = will_paginate @posts -- unless @posts.empty? - - @posts.each do |post| - = render partial: "single", locals: { post: post, subject: true } - - .pagination - = page_entries_info @posts - = will_paginate @posts +.pagination= render 'layouts/pagination', collection: @posts %p - if @author From f01996924017d98352cfa9563efe5e4e5587f9e5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 May 2019 21:41:41 +1200 Subject: [PATCH 085/549] Tidy up posts --- app/helpers/posts_helper.rb | 6 ++++++ app/models/post.rb | 4 ++++ app/views/home/index.html.haml | 10 +++++----- app/views/posts/_single.html.haml | 3 ++- app/views/posts/index.html.haml | 4 +++- spec/factories/post.rb | 4 ++-- spec/features/percy/percy_spec.rb | 12 +++++++++++- 7 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 app/helpers/posts_helper.rb diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb new file mode 100644 index 000000000..c7d7c6c2b --- /dev/null +++ b/app/helpers/posts_helper.rb @@ -0,0 +1,6 @@ +module PostsHelper + def display_post_truncated(post) + length = 300 + return truncate(post.body, length: length, separator: ' ', omission: '... ') { link_to "Read more", post_path(post) } + end +end diff --git a/app/models/post.rb b/app/models/post.rb index 46efa2e45..050af47f5 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -48,6 +48,10 @@ class Post < ApplicationRecord end end + def to_s + subject + end + private def update_crops_posts_association diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 0b1e6965b..59ae38890 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -20,7 +20,6 @@ %h3= t('.recently_added') != Crop.recent.limit(30).map { |c| link_to(c, c) }.join(", ") - %section.seeds %h2.text-center= t('.seeds_available_to_trade') .homepage-cards @@ -28,13 +27,14 @@ .align-bottom %p.text-right= link_to "#{t('home.seeds.view_all')} »", seeds_path, class: 'btn' + %section.members= render 'members' + .col-xl-5 .row .col-md-6.col-sm-12=render 'plantings' .col-md-6.col-sm-12= render 'harvests' + .row + .col-12 + %section.members= render 'discuss' - %section.members= render 'discuss' - - -%section.members= render 'members' diff --git a/app/views/posts/_single.html.haml b/app/views/posts/_single.html.haml index 65999aa1d..6132343f1 100644 --- a/app/views/posts/_single.html.haml +++ b/app/views/posts/_single.html.haml @@ -1,4 +1,5 @@ -.well + +.card .post{ id: "post-#{post.id}" } .row .col-md-1 diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index c5996019c..dc50b5458 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -1,10 +1,12 @@ - content_for :title, @author ? t('.title.author_posts', author: @author) : t('.title.default') + +%h1= @author ? t('.title.author_posts', author: @author) : t('.title.default') .pagination= render 'layouts/pagination', collection: @posts .row .card-deck - @posts.each do |post| - .col-6.col-xs-12 + .col-6 .card .card-body .row diff --git a/spec/factories/post.rb b/spec/factories/post.rb index 8284ed393..f3471042f 100644 --- a/spec/factories/post.rb +++ b/spec/factories/post.rb @@ -1,8 +1,8 @@ FactoryBot.define do factory :post do - subject { "A Post" } + subject { Faker::Book.title } - body { "This is some text." } + body { Faker::Lorem.paragraphs.join("\n") } author created_at { Time.zone.now } diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 22faf8ffb..4948f1dbf 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -88,7 +88,7 @@ describe 'Test with visual testing', type: :feature, js: true do tomato_planting = FactoryBot.create :planting, garden: garden, owner: member, crop: tomato tomato_photo.plantings << tomato_planting visit garden_path(garden) - Percy.snapshot(page, name: "#{prefix}/gardens#show-2") + Percy.snapshot(page, name: "#{prefix}/gardens#show") end end @@ -110,6 +110,16 @@ describe 'Test with visual testing', type: :feature, js: true do visit post_path(post) Percy.snapshot(page, name: "#{prefix}/posts#show") end + it 'loads posts#index' do + Member.all.each do |member| + FactoryBot.create_list :post, 12, author: member + end + Post.all.order(:id).limit(4) do |post| + FactoryBot.create_list :comment, rand(1..5), post: post + end + visit posts_path + Percy.snapshot(page, name: "#{prefix}/posts#index") + end end describe 'photos' do From b19586dd1dd585edf4e3bab4a6a5dc7b651bbbbd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 May 2019 21:42:12 +1200 Subject: [PATCH 086/549] six harvests/plantings on the homepage --- app/views/home/_harvests.html.haml | 2 +- app/views/home/_plantings.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/home/_harvests.html.haml b/app/views/home/_harvests.html.haml index e83a7698e..aab9c71d4 100644 --- a/app/views/home/_harvests.html.haml +++ b/app/views/home/_harvests.html.haml @@ -1,6 +1,6 @@ %section.harvests %h5= t('.recently_harvested') - - Harvest.has_photos.recent.includes(:crop, :owner, :photos).limit(3).each do |harvest| + - Harvest.has_photos.recent.includes(:crop, :owner, :photos).limit(6).each do |harvest| .card = link_to harvest, class: 'list-group-item list-group-item-action flex-column align-items-start' do .d-flex.w-100.justify-content-between diff --git a/app/views/home/_plantings.html.haml b/app/views/home/_plantings.html.haml index ecbcc23de..82f68f0bf 100644 --- a/app/views/home/_plantings.html.haml +++ b/app/views/home/_plantings.html.haml @@ -1,7 +1,7 @@ %section.plantings %h5= t('.recently_planted') - - Planting.has_photos.recent.includes(:crop, garden: :owner).limit(3).each do |planting| + - Planting.has_photos.recent.includes(:crop, garden: :owner).limit(6).each do |planting| .card = link_to planting, class: 'list-group-item list-group-item-action flex-column align-items-start' do .d-flex.w-100.justify-content-between From 253d1806ef4af5191aa889d6e4cad7c21cd72e89 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 May 2019 21:42:26 +1200 Subject: [PATCH 087/549] Fix the admin menu --- app/views/layouts/_header.html.haml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 7f214803d..30ba563e1 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -50,19 +50,22 @@ notifications_path) - else = link_to t('.inbox'), notifications_path, class: 'dropdown-item' + - if current_member.role?(:crop_wrangler) || current_member.role?(:admin) - %li.divider{ role: 'presentation' } - - if current_member.role?(:crop_wrangler) - = link_to t('.crop_wrangling'), wrangle_crops_path, class: 'dropdown-item' - - if current_member.role?(:admin) - = link_to t('.admin'), admin_path, class: 'dropdown-item' + %li.nav-item.dropdown + %a.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", href: "#", role: "button"}= t('.admin') + .dropdown-menu{"aria-labelledby" => "navbarDropdown"} + - if current_member.role?(:crop_wrangler) + = link_to t('.crop_wrangling'), wrangle_crops_path, class: 'dropdown-item' + - if current_member.role?(:admin) + = link_to t('.admin'), admin_path, class: 'dropdown-item' %li.nav-item = link_to t('.sign_out'), destroy_member_session_path, method: :delete, class: 'nav-link' - else - %li.nav-item= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin', class: 'nav-link' - %li.nav-item= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup', class: 'nav-link' + %li.nav-item= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin', class: 'btn nav-link' + %li.nav-item= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup', class: 'btn nav-link' = form_tag search_crops_path, method: :get, class: 'form-inline my-2 my-lg-0' do From 7bf2d7560560d6470f463f5ae279747fb41c9982 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 May 2019 21:45:31 +1200 Subject: [PATCH 088/549] More post content in percy specs --- spec/features/percy/percy_spec.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 4948f1dbf..59149af62 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -105,7 +105,26 @@ describe 'Test with visual testing', type: :feature, js: true do end describe 'posts' do - let(:post) { FactoryBot.create :post, author: member } + let(:post_body) do + "So, um, watering's important. Yep. Very important. + +Well, what with moving into the house and all THAT entails...my plants are looking the worse for wear. They haven't gotten enough water. The oregano is dead. The basil and chives are just hanging on. The [tomato](crop) have sort of purple leaves. Seeing that the roots were all growing out of the bottom of the pots, I finally went and got soil to fill the basins I have for the tomatoes and spent the money on proper (much larger) pots for the herbs. + +At Home Depot, it turned out that 7.5\" pots that are glazed inside and out (to prevent wicking & evaporation of water -- the problem my tomatoes were hitting with the teensy clay pots) were $10 for the pot and $5 for the saucer. Or there are 7.25\" self-watering pots for $15. So my herbs are now in self-watering pots where they should be able to survive Pennsic without me. I got a new oregano plant too. + +[ ![self-watering herbs](http://farm4.staticflickr.com/3735/9337893326_62a036bf56.jpg) ](http://www.flickr.com/photos/maco_nix/9337893326/) + +The tomatoes are now in large plastic bins full of dirt/compost, where their roots can spread out. Turns out clay pots in weather that is always over 80, usually over 90, and hitting over 100 (celsius people, read those as 26, 32, 38) means you need to water at least daily, probably a couple of times a day, to keep the plants happy. + +[ ![tomatoes in plastic cement mixing tubs](http://farm4.staticflickr.com/3745/9337878942_9602530c31.jpg)](http://www.flickr.com/photos/maco_nix/9337878942/) + +After taking that photo, I put some egg shells (since I hardboiled some eggs today for pickling) in the dirt around them and added stakes. + +I noticed a couple of days ago on the way to work that there's a place near home called Country Boy Market. Fresh locally grown produce (cheap berries, nom nom), mulch, top soil, compost, and straw bales are all available. Also they deliver mulch & soil. Well then. I know what's happening next spring when I try to build up the rest of the garden. +[apple](crop) + " + end + let(:post) { FactoryBot.create :post, author: member, subject: "Watering", body: post_body } it 'loads posts#show' do visit post_path(post) Percy.snapshot(page, name: "#{prefix}/posts#show") From 5982a588518462e0203db7ad6fe2cb0f1f00c7ef Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 May 2019 22:26:50 +1200 Subject: [PATCH 089/549] Fix posts#index --- app/views/posts/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index dc50b5458..9c1f6e10d 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -6,7 +6,7 @@ .row .card-deck - @posts.each do |post| - .col-6 + .col-12.col-md-6 .card .card-body .row From b19bef0ec3953918c850933e92a166f51c0812a1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 May 2019 22:29:49 +1200 Subject: [PATCH 090/549] Adding posts and comments to percy spec --- spec/features/percy/percy_spec.rb | 57 ++++++++++++++++++------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 59149af62..cc4c71a5a 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -16,6 +16,26 @@ describe 'Test with visual testing', type: :feature, js: true do fullsize_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_z.jpg', thumbnail_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_q.jpg' end + let(:post_body) do + "So, um, watering's important. Yep. Very important. + +Well, what with moving into the house and all THAT entails...my plants are looking the worse for wear. They haven't gotten enough water. The oregano is dead. The basil and chives are just hanging on. The [tomato](crop) have sort of purple leaves. Seeing that the roots were all growing out of the bottom of the pots, I finally went and got soil to fill the basins I have for the tomatoes and spent the money on proper (much larger) pots for the herbs. + +At Home Depot, it turned out that 7.5\" pots that are glazed inside and out (to prevent wicking & evaporation of water -- the problem my tomatoes were hitting with the teensy clay pots) were $10 for the pot and $5 for the saucer. Or there are 7.25\" self-watering pots for $15. So my herbs are now in self-watering pots where they should be able to survive Pennsic without me. I got a new oregano plant too. + +[ ![self-watering herbs](http://farm4.staticflickr.com/3735/9337893326_62a036bf56.jpg) ](http://www.flickr.com/photos/maco_nix/9337893326/) + +The tomatoes are now in large plastic bins full of dirt/compost, where their roots can spread out. Turns out clay pots in weather that is always over 80, usually over 90, and hitting over 100 (celsius people, read those as 26, 32, 38) means you need to water at least daily, probably a couple of times a day, to keep the plants happy. + +[ ![tomatoes in plastic cement mixing tubs](http://farm4.staticflickr.com/3745/9337878942_9602530c31.jpg)](http://www.flickr.com/photos/maco_nix/9337878942/) + +After taking that photo, I put some egg shells (since I hardboiled some eggs today for pickling) in the dirt around them and added stakes. + +I noticed a couple of days ago on the way to work that there's a place near home called Country Boy Market. Fresh locally grown produce (cheap berries, nom nom), mulch, top soil, compost, and straw bales are all available. Also they deliver mulch & soil. Well then. I know what's happening next spring when I try to build up the rest of the garden. +[apple](crop) + " + end + let(:post) { FactoryBot.create :post, author: member, subject: "Watering", body: post_body } before do # Freeze time, so we don't have variations in timestamps on the page Timecop.freeze(Time.local(2019, 1, 1)) @@ -37,6 +57,9 @@ describe 'Test with visual testing', type: :feature, js: true do harvest = FactoryBot.create :harvest, crop: crop, owner: owner, plant_part: plant_part harvest.photos << photo + FactoryBot.create :planting, crop: tomato, + planted_at: 1.year.ago, finished_at: 2.months.ago, + sunniness: 'sun', planted_from: 'seed' end end after { Timecop.return } @@ -81,7 +104,7 @@ describe 'Test with visual testing', type: :feature, js: true do it 'gardens#show' do # a garden - garden = FactoryBot.create :garden, name: 'paraside', owner: member + garden = FactoryBot.create :garden, name: 'paradise', owner: member #with some lettuce (finished) FactoryBot.create :planting, crop: FactoryBot.create(:crop, name: 'lettuce'), garden: garden, owner: member, finished_at: 2.weeks.ago #tomato still growing @@ -105,35 +128,17 @@ describe 'Test with visual testing', type: :feature, js: true do end describe 'posts' do - let(:post_body) do - "So, um, watering's important. Yep. Very important. - -Well, what with moving into the house and all THAT entails...my plants are looking the worse for wear. They haven't gotten enough water. The oregano is dead. The basil and chives are just hanging on. The [tomato](crop) have sort of purple leaves. Seeing that the roots were all growing out of the bottom of the pots, I finally went and got soil to fill the basins I have for the tomatoes and spent the money on proper (much larger) pots for the herbs. - -At Home Depot, it turned out that 7.5\" pots that are glazed inside and out (to prevent wicking & evaporation of water -- the problem my tomatoes were hitting with the teensy clay pots) were $10 for the pot and $5 for the saucer. Or there are 7.25\" self-watering pots for $15. So my herbs are now in self-watering pots where they should be able to survive Pennsic without me. I got a new oregano plant too. - -[ ![self-watering herbs](http://farm4.staticflickr.com/3735/9337893326_62a036bf56.jpg) ](http://www.flickr.com/photos/maco_nix/9337893326/) - -The tomatoes are now in large plastic bins full of dirt/compost, where their roots can spread out. Turns out clay pots in weather that is always over 80, usually over 90, and hitting over 100 (celsius people, read those as 26, 32, 38) means you need to water at least daily, probably a couple of times a day, to keep the plants happy. - -[ ![tomatoes in plastic cement mixing tubs](http://farm4.staticflickr.com/3745/9337878942_9602530c31.jpg)](http://www.flickr.com/photos/maco_nix/9337878942/) - -After taking that photo, I put some egg shells (since I hardboiled some eggs today for pickling) in the dirt around them and added stakes. - -I noticed a couple of days ago on the way to work that there's a place near home called Country Boy Market. Fresh locally grown produce (cheap berries, nom nom), mulch, top soil, compost, and straw bales are all available. Also they deliver mulch & soil. Well then. I know what's happening next spring when I try to build up the rest of the garden. -[apple](crop) - " - end - let(:post) { FactoryBot.create :post, author: member, subject: "Watering", body: post_body } it 'loads posts#show' do + FactoryBot.create :comment ,post: post + FactoryBot.create :comment ,post: post visit post_path(post) Percy.snapshot(page, name: "#{prefix}/posts#show") end it 'loads posts#index' do - Member.all.each do |member| + Member.all.limit(5).each do |member| FactoryBot.create_list :post, 12, author: member end - Post.all.order(:id).limit(4) do |post| + Post.all.order(id: :desc).limit(4) do |post| FactoryBot.create_list :comment, rand(1..5), post: post end visit posts_path @@ -250,10 +255,14 @@ I noticed a couple of days ago on the way to work that there's a place near home end it 'loads posts#edit' do - post = FactoryBot.create :post, author: member visit edit_post_path(post) Percy.snapshot(page, name: "#{prefix}/posts#edit") end + + it 'comments#new' do + visit new_comment_path(post_id: post.id) + Percy.snapshot(page, name: "comments#new") + end end describe 'expand menus' do From dccbf440cb3763cc155eac357822a879e4697ffc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 May 2019 23:18:27 +1200 Subject: [PATCH 091/549] Breadcrumbs --- app/views/admin/index.html.haml | 7 +++++ app/views/crops/index.html.haml | 35 ++++++++++++---------- app/views/crops/search.html.haml | 12 +++++--- app/views/crops/show.html.haml | 8 +++++ app/views/layouts/application.html.haml | 11 +++++-- app/views/posts/index.html.haml | 8 +++++ app/views/posts/show.html.haml | 39 +++++++++++++++++-------- 7 files changed, 85 insertions(+), 35 deletions(-) diff --git a/app/views/admin/index.html.haml b/app/views/admin/index.html.haml index ba67f1ec2..f21c5f93a 100644 --- a/app/views/admin/index.html.haml +++ b/app/views/admin/index.html.haml @@ -1,5 +1,12 @@ - content_for :title, 'Admin' +- content_for :breadcrumbs do + %nav{"aria-label" => "breadcrumb"} + %ol.breadcrumb + %li.breadcrumb-item + = link_to 'Home', root_path + %li.breadcrumb-item.active= link_to 'Admin', admin_path + %h2 Manage .row diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml index ac2dba563..19bb52b41 100644 --- a/app/views/crops/index.html.haml +++ b/app/views/crops/index.html.haml @@ -1,5 +1,4 @@ - content_for :title, t('.title') -- content_for :subtitle, t('.subtitle', crops_size: @crops.size) - content_for :buttonbar do - if can? :wrangle, Crop @@ -7,24 +6,30 @@ - if can? :create, Crop = link_to 'Add new Crop', new_crop_path, class: 'btn btn-primary' +- content_for :breadcrumbs do + %nav{"aria-label" => "breadcrumb"} + %ol.breadcrumb + %li.breadcrumb-item + = link_to 'Home', root_path + %li.breadcrumb-item.active= link_to 'Crops', crops_path -- if @num_requested_crops && @num_requested_crops.positive? - = link_to(I18n.t('crops.requested.link', number_crops: @num_requested_crops), requested_crops_path) - +%h1=t('.title') %p #{ENV['GROWSTUFF_SITE_NAME']} tracks who's growing what, where. View any crop page to see which of our members have planted it and find information on how to grow it yourself. -= form_tag(crops_path, method: :get, class: 'form-inline', role: 'form') do - .form-group - = label_tag :sort, "Sort by:", class: 'sr-only' - = select_tag "sort", - options_for_select({ "Sort by popularity": 'popular', - "Sort alphabetically": 'alpha' }, - @sort || 'popular'), - class: 'form-control' - = submit_tag "Show", class: 'btn btn-primary' + +.well + = form_tag(crops_path, method: :get, class: 'form-inline', role: 'form') do + .form-group + = label_tag :sort, "Sort by:", class: 'sr-only' + = select_tag "sort", + options_for_select({ "Sort by popularity": 'popular', + "Sort alphabetically": 'alpha' }, + @sort || 'popular'), + class: 'form-control' + = submit_tag "Show", class: 'btn btn-success' .pagination= render 'layouts/pagination', collection: @crops @@ -32,9 +37,7 @@ - @crops.each do |crop| .col-md-2= render 'crops/thumbnail', crop: crop -.pagination - = will_paginate @crops - +.pagination= render 'layouts/pagination', collection: @crops %ul.list-inline %li The data on this page is available in the following formats: diff --git a/app/views/crops/search.html.haml b/app/views/crops/search.html.haml index b20273807..4dee37fa5 100644 --- a/app/views/crops/search.html.haml +++ b/app/views/crops/search.html.haml @@ -5,6 +5,14 @@ - else - content_for :title, "Crop search" +- content_for :breadcrumbs do + %nav{"aria-label" => "breadcrumb"} + %ol.breadcrumb + %li.breadcrumb-item + = link_to 'Home', root_path + %li.breadcrumb-item= link_to 'Crops', crops_path + %li.breadcrumb-item.active= link_to 'Search', search_crops_path(term: @term) + %div = form_tag search_crops_path, method: :get, id: 'crop-search', class: 'form-inline' do .form-group @@ -25,10 +33,6 @@ instead. - else - = will_paginate @crops - .row - @crops.each do |crop| .col-md-2= render 'crops/thumbnail', crop: crop - - = will_paginate @crops diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index e99100022..dea9795b2 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -10,6 +10,14 @@ - content_for :scripts do = javascript_include_tag "charts" +- content_for :breadcrumbs do + %nav{"aria-label" => "breadcrumb"} + %ol.breadcrumb + %li.breadcrumb-item + = link_to 'Home', root_path + %li.breadcrumb-item= link_to 'Crops', crops_path + %li.breadcrumb-item.active= link_to @crop, @crop + %h1 = @crop.name %small= @crop.default_scientific_name diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 0362fca92..5dd7ccd33 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -8,9 +8,14 @@ -# anchor tag for accessibility link to skip the navigation menu %a{ name: 'skipnav' } #maincontainer.container - .pull-right= render 'shared/global_actions' - - if content_for?(:buttonbar) - = yield(:buttonbar) + .row + .col-md-12 + - if content_for?(:breadcrumbs) + .float-left= yield(:breadcrumbs) + .float-right + = render 'shared/global_actions' + - if content_for?(:buttonbar) + = yield(:buttonbar) - if content_for?(:subtitle) %small= yield(:subtitle) diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index 9c1f6e10d..b4d76e541 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -1,5 +1,13 @@ - content_for :title, @author ? t('.title.author_posts', author: @author) : t('.title.default') +- content_for :breadcrumbs do + %nav{"aria-label" => "breadcrumb"} + %ol.breadcrumb + %li.breadcrumb-item + = link_to 'Home', root_path + - if @author.present? + %li.breadcrumb-item= link_to @author, @author + %li.breadcrumb-item.active= link_to 'posts', posts_path(author: @author.slug) %h1= @author ? t('.title.author_posts', author: @author) : t('.title.default') .pagination= render 'layouts/pagination', collection: @posts diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index 01438393c..1456beada 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -21,6 +21,33 @@ = render "shared/signin_signup", to: "or to start using #{ENV['GROWSTUFF_SITE_NAME']} to track what you're planting and harvesting" +- content_for :buttonbar do + - if can?(:edit, @post) || can?(:destroy, @post) + - if can? :edit, @post + = link_to edit_post_path(@post), class: 'btn' do + = edit_icon + edit + + - if can? :destroy, @post + = link_to @post, method: :delete, + data: { confirm: 'Are you sure?' }, + class: 'btn btn-danger' do + = delete_icon + delete + + - if @post.comments.count > 10 && can?(:create, Comment) + = link_to 'Comment', new_comment_path(post_id: @post.id), class: 'btn' + + +- content_for :breadcrumbs do + %nav{"aria-label" => "breadcrumb"} + %ol.breadcrumb + %li.breadcrumb-item + = link_to 'Home', root_path + %li.breadcrumb-item= link_to @post.author, @post.author + %li.breadcrumb-item= link_to 'posts', posts_path(author: @post.author.slug) + %li.breadcrumb-item.active{"aria-current" => "page"}= @post.subject + .row .col-8.col-xs-12 @@ -53,18 +80,6 @@ = icon 'fas', 'comment' Comment - - if can?(:edit, @post) || can?(:destroy, @post) - - if can? :edit, @post - = link_to 'Edit Post', edit_post_path(@post), class: 'btn' - - - if can? :destroy, @post - = link_to 'Delete Post', @post, method: :delete, - data: { confirm: 'Are you sure?' }, - class: 'btn' - - - if @post.comments.count > 10 && can?(:create, Comment) - = link_to 'Comment', new_comment_path(post_id: @post.id), class: 'btn' - .col-4.col-xs-12 = render @post.author From 64b3ab25e1a04cb844caa5f67140f0b600fab88f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 18 May 2019 23:18:42 +1200 Subject: [PATCH 092/549] tidy up plantings#index --- app/views/plantings/index.html.haml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index 03bb660af..09369ad73 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -13,7 +13,9 @@ = page_entries_info @plantings = render 'layouts/pagination', collection: @plantings -.row= render(@plantings) || "empty_list" +.row + - @plantings.each do |planting| + .col-md-3.col-sm-4.col-6= render 'plantings/card', planting: planting .pagination = page_entries_info @plantings From 4af8282a44c4eb0d19575e4cc715def2d2136c70 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Sat, 18 May 2019 19:36:26 +0000 Subject: [PATCH 093/549] [CodeFactor] Apply fixes --- app/assets/javascripts/nav.js | 2 +- app/helpers/posts_helper.rb | 2 +- app/models/post.rb | 2 +- spec/features/percy/percy_spec.rb | 20 ++++++++++---------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/nav.js b/app/assets/javascripts/nav.js index 34ce99672..eb3d7297a 100644 --- a/app/assets/javascripts/nav.js +++ b/app/assets/javascripts/nav.js @@ -1 +1 @@ -$('.dropdown-toggle').dropdown() \ No newline at end of file +$('.dropdown-toggle').dropdown(); diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index c7d7c6c2b..9928f710c 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -1,6 +1,6 @@ module PostsHelper def display_post_truncated(post) length = 300 - return truncate(post.body, length: length, separator: ' ', omission: '... ') { link_to "Read more", post_path(post) } + truncate(post.body, length: length, separator: ' ', omission: '... ') { link_to "Read more", post_path(post) } end end diff --git a/app/models/post.rb b/app/models/post.rb index 050af47f5..50be9bfc7 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -51,7 +51,7 @@ class Post < ApplicationRecord def to_s subject end - + private def update_crops_posts_association diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index cc4c71a5a..dd9d42f63 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -10,16 +10,16 @@ describe 'Test with visual testing', type: :feature, js: true do let(:plant_part) { FactoryBot.create :plant_part, name: 'fruit' } let(:tomato_photo) do - FactoryBot.create :photo, - title: 'look at my tomatoes', - owner: member, - fullsize_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_z.jpg', - thumbnail_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_q.jpg' + FactoryBot.create :photo, + title: 'look at my tomatoes', + owner: member, + fullsize_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_z.jpg', + thumbnail_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_q.jpg' end let(:post_body) do "So, um, watering's important. Yep. Very important. -Well, what with moving into the house and all THAT entails...my plants are looking the worse for wear. They haven't gotten enough water. The oregano is dead. The basil and chives are just hanging on. The [tomato](crop) have sort of purple leaves. Seeing that the roots were all growing out of the bottom of the pots, I finally went and got soil to fill the basins I have for the tomatoes and spent the money on proper (much larger) pots for the herbs. +Well, what with moving into the house and all THAT entails...my plants are looking the worse for wear. They haven't gotten enough water. The oregano is dead. The basil and chives are just hanging on. The [tomato](crop) have sort of purple leaves. Seeing that the roots were all growing out of the bottom of the pots, I finally went and got soil to fill the basins I have for the tomatoes and spent the money on proper (much larger) pots for the herbs. At Home Depot, it turned out that 7.5\" pots that are glazed inside and out (to prevent wicking & evaporation of water -- the problem my tomatoes were hitting with the teensy clay pots) were $10 for the pot and $5 for the saucer. Or there are 7.25\" self-watering pots for $15. So my herbs are now in self-watering pots where they should be able to survive Pennsic without me. I got a new oregano plant too. @@ -105,9 +105,9 @@ I noticed a couple of days ago on the way to work that there's a place near home it 'gardens#show' do # a garden garden = FactoryBot.create :garden, name: 'paradise', owner: member - #with some lettuce (finished) + # with some lettuce (finished) FactoryBot.create :planting, crop: FactoryBot.create(:crop, name: 'lettuce'), garden: garden, owner: member, finished_at: 2.weeks.ago - #tomato still growing + # tomato still growing tomato_planting = FactoryBot.create :planting, garden: garden, owner: member, crop: tomato tomato_photo.plantings << tomato_planting visit garden_path(garden) @@ -129,8 +129,8 @@ I noticed a couple of days ago on the way to work that there's a place near home describe 'posts' do it 'loads posts#show' do - FactoryBot.create :comment ,post: post - FactoryBot.create :comment ,post: post + FactoryBot.create :comment, post: post + FactoryBot.create :comment, post: post visit post_path(post) Percy.snapshot(page, name: "#{prefix}/posts#show") end From dcfe49901e9dec120ca6150fade02cfd4fa665cb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 19 May 2019 10:20:35 +1200 Subject: [PATCH 094/549] Posts actions in dropdown menus --- app/helpers/icons_helper.rb | 4 + app/helpers/posts_helper.rb | 23 +++++- app/views/comments/_single.html.haml | 28 ++++--- app/views/comments/new.html.haml | 6 +- app/views/posts/_single.html.haml | 114 +++++++++++++++------------ app/views/posts/index.html.haml | 6 +- app/views/posts/show.html.haml | 60 +++++--------- 7 files changed, 137 insertions(+), 104 deletions(-) diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index bf841c0e5..bb6c61ee9 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -21,6 +21,10 @@ module IconsHelper icon('fas', 'heart') end + def comment_icon + icon('fas', 'comment') + end + def finished_icon icon('fas', 'calendar') end diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index c7d7c6c2b..c553b9bfc 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -1,6 +1,27 @@ module PostsHelper def display_post_truncated(post) length = 300 - return truncate(post.body, length: length, separator: ' ', omission: '... ') { link_to "Read more", post_path(post) } + return truncate(strip_tags(post.body), length: length, separator: ' ', omission: '... ') { link_to "Read more", post_path(post) } + end + + def post_byline(post) + byline = 'Posted by ' + + if post.author + byline += link_to post.author.login_name, member_path(post.author) + else + byline += 'Member Deleted' + end + + if post.forum + byline += ' in ' + byline += link_to post.forum, post.forum + end + + byline += " on #{post.created_at}" + + byline += " and edited at #{post.updated_at}" if post.updated_at > post.created_at + + byline.html_safe end end diff --git a/app/views/comments/_single.html.haml b/app/views/comments/_single.html.haml index d3488f4f9..e0726f343 100644 --- a/app/views/comments/_single.html.haml +++ b/app/views/comments/_single.html.haml @@ -1,10 +1,23 @@ -.well - .comment +.card.comment + .card-body .row .col-md-1 = render partial: "members/avatar", locals: { member: comment.author } - .col-md-11 - .comment-meta + .col-md-11.border-left + - if can?(:edit, comment) || can?(:destroy, comment) + .dropdown.float-right + %button#comment-edit-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button"} Actions + .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "comment-edit-button"} + - if can? :edit, comment + = link_to edit_comment_path(comment), class: 'dropdown-item' do + = edit_icon + Edit + - if can? :destroy, comment + = link_to comment, method: :delete, + data: { confirm: 'Are you sure?' }, class: 'dropdown-item text-danger' do + = delete_icon + Delete + .comment-meta.text-muted Posted by - if comment.author.deleted? Member Deleted @@ -20,10 +33,3 @@ :growstuff_markdown #{ strip_tags comment.body } - - if can?(:edit, comment) || can?(:destroy, comment) - .comment-actions - - if can? :edit, comment - = link_to 'Edit', edit_comment_path(comment), class: 'btn btn-default btn-xs' - - if can? :destroy, comment - = link_to 'Delete', comment, method: :delete, - data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs' diff --git a/app/views/comments/new.html.haml b/app/views/comments/new.html.haml index 91f8eef79..e66aba331 100644 --- a/app/views/comments/new.html.haml +++ b/app/views/comments/new.html.haml @@ -1,6 +1,10 @@ = content_for :title, "New comment" -= render partial: "posts/single", locals: { post: @post || @comment.post, subject: true } +%section.blog-post + .card.post{ id: "post-#{@post.id}" } + .card-header + %h2.display-3= @post.subject + .card-body= render "posts/single", post: @post || @comment.post, subject: true = render partial: "posts/comments", locals: { post: @post || @comment.post } diff --git a/app/views/posts/_single.html.haml b/app/views/posts/_single.html.haml index 6132343f1..e06a1a80e 100644 --- a/app/views/posts/_single.html.haml +++ b/app/views/posts/_single.html.haml @@ -1,56 +1,72 @@ +%p + Posted by + - if @post.author + = link_to @post.author.login_name, member_path(@post.author) + - else + Member Deleted + - if @post.forum + in + = link_to @post.forum, @post.forum + on + = @post.created_at + - if @post.updated_at > @post.created_at + and edited at + = @post.updated_at +:growstuff_markdown + #{ strip_tags @post.body } -.card - .post{ id: "post-#{post.id}" } - .row - .col-md-1 - = render partial: "members/avatar", locals: { member: post.author } - .col-md-11 - - if defined?(subject) - %h3= link_to strip_tags(post.subject), post +-# .card +-# .post{ id: "post-#{post.id}" } +-# .row +-# .col-md-1 +-# = render partial: "members/avatar", locals: { member: post.author } +-# .col-md-11 +-# - if defined?(subject) +-# %h3= link_to strip_tags(post.subject), post - .post-meta - %p - Posted by - - if post.author - = link_to post.author.login_name, member_path(post.author) - - else - Member Deleted - - if post.forum - in - = link_to post.forum, post.forum - on - = post.created_at - - if post.updated_at > post.created_at - and edited at - = post.updated_at +-# .post-meta +-# %p +-# Posted by +-# - if post.author +-# = link_to post.author.login_name, member_path(post.author) +-# - else +-# Member Deleted +-# - if post.forum +-# in +-# = link_to post.forum, post.forum +-# on +-# = post.created_at +-# - if post.updated_at > post.created_at +-# and edited at +-# = post.updated_at - .post-body - :growstuff_markdown - #{ strip_tags post.body } +-# .post-body +-# :growstuff_markdown +-# #{ strip_tags post.body } - - unless defined?(hide_comments) - .post-comments - %ul.list-inline - %li.first - = link_to localize_plural(post.comments, Comment), - post_path(post, anchor: 'comments') - - if can? :create, Comment - %li= link_to "Reply", new_comment_path(post_id: post.id) - %li= link_to "Permalink", post - - if can? :edit, post - %li= link_to "Edit", edit_post_path(post) +-# - unless defined?(hide_comments) +-# .post-comments +-# %ul.list-inline +-# %li.first +-# = link_to localize_plural(post.comments, Comment), +-# post_path(post, anchor: 'comments') +-# - if can? :create, Comment +-# %li= link_to "Reply", new_comment_path(post_id: post.id) +-# %li= link_to "Permalink", post +-# - if can? :edit, post +-# %li= link_to "Edit", edit_post_path(post) - .like-count - = pluralize(post.likes.count, "like") unless post.likes.empty? - - if member_signed_in? - - if !post.members.include? current_member - - if can?(:new, Like) - = link_to 'Like', likes_path(post_id: post.id, format: :json), - method: :post, remote: true, class: 'post-like' - - else - - like = post.likes.find_by(member: current_member) - - if like && can?(:destroy, like) - = link_to 'Unlike', like_path(id: like.id, format: :json), - method: :delete, remote: true, class: 'post-like' +-# .like-count +-# = pluralize(post.likes.count, "like") unless post.likes.empty? +-# - if member_signed_in? +-# - if !post.members.include? current_member +-# - if can?(:new, Like) +-# = link_to 'Like', likes_path(post_id: post.id, format: :json), +-# method: :post, remote: true, class: 'post-like' +-# - else +-# - like = post.likes.find_by(member: current_member) +-# - if like && can?(:destroy, like) +-# = link_to 'Unlike', like_path(id: like.id, format: :json), +-# method: :delete, remote: true, class: 'post-like' diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index b4d76e541..e12d99b9a 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -18,14 +18,16 @@ .card .card-body .row - .col-4= render 'members/avatar', member: post.author - .col-8 + .col-2.text-right + = render 'members/avatar', member: post.author + .col-10.border-left %h5.card-title = link_to post.subject, post - if post.comments.size.positive? %span.badge.badge-pill.badge-info.float-right = icon 'fas', 'comment' = post.comments.size + %p.text-muted= post_byline(post) %p.card-text= display_post_truncated(post) - post.crops.each do |crop| %span.badge.badge-pill.badge-primary= link_to crop, crop diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index 1456beada..4ef89d485 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -22,23 +22,9 @@ to: "or to start using #{ENV['GROWSTUFF_SITE_NAME']} to track what you're planting and harvesting" - content_for :buttonbar do - - if can?(:edit, @post) || can?(:destroy, @post) - - if can? :edit, @post - = link_to edit_post_path(@post), class: 'btn' do - = edit_icon - edit - - - if can? :destroy, @post - = link_to @post, method: :delete, - data: { confirm: 'Are you sure?' }, - class: 'btn btn-danger' do - = delete_icon - delete - - if @post.comments.count > 10 && can?(:create, Comment) = link_to 'Comment', new_comment_path(post_id: @post.id), class: 'btn' - - content_for :breadcrumbs do %nav{"aria-label" => "breadcrumb"} %ol.breadcrumb @@ -50,36 +36,32 @@ .row .col-8.col-xs-12 - - / Section: Blog v.4 %section.blog-post .card.post{ id: "post-#{@post.id}" } .card-header - %h2.display-3= @post.subject - .card-body - %p - Posted by - - if @post.author - = link_to @post.author.login_name, member_path(@post.author) - - else - Member Deleted - - if @post.forum - in - = link_to @post.forum, @post.forum - on - = @post.created_at - - if @post.updated_at > @post.created_at - and edited at - = @post.updated_at - :growstuff_markdown - #{ strip_tags @post.body } + %h2.display-3.float-left + = @post.subject + .dropdown.float-right + %button#post-edit-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions + .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "post-edit-button"} + - if can? :edit, @post + = link_to edit_post_path(@post), class: 'dropdown-item' do + = edit_icon + Edit + - if can? :delete, @post + = link_to post_path(@post), class: 'dropdown-item text-danger', data: { confirm: 'Are you sure?' } do + = delete_icon + Delete + .card-body= render 'posts/single', post: @post .card-footer - - if can? :create, Comment - = link_to new_comment_path(post_id: @post.id), class: 'btn' do - = icon 'fas', 'comment' - Comment + .float-right + - if can? :create, Comment + = link_to new_comment_path(post_id: @post.id), class: 'btn' do + = icon 'fas', 'comment' + Comment + = render "comments", post: @post .col-4.col-xs-12 = render @post.author @@ -94,6 +76,4 @@ - .col-md-12 - = render "comments", post: @post From 13419d37bb653d8907d016d186ab0e307cd5c596 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 19 May 2019 11:50:04 +1200 Subject: [PATCH 095/549] pull-right becomes text-right --- app/views/comments/_form.html.haml | 2 +- app/views/garden_types/_actions.html.haml | 2 +- app/views/gardens/_thumbnail.html.haml | 2 +- app/views/harvests/show.html.haml | 2 +- app/views/members/_map.html.haml | 2 +- app/views/seeds/_card.html.haml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/comments/_form.html.haml b/app/views/comments/_form.html.haml index 676d7f4fb..43b9073b9 100644 --- a/app/views/comments/_form.html.haml +++ b/app/views/comments/_form.html.haml @@ -19,7 +19,7 @@ %span.help-block = render partial: "shared/markdown_help" - .actions.pull-right + .actions.text-right = f.submit 'Post comment', class: 'btn btn-primary' - if defined?(@post) .field diff --git a/app/views/garden_types/_actions.html.haml b/app/views/garden_types/_actions.html.haml index 9dcf04028..e5153d1b9 100644 --- a/app/views/garden_types/_actions.html.haml +++ b/app/views/garden_types/_actions.html.haml @@ -1,4 +1,4 @@ .btn-group.garden_type-actions = render 'shared/buttons/edit', path: edit_garden_type_path(garden_type) - .pull-right + .text-right = render 'shared/buttons/delete', path: garden_type_path(garden_type) diff --git a/app/views/gardens/_thumbnail.html.haml b/app/views/gardens/_thumbnail.html.haml index a2e4ea7eb..f26ab62b9 100644 --- a/app/views/gardens/_thumbnail.html.haml +++ b/app/views/gardens/_thumbnail.html.haml @@ -3,7 +3,7 @@ %h3.panel-title = link_to display_garden_name(garden), garden_path(garden) - if can? :edit, garden - %a.pull-right{ href: edit_garden_path(garden), role: "button", id: "edit_garden_glyphicon" } + %a.text-right{ href: edit_garden_path(garden), role: "button", id: "edit_garden_glyphicon" } %span.glyphicon.glyphicon-pencil{ title: "Edit" } .panel-body{ id: "gardens_panel_body" } .row diff --git a/app/views/harvests/show.html.haml b/app/views/harvests/show.html.haml index c59dfc9fd..28e60243f 100644 --- a/app/views/harvests/show.html.haml +++ b/app/views/harvests/show.html.haml @@ -48,7 +48,7 @@ .row .col-md-6= render @harvest.default_photo .col-md-6 - = link_to 'View all photos >>', planting_photos_path(@harvest), class: 'pull-right' + = link_to 'View all photos >>', planting_photos_path(@harvest), class: 'text-right' .row - @harvest.photos.order(date_taken: :desc).limit(3).each do |photo| .col-md-3= render('photos/thumbnail', photo: photo) \ No newline at end of file diff --git a/app/views/members/_map.html.haml b/app/views/members/_map.html.haml index 711e4d9e0..77a46614e 100644 --- a/app/views/members/_map.html.haml +++ b/app/views/members/_map.html.haml @@ -1,6 +1,6 @@ - if member.latitude && member.longitude #membermap - %p.pull-right + %p.text-right See other members, plantings, seeds and more near = link_to member.location, place_path(member.location, anchor: "members") - else diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index fe59c0cbd..64f8ce6a6 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -3,7 +3,7 @@ -# %h3.panel-title -# = link_to seed, seed -# - if can? :edit, seed --# %a.pull-right{ href: edit_seed_path(seed), role: "button", id: "edit_seed_glyphicon" } +-# %a.text-right{ href: edit_seed_path(seed), role: "button", id: "edit_seed_glyphicon" } -# %span.glyphicon.glyphicon-pencil{ title: "Edit" } -# .panel-body -# .row From 586cdef0edb46e10feb7d7b81d9d56cd5344d14d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 19 May 2019 11:50:28 +1200 Subject: [PATCH 096/549] Tidy up comments display --- app/views/posts/_comments.html.haml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/posts/_comments.html.haml b/app/views/posts/_comments.html.haml index 91f2e6323..5efad7aae 100644 --- a/app/views/posts/_comments.html.haml +++ b/app/views/posts/_comments.html.haml @@ -1,11 +1,12 @@ %a{ name: "comments" } - if post.comments + %hr/ %h2 + = comment_icon = localize_plural(post.comments, Comment) - - post.comments.post_order.each do |c| - = render partial: "comments/single", locals: { comment: c } + - post.comments.post_order.each do |comment| + = render "comments/single", comment: comment - else %h2 There are no comments yet - From 1855d1318bad85620aea6f2fc963ac4d2ed1293c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 19 May 2019 11:50:40 +1200 Subject: [PATCH 097/549] pull-right becomes text-right --- app/views/plantings/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/plantings/show.html.haml b/app/views/plantings/show.html.haml index f8febae8a..785134dde 100644 --- a/app/views/plantings/show.html.haml +++ b/app/views/plantings/show.html.haml @@ -27,7 +27,7 @@ #{strip_tags(@planting.description)} %hr/ = render 'plantings/photos', photos: @photos, planting: @planting - .col-md-4.col-xs-12.pull-right + .col-md-4.col-xs-12.text-right = render 'plantings/owner', planting: @planting = render @planting.crop .row From d9a13232349dbb643ec8c75abae758e5d2d31169 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 19 May 2019 11:51:53 +1200 Subject: [PATCH 098/549] Tidy up gardens#show --- app/views/gardens/show.html.haml | 7 +++---- app/views/plantings/_badges.html.haml | 10 +++++----- app/views/plantings/_progress.html.haml | 11 ++++++++--- app/views/plantings/_thumbnail.html.haml | 21 +++++++++------------ 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index 5d7349e7b..a021ea0c0 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -47,8 +47,7 @@ .row - if @current_plantings.size.positive? - @current_plantings.each do |planting| - .col-xs-12.col-md-6 - = render "plantings/card", planting: planting + .col-xs-12.col-3= render "plantings/card", planting: planting - else .col-md-12 %p Nothing is currently planted here. @@ -84,7 +83,7 @@ = link_to othergarden, garden_path(othergarden) - unless @garden.owner.gardens.inactive.empty? - %h4= "Inactive gardens" + %h4 Inactive gardens %ul - @garden.owner.gardens.inactive.each do |othergarden| %li @@ -108,4 +107,4 @@ %h3= localize_plural(@garden.photos, Photo) .row - @garden.photos.includes(:owner).each do |photo| - .col-xs-6= render partial: 'photos/thumbnail', locals: { photo: photo } + .col-xs-6= render 'photos/thumbnail', photo: photo diff --git a/app/views/plantings/_badges.html.haml b/app/views/plantings/_badges.html.haml index 3c5493818..fd38ccb57 100644 --- a/app/views/plantings/_badges.html.haml +++ b/app/views/plantings/_badges.html.haml @@ -3,22 +3,22 @@ // Finish times - if planting.finish_is_predicatable? - if planting.super_late? - .badge.badge-super-late= t('.super_late') + %span.badge.badge-info.badge-super-late= t('.super_late') = planting_finish_button(planting) - elsif planting.late? - .badge.badge-late= t('.late_finishing') + %span.badge.badge-info.badge-late= t('.late_finishing') - else - .badge{'data-toggle': "tooltip", 'data-placement': "top", title: 'Predicted days until planting is finished'} + %span.badge.badge-info{'data-toggle': "tooltip", 'data-placement': "top", title: 'Predicted days until planting is finished'} = finished_icon = t('label.days_until_finished', number: days_from_now_to_finished(planting)) // Harvest times - unless planting.super_late? - if planting.harvest_time? - .badge.badge-harvest{'data-toggle': "tooltip", 'data-placement': "top", title: 'Planting is ready for harvesting now'} + %span.badge.badge-info.badge-harvest{'data-toggle': "tooltip", 'data-placement': "top", title: 'Planting is ready for harvesting now'} = harvest_icon = t('label.harvesting_now') - elsif planting.before_harvest_time? - .badge{'data-toggle': "tooltip", 'data-placement': "top", title: 'Predicted days until harvest'} + %span.badge.badge-info{'data-toggle': "tooltip", 'data-placement': "top", title: 'Predicted days until harvest'} = harvest_icon = t('label.days_until_harvest', number: days_from_now_to_first_harvest(planting)) diff --git a/app/views/plantings/_progress.html.haml b/app/views/plantings/_progress.html.haml index 65ee562b9..76146c6a6 100644 --- a/app/views/plantings/_progress.html.haml +++ b/app/views/plantings/_progress.html.haml @@ -1,3 +1,8 @@ -.progress - - if planting.percentage_grown.present? - = render "plantings/progress_bar", status: planting_status(planting), progress: planting.percentage_grown +- if planting.percentage_grown.present? + .progress + .progress-bar.bg-success{"aria-valuemax" => "100", "aria-valuemin" => "0", "aria-valuenow" => planting.percentage_grown, :role => "progressbar", :style => "width: #{planting.percentage_grown}%"} + + .float-left #{sprintf '%.0f', planting.percentage_grown}% + +- unless planting.finish_predicted_at.blank? + .float-right= planting.finish_predicted_at diff --git a/app/views/plantings/_thumbnail.html.haml b/app/views/plantings/_thumbnail.html.haml index b6bcad461..e3e7b6c35 100644 --- a/app/views/plantings/_thumbnail.html.haml +++ b/app/views/plantings/_thumbnail.html.haml @@ -1,12 +1,9 @@ -.planting - .card.thumbnail - .planting-thumbnail - /= render 'plantings/quick_actions', planting: planting - = render 'plantings/badges', planting: planting - .planting-thumbnail-image - = link_to image_tag(planting_image_path(planting), - alt: planting.crop, class: 'img'), - planting - .plantinginfo - .planting-name - = link_to planting, planting +.card.thumbnail + /= render 'plantings/quick_actions', planting: planting + = render 'plantings/badges', planting: planting + .planting-thumbnail-image + = link_to image_tag(planting_image_path(planting, full_size: true), + alt: planting.crop, class: 'img-card'), + planting + .card-body.plantinginfo + = link_to planting.crop, planting From e0e54d7c07c6658b47d51ccf4ac76aae56be315e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 19 May 2019 11:52:08 +1200 Subject: [PATCH 099/549] pull-right becomes text-right --- app/views/plantings/_quick_actions.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/plantings/_quick_actions.haml b/app/views/plantings/_quick_actions.haml index a190f7a9b..a2e4c6fac 100644 --- a/app/views/plantings/_quick_actions.haml +++ b/app/views/plantings/_quick_actions.haml @@ -1,5 +1,5 @@ - if can?(:edit, planting) - .planting-quick-actions.pull-right + .planting-quick-actions.text-right %a.btn#actionsMenu.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", href: "#"} -# =icon('fas', 'ellipsis-v') %ul.dropdown-menu.dropdown-menu-left{"aria-labelledby" => "actionsMenu"} From 57cd11e2ab10204c44bdb43ddf25d943753fe102 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 19 May 2019 11:52:35 +1200 Subject: [PATCH 100/549] tidy up members#show --- app/views/home/_seeds.html.haml | 6 +-- app/views/members/_roles.html.haml | 9 ---- app/views/members/_stats.html.haml | 23 ++++------ app/views/members/show.html.haml | 67 ++++++++++++++++-------------- 4 files changed, 47 insertions(+), 58 deletions(-) delete mode 100644 app/views/members/_roles.html.haml diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml index 8efd1d666..525b0dc6f 100644 --- a/app/views/home/_seeds.html.haml +++ b/app/views/home/_seeds.html.haml @@ -1,5 +1,3 @@ - cache cache_key_for(Seed) do - - seeds = Seed.current.tradable.includes(:owner, :crop).order(created_at: :desc).limit(6) - - if seeds.size.positive? - %h2= t('.title') - = render 'seeds/list', seeds: seeds + %h2= t('.title') + = render 'seeds/list', seeds: Seed.current.tradable.includes(:owner, :crop).order(created_at: :desc).limit(6) diff --git a/app/views/members/_roles.html.haml b/app/views/members/_roles.html.haml deleted file mode 100644 index cbfd0b576..000000000 --- a/app/views/members/_roles.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -%p - %strong Member Roles: - %br - - if member.role? :admin - Administrator - - if member.role? :crop_wrangler - Crop Wrangler - - unless (member.role?(:admin) || member.role?(:crop_wrangler)) - Member diff --git a/app/views/members/_stats.html.haml b/app/views/members/_stats.html.haml index 83760dfd1..b6eebc287 100644 --- a/app/views/members/_stats.html.haml +++ b/app/views/members/_stats.html.haml @@ -1,41 +1,36 @@ -%p - %strong Member since: - = member.created_at.to_s(:date) -%p - %strong Last Login: - = member.last_sign_in_at + + %h3 Activity - -%ul.activity-list - %li +%ul.list-group.list-group-flush + %li.list-group-item - if !member.plantings.empty? = link_to localize_plural(member.plantings, Planting), member_plantings_path(member) - else 0 plantings - %li + %li.list-group-item - if !member.harvests.empty? = link_to localize_plural(member.harvests, Harvest), member_harvests_path(member) - else 0 harvests - %li + %li.list-group-item - if !member.seeds.empty? = link_to localize_plural(member.seeds, Seed), member_seeds_path(member) - else 0 seeds - %li + %li.list-group-item - if !member.posts.empty? = link_to localize_plural(member.posts, Post), member_posts_path(member) - else 0 posts - %li + %li.list-group-item - if !member.followed.empty? = link_to localize_plural(member.followed, Follow), member_follows_path(member) - else 0 following - %li + %li.list-group-item - if !member.followers.empty? = link_to pluralize(member.followers.size, "follower"), member_followers_path(member) - else diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index ee2ce252a..d21e22c7c 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -9,46 +9,51 @@ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) -- content_for :buttonbar do - %p.btn-group - - if can? :update, @member - = link_to edit_member_registration_path, class: 'btn btn-default pull-right' do - = edit_icon - = t('members.edit_profile') +-# - content_for :buttonbar do +-# %p.btn-group +-# - if can? :update, @member +-# = link_to edit_member_registration_path, class: 'btn btn-default text-right' do +-# = edit_icon +-# = t('members.edit_profile') - - if can?(:create, Notification) && current_member != @member - = link_to 'Send message', new_notification_path(recipient_id: @member.id), class: 'btn btn-default' +-# - if can?(:create, Notification) && current_member != @member +-# = link_to 'Send message', new_notification_path(recipient_id: @member.id), class: 'btn btn-default' - - if current_member && current_member != @member # must be logged in, can't follow yourself - - follow = current_member.get_follow(@member) - - if !follow && can?(:create, Follow) # not already following - = link_to 'Follow', follows_path(followed: @member), method: :post, class: 'btn btn-default pull-right' - - if follow && can?(:destroy, follow) # already following - = link_to 'Unfollow', follow_path(follow), method: :delete, class: 'btn btn-default pull-right' +-# - if current_member && current_member != @member # must be logged in, can't follow yourself +-# - follow = current_member.get_follow(@member) +-# - if !follow && can?(:create, Follow) # not already following +-# = link_to 'Follow', follows_path(followed: @member), method: :post, class: 'btn btn-default text-right' +-# - if follow && can?(:destroy, follow) # already following +-# = link_to 'Unfollow', follow_path(follow), method: :delete, class: 'btn btn-default text-right' - content_for :member_rss_login_name, @member.login_name - content_for :member_rss_slug, @member.slug .row - = render partial: "map", locals: { member: @member } - .col-md-2.profile-sidebar - = render partial: "avatar", locals: { member: @member } - = render partial: "bio", locals: { member: @member } - = render partial: "roles", locals: { member: @member } - = render partial: "stats", locals: { member: @member } - = render partial: "contact", locals: { member: @member, - twitter_auth: @twitter_auth, - flickr_auth: @flickr_auth, - facebook_auth: @facebook_auth } + .col-md-2 + .card + .card-body + = render "avatar", member: @member + = render "bio", member: @member + %p + - @member.roles.each do |role| + %span.badge.badge-info= role.name + %p + %strong Member since + = @member.created_at.to_s(:date) + %p + %strong Last Login + = @member.last_sign_in_at + = render "stats", member: @member + .card-footer + = render "contact", member: @member, twitter_auth: @twitter_auth, + flickr_auth: @flickr_auth, + facebook_auth: @facebook_auth .col-md-10 - %ul.nav.nav-pills.nav-justified - %li.active - %a{ "data-toggle" => "tab", href: "#gardens" } Gardens - %li - %a{ "data-toggle" => "tab", href: "#harvests" } Harvests + = render "map", member: @member .tab-content.profile-activity .tab-pane.active#gardens - = render partial: "gardens", locals: { member: @member, gardens: @gardens } + = render "gardens", member: @member, gardens: @gardens .tab-pane#harvests - = render partial: "harvests", locals: { member: @member, harvests: @harvests } + = render "harvests", member: @member, harvests: @harvests From 4a78a307793bd87aa4254713e5bb160d9d5729f1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 19 May 2019 15:10:03 +1200 Subject: [PATCH 101/549] Put membet activity on their profile --- Gemfile | 1 + Gemfile.lock | 3 ++ app/controllers/members_controller.rb | 13 ++++- app/models/comment.rb | 4 ++ app/views/layouts/_header.bak | 78 +++++++++++++++++++++++++++ app/views/members/_gardens.html.haml | 54 ------------------- app/views/members/show.html.haml | 40 ++++++++++++-- 7 files changed, 132 insertions(+), 61 deletions(-) create mode 100644 app/views/layouts/_header.bak diff --git a/Gemfile b/Gemfile index 2e890b014..363fa5012 100644 --- a/Gemfile +++ b/Gemfile @@ -33,6 +33,7 @@ gem 'oj' # Speeds up json # planting and harvest predictions # based on median values for the crop gem 'active_median', '0.1.4' # needs postgresql update https://github.com/Growstuff/growstuff/issues/1757 +gem 'active_record_union' gem 'flickraw' gem 'jquery-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 37f02b6a8..8c94a0252 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -30,6 +30,8 @@ GEM addressable active_median (0.1.4) activerecord + active_record_union (1.3.0) + activerecord (>= 4.0) active_utils (3.3.16) activesupport (>= 4.2) i18n @@ -526,6 +528,7 @@ PLATFORMS DEPENDENCIES active_median (= 0.1.4) + active_record_union active_utils better_errors bluecloth diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index d2a4b74c1..60344877c 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -18,8 +18,17 @@ class MembersController < ApplicationController @flickr_auth = @member.auth('flickr') @facebook_auth = @member.auth('facebook') @posts = @member.posts - @gardens = @member.gardens.active.order(:name) - @harvests = @member.harvests + plantings = Planting.select(:id, "'planting' as event_type", 'planted_at as event_at', :owner_id, :crop_id, :slug) + harvests = Harvest.select(:id, "'harvest' as event_type", 'harvested_at as event_at', :owner_id, :crop_id, :slug) + posts = Post.select(:id, "'post' as event_type", 'posts.created_at as event_at', 'author_id as owner_id', 'null as crop_id', :slug) + comments = Comment.select(:id, "'comment' as event_type", 'comments.created_at as event_at', 'author_id as owner_id', 'null as crop_id', 'null as slug') + @activity = plantings + .union_all(harvests) + .union_all(posts) + .union_all(comments) + .where(owner_id: @member.id) + .order(event_at: :desc) + .limit(30) # The garden form partial is called from the "New Garden" tab; # it requires a garden to be passed in @garden. diff --git a/app/models/comment.rb b/app/models/comment.rb index 182e1e61f..3ff8eef4f 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -18,4 +18,8 @@ class Comment < ApplicationRecord ) end end + + def to_s + "#{author.login_name} commented on #{post.subject}" + end end diff --git a/app/views/layouts/_header.bak b/app/views/layouts/_header.bak new file mode 100644 index 000000000..b4f35ace5 --- /dev/null +++ b/app/views/layouts/_header.bak @@ -0,0 +1,78 @@ +-# .navbar.navbar-default.navbar-fixed-top{ role: "navigation" } +%nav.navbar.navbar-dark.default-color.bg-dark + .container-fluid + .navbar-header + %button.navbar-toggle{"data-target" => ".navbar-responsive-collapse", "data-toggle" => "collapse", type: "button"} + %span.glyphicon.glyphicon-menu-hamburger.text-white + %a.navbar-brand.hidden-xs{ href: root_path } + = image_tag("growstuff-brand.png", size: "200x50", alt: ENV['GROWSTUFF_SITE_NAME']) + %a.navbar-brand.visible-xs{ href: root_path } + = image_tag("growstuff-apple-touch-icon-precomposed.png", + size: "40x40", alt: ENV['GROWSTUFF_SITE_NAME']) + = render 'crops/search_bar' + + .navbar-collapse.collapse.navbar-responsive-collapse + %ul.nav.navbar-nav.navbar-right + %li.dropdown< + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path }= t('.crops') + %ul.dropdown-menu + %li= link_to t('.browse_crops'), crops_path + %li= link_to t('.seeds'), seeds_path + %li= link_to t('.plantings'), plantings_path + %li= link_to t('.harvests'), harvests_path + %li.dropdown< + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: members_path } + = t('.community') + %ul.dropdown-menu + %li= link_to t('.community_map'), places_path + %li= link_to t('.browse_members'), members_path + %li= link_to t('.posts'), posts_path + %li= link_to t('.forums'), forums_path + - if member_signed_in? + %li.dropdown< + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: root_path } + - if current_member.notifications.unread_count.positive? + = t('.your_stuff', unread_count: current_member.notifications.unread_count) + - else + = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) + %ul.dropdown-menu + %li + = link_to member_path(current_member) do + = member_icon + = t('.profile') + %li + = link_to member_gardens_path(current_member) do + = garden_icon + = t('.gardens') + %li + = link_to member_plantings_path(current_member) do + = planting_icon + = t('.plantings') + %li + = link_to member_harvests_path(current_member) do + = harvest_icon + = t('.harvest') + %li + = link_to member_seeds_path(current_member) do + = seed_icon + = t('.seeds') + %li= link_to t('.posts'), member_posts_path(current_member) + %li + - if current_member.notifications.unread_count.positive? + = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), + notifications_path) + - else + = link_to(t('.inbox'), notifications_path) + - if current_member.role?(:crop_wrangler) || current_member.role?(:admin) + %li.divider{ role: 'presentation' } + - if current_member.role?(:crop_wrangler) + %li= link_to t('.crop_wrangling'), wrangle_crops_path + - if current_member.role?(:admin) + %li= link_to t('.admin'), admin_path + + %li= link_to t('.sign_out'), destroy_member_session_path, method: :delete + + - else + %li= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' + %li= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' + diff --git a/app/views/members/_gardens.html.haml b/app/views/members/_gardens.html.haml index 5872f4926..e69de29bb 100644 --- a/app/views/members/_gardens.html.haml +++ b/app/views/members/_gardens.html.haml @@ -1,54 +0,0 @@ -.tabbable - %ul.nav.nav-tabs - - first_garden = true - - gardens.each do |g| - %li{ class: first_garden ? 'active' : '' } - - first_garden = false - = link_to display_garden_name(g), "#garden#{g.id}", 'data-toggle' => 'tab' - - if current_member == member - %li.navbar-right - = link_to new_garden_path, class: 'btn' do - Add New Garden - .tab-content{ style: "padding-top: 1em" } - - first_garden = true - - gardens.each do |g| - - %div{ class: ['tab-pane', first_garden ? 'active' : ''], id: "garden#{g.id}" } - - first_garden = false - - .container - :growstuff_markdown - #{ strip_tags g.description } - - unless g.description - .row - %p No description available yet. - - - if can? :edit, g - %p - Why not - = link_to 'tell us more.', edit_garden_path(g) - - - - if !g.photos.empty? || (can?(:edit, g) && can?(:create, Photo)) - .row - %h3 Photos - %p= localize_plural(g.photos, Photo) - .row - %ul.thumbnails - - g.photos.includes(:owner).each do |p| - .col-md-2.six-across - = render partial: 'photos/thumbnail', locals: { photo: p } - .row - - if can?(:create, Photo) && can?(:edit, g) - %p - = link_to "Add photo", new_photo_path(type: "garden", id: g.id), class: 'btn btn-primary' - - %h3 What's planted here? - .card-row - - unless g.featured_plantings.empty? - - g.featured_plantings.each.with_index do |planting| - .card - = render partial: "plantings/card", locals: { planting: planting } - - %p - = link_to "More about this garden...", url_for(g) diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index d21e22c7c..26f7b172d 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -52,8 +52,38 @@ .col-md-10 = render "map", member: @member - .tab-content.profile-activity - .tab-pane.active#gardens - = render "gardens", member: @member, gardens: @gardens - .tab-pane#harvests - = render "harvests", member: @member, harvests: @harvests + %h2 Activity + .list-group + - @activity.each do |event| + .list-group-item.list-group-item-action.flex-column.align-items-start.active{:href => "#!"} + .d-flex.w-100.justify-content-between + %h5 + - if event.event_type == 'planting' + - planting = Planting.find(event.id) + = planting_icon + planted + = link_to planting, planting + - elsif event.event_type == 'harvest' + - harvest = Harvest.find(event.id) + = harvest_icon + harvested + = link_to harvest, harvest + - elsif event.event_type == 'comment' + - comment = Comment.find(event.id) + = comment_icon + = link_to 'commented', comment + on + = link_to comment.post, comment.post + - elsif event.event_type == 'post' + - post = Post.find(event.id) + = blog_icon + wrote a post about + = link_to post, post + - else + = link_to event.event_type, event + %small #{time_ago_in_words(event.event_at)} ago + -# %p.mb-2 + -# Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius + -# blandit. + -# %small Donec id elit non mi porta. + From 7528a337cff0ee01341d8e38792e6ed892a82570 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 19 May 2019 15:10:31 +1200 Subject: [PATCH 102/549] Seeds to be in percy specs --- spec/features/percy/percy_spec.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index dd9d42f63..52f26d61e 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe 'Test with visual testing', type: :feature, js: true do - let(:member) { FactoryBot.create :member, login_name: 'percy', preferred_avatar_uri: gravatar } + let(:member) { FactoryBot.create :member, login_name: 'percy', preferred_avatar_uri: gravatar, location: 'Paris, France' } let(:someone_else) { FactoryBot.create :member, login_name: 'ruby', preferred_avatar_uri: gravatar2 } let(:gravatar) { 'http://www.gravatar.com/avatar/d021434aac03a7f7c7c0de60d07dad1c?size=150&default=identicon' } @@ -61,6 +61,9 @@ I noticed a couple of days ago on the way to work that there's a place near home planted_at: 1.year.ago, finished_at: 2.months.ago, sunniness: 'sun', planted_from: 'seed' end + + FactoryBot.create :seed, owner: member, tradeable_to: 'nationally' + FactoryBot.create :seed, owner: someone_else, tradeable_to: 'nationally' end after { Timecop.return } From dea6f36b0e22ac8f9c286cbf929a5fb7d8f8d326 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 19 May 2019 15:34:26 +1200 Subject: [PATCH 103/549] Fix filter posts by member --- app/controllers/posts_controller.rb | 2 +- app/views/posts/show.html.haml | 2 +- spec/controllers/posts_controller_spec.rb | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 47aa6bd18..395212829 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -8,7 +8,7 @@ class PostsController < ApplicationController # GET /posts.json # GET /posts.rss def index - @author = Member.find_by(slug: params[:author]) + @author = Member.find_by(slug: params[:member_slug]) @posts = posts respond_with(@posts) end diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index 4ef89d485..91143f0bd 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -31,7 +31,7 @@ %li.breadcrumb-item = link_to 'Home', root_path %li.breadcrumb-item= link_to @post.author, @post.author - %li.breadcrumb-item= link_to 'posts', posts_path(author: @post.author.slug) + %li.breadcrumb-item= link_to 'posts', posts_path(member_slug: @post.author.slug) %li.breadcrumb-item.active{"aria-current" => "page"}= @post.subject .row diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index 2dde4f8ae..09cf7b10a 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -8,6 +8,22 @@ describe PostsController do { author_id: member.id, subject: "blah", body: "blah blah" } end + describe '#index' do + before do + FactoryBot.create_list :post, 100 + FactoryBot.create_list :post, 5, author: member + end + describe "everyone's posts" do + before { get :index } + it {expect(assigns(:posts).size).to eq 12 } + end + describe "one member's posts" do + before { get :index, params: {member_slug: member.slug } } + it { expect(assigns(:posts).size).to eq 5 } + it { expect(assigns(:posts).first.author).to eq member } + end + end + describe "GET RSS feed" do it "returns an RSS feed" do get :index, format: "rss" From 4de9b2f5580fc89731893b71734ceb2d2b278c58 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 19 May 2019 15:34:37 +1200 Subject: [PATCH 104/549] fix bug in percy spec --- spec/features/percy/percy_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 52f26d61e..948d07562 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe 'Test with visual testing', type: :feature, js: true do - let(:member) { FactoryBot.create :member, login_name: 'percy', preferred_avatar_uri: gravatar, location: 'Paris, France' } + let(:member) { FactoryBot.create :member, login_name: 'percy', preferred_avatar_uri: gravatar } let(:someone_else) { FactoryBot.create :member, login_name: 'ruby', preferred_avatar_uri: gravatar2 } let(:gravatar) { 'http://www.gravatar.com/avatar/d021434aac03a7f7c7c0de60d07dad1c?size=150&default=identicon' } From f293661bbe6446f79c002e522ca289e0e51d42d5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 19 May 2019 15:34:51 +1200 Subject: [PATCH 105/549] seeds tidy up --- app/views/seeds/_list.html.haml | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/app/views/seeds/_list.html.haml b/app/views/seeds/_list.html.haml index 189ff7052..45715a1ce 100644 --- a/app/views/seeds/_list.html.haml +++ b/app/views/seeds/_list.html.haml @@ -1,16 +1,13 @@ - seeds.each do |seed| - - cache seed do - .col-lg-3.col-md-4.col-sm-3.col-xs-6 - .card - .view.overlay - = link_to seed do - = image_tag(seed_image_path(seed, full_size: true), alt: seed, class: 'card-img-top img-responsive') - .card-body.p-3 - %h5.card-title.font-weight-bold.fuchsia-rose-text.mb-0 - = link_to seed, seed - %p - %i #{seed.owner.location} - %p Will trade #{seed.tradable_to} - %p.float-right - = link_to seed.owner do - = image_tag(avatar_uri(seed.owner, 50), alt: '', class: 'img img-responsive avatar rounded') \ No newline at end of file + .card + .card-image + = link_to seed do + = image_tag(seed_image_path(seed, full_size: true), alt: seed, class: 'card-img-top img-responsive') + .card-body + %h5.card-title= link_to seed, seed + %p + %i #{seed.owner.location} + %p Will trade #{seed.tradable_to} + %p.float-right + = link_to seed.owner do + = image_tag(avatar_uri(seed.owner, 50), alt: '', class: 'img img-responsive avatar rounded') \ No newline at end of file From 47e9f38ccef1a35e26997c7564cd3980504d7f5d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 19 May 2019 15:35:14 +1200 Subject: [PATCH 106/549] Move badges on planting thumbnail --- app/views/plantings/_thumbnail.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/plantings/_thumbnail.html.haml b/app/views/plantings/_thumbnail.html.haml index e3e7b6c35..d8cd07c24 100644 --- a/app/views/plantings/_thumbnail.html.haml +++ b/app/views/plantings/_thumbnail.html.haml @@ -1,9 +1,9 @@ .card.thumbnail /= render 'plantings/quick_actions', planting: planting - = render 'plantings/badges', planting: planting .planting-thumbnail-image = link_to image_tag(planting_image_path(planting, full_size: true), alt: planting.crop, class: 'img-card'), planting - .card-body.plantinginfo + .card-body = link_to planting.crop, planting + = render 'plantings/badges', planting: planting From 5f1d65dfc03e7a8f641bdb2a52bdf62c3b85941e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 19 May 2019 15:36:45 +1200 Subject: [PATCH 107/549] typo. tradeable -> tradable --- spec/features/percy/percy_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 948d07562..e6b1f8fab 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -62,8 +62,8 @@ I noticed a couple of days ago on the way to work that there's a place near home sunniness: 'sun', planted_from: 'seed' end - FactoryBot.create :seed, owner: member, tradeable_to: 'nationally' - FactoryBot.create :seed, owner: someone_else, tradeable_to: 'nationally' + FactoryBot.create :seed, owner: member, tradable_to: 'nationally' + FactoryBot.create :seed, owner: someone_else, tradable_to: 'nationally' end after { Timecop.return } From 2e5445da3ee83f06e33ea006e7db21bdd3e98466 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 19 May 2019 15:46:42 +1200 Subject: [PATCH 108/549] Create some activity on the member's page --- spec/features/percy/percy_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index e6b1f8fab..c86afd20a 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -125,6 +125,11 @@ I noticed a couple of days ago on the way to work that there's a place near home end it 'loads another members#show' do + Factory.create :planting, author: someone_else, created_at: 30.days.ago, crop: tomato + Factory.create :planting, author: someone_else, created_at: 24.days.ago, crop: tomato + Factory.create :post, author: someone_else, created_at: 4.days.ago, subject: 'waiting for my tomatoes' + Factory.create :harvest, author: someone_else, created_at: 1.day.ago, crop: tomato + visit member_path(someone_else) Percy.snapshot(page, name: "#{prefix}/members#show") end From 8a2e5f1f54ea164ccbfc4929926bd85d77dbe20c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 19 May 2019 18:07:05 +1200 Subject: [PATCH 109/549] Fix percy spec --- spec/features/percy/percy_spec.rb | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index c86afd20a..955b19ea0 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -77,6 +77,18 @@ I noticed a couple of days ago on the way to work that there's a place near home describe 'crops' do it 'loads crops#show' do + FactoryBot.create :planting, planted_at: 2.months.ago, sunniness: 'shade', planted_from: 'seedling' + + planting = FactoryBot.create :planting, planted_at: 1.year.ago , sunniness: 'sun', planted_from: 'seed', crop: tomato + FactoryBot.create(:harvest, + crop: tomato, + plant_part: FactoryBot.create(:plant_part, name: 'berry'), + planting: planting, + harvested_at: 1.day.ago) + + post = FactoryBot.create :post, subject: 'tomatoes are delicious' + tomato.posts << post + visit crop_path(tomato) Percy.snapshot(page, name: "#{prefix}/crops#show") end @@ -125,10 +137,10 @@ I noticed a couple of days ago on the way to work that there's a place near home end it 'loads another members#show' do - Factory.create :planting, author: someone_else, created_at: 30.days.ago, crop: tomato - Factory.create :planting, author: someone_else, created_at: 24.days.ago, crop: tomato - Factory.create :post, author: someone_else, created_at: 4.days.ago, subject: 'waiting for my tomatoes' - Factory.create :harvest, author: someone_else, created_at: 1.day.ago, crop: tomato + FactoryBot.create :planting, owner: someone_else, created_at: 30.days.ago, crop: tomato + FactoryBot.create :planting, owner: someone_else, created_at: 24.days.ago, crop: tomato + FactoryBot.create :post, author: someone_else, created_at: 4.days.ago, subject: 'waiting for my tomatoes' + FactoryBot.create :harvest, owner: someone_else, created_at: 1.day.ago, crop: tomato visit member_path(someone_else) Percy.snapshot(page, name: "#{prefix}/members#show") From 9adca482d6b386398066ec8319ab30b723f0524b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 19 May 2019 20:34:46 +1200 Subject: [PATCH 110/549] member in percy spec located --- spec/features/percy/percy_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 955b19ea0..702f2cd72 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' describe 'Test with visual testing', type: :feature, js: true do let(:member) { FactoryBot.create :member, login_name: 'percy', preferred_avatar_uri: gravatar } - let(:someone_else) { FactoryBot.create :member, login_name: 'ruby', preferred_avatar_uri: gravatar2 } + let(:someone_else) { FactoryBot.create :edinburgh_member, login_name: 'ruby', preferred_avatar_uri: gravatar2 } let(:gravatar) { 'http://www.gravatar.com/avatar/d021434aac03a7f7c7c0de60d07dad1c?size=150&default=identicon' } let(:gravatar2) { 'http://www.gravatar.com/avatar/353d83d3677b142520987e1936fd093c?size=150&default=identicon' } @@ -90,6 +90,7 @@ I noticed a couple of days ago on the way to work that there's a place near home tomato.posts << post visit crop_path(tomato) + expect(page).to have_text 'tomato' Percy.snapshot(page, name: "#{prefix}/crops#show") end it 'loads crops#index' do From 0d9d7efbe7c4f86d0a0b226c0b2ad252b7ff52e7 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Sun, 19 May 2019 08:35:36 +0000 Subject: [PATCH 111/549] [CodeFactor] Apply fixes --- app/helpers/posts_helper.rb | 12 ++++++------ spec/controllers/posts_controller_spec.rb | 4 ++-- spec/features/percy/percy_spec.rb | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index c553b9bfc..62ef5d9e0 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -1,17 +1,17 @@ module PostsHelper def display_post_truncated(post) length = 300 - return truncate(strip_tags(post.body), length: length, separator: ' ', omission: '... ') { link_to "Read more", post_path(post) } + truncate(strip_tags(post.body), length: length, separator: ' ', omission: '... ') { link_to "Read more", post_path(post) } end def post_byline(post) byline = 'Posted by ' - if post.author - byline += link_to post.author.login_name, member_path(post.author) - else - byline += 'Member Deleted' - end + byline += if post.author + link_to post.author.login_name, member_path(post.author) + else + 'Member Deleted' + end if post.forum byline += ' in ' diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index 09cf7b10a..e490d2ff5 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -15,10 +15,10 @@ describe PostsController do end describe "everyone's posts" do before { get :index } - it {expect(assigns(:posts).size).to eq 12 } + it { expect(assigns(:posts).size).to eq 12 } end describe "one member's posts" do - before { get :index, params: {member_slug: member.slug } } + before { get :index, params: { member_slug: member.slug } } it { expect(assigns(:posts).size).to eq 5 } it { expect(assigns(:posts).first.author).to eq member } end diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 702f2cd72..b7665ade2 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -79,12 +79,12 @@ I noticed a couple of days ago on the way to work that there's a place near home it 'loads crops#show' do FactoryBot.create :planting, planted_at: 2.months.ago, sunniness: 'shade', planted_from: 'seedling' - planting = FactoryBot.create :planting, planted_at: 1.year.ago , sunniness: 'sun', planted_from: 'seed', crop: tomato + planting = FactoryBot.create :planting, planted_at: 1.year.ago, sunniness: 'sun', planted_from: 'seed', crop: tomato FactoryBot.create(:harvest, - crop: tomato, - plant_part: FactoryBot.create(:plant_part, name: 'berry'), - planting: planting, - harvested_at: 1.day.ago) + crop: tomato, + plant_part: FactoryBot.create(:plant_part, name: 'berry'), + planting: planting, + harvested_at: 1.day.ago) post = FactoryBot.create :post, subject: 'tomatoes are delicious' tomato.posts << post From d217282bf3ed931118369ceb6d3a33968c8e9444 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 21 May 2019 12:06:22 +1200 Subject: [PATCH 112/549] Add photos to activity --- app/controllers/members_controller.rb | 2 ++ app/views/members/show.html.haml | 32 ++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 60344877c..cb12f6221 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -22,10 +22,12 @@ class MembersController < ApplicationController harvests = Harvest.select(:id, "'harvest' as event_type", 'harvested_at as event_at', :owner_id, :crop_id, :slug) posts = Post.select(:id, "'post' as event_type", 'posts.created_at as event_at', 'author_id as owner_id', 'null as crop_id', :slug) comments = Comment.select(:id, "'comment' as event_type", 'comments.created_at as event_at', 'author_id as owner_id', 'null as crop_id', 'null as slug') + photos = Photo.select(:id, "'photo' as event_type", "photos.created_at as event_at", 'photos.owner_id', 'null as crop_id', 'null as slug') @activity = plantings .union_all(harvests) .union_all(posts) .union_all(comments) + .union_all(photos) .where(owner_id: @member.id) .order(event_at: :desc) .limit(30) diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 26f7b172d..484fe122d 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -62,7 +62,7 @@ - planting = Planting.find(event.id) = planting_icon planted - = link_to planting, planting + = link_to planting.crop, planting - elsif event.event_type == 'harvest' - harvest = Harvest.find(event.id) = harvest_icon @@ -79,6 +79,36 @@ = blog_icon wrote a post about = link_to post, post + - elsif event.event_type == 'photo' + - photo = Photo.find(event.id) + %p + = photo_icon + took a photo + = link_to photo, photo.title + %p + .float-left= image_tag photo.fullsize_url, width: 75, class: 'rounded shadow' + %p + %ul.associations + - photo.plantings.each do |planting| + %li + = planting_icon + = link_to t('photos.show.planting', planting: planting.to_s, owner: planting.owner.to_s), planting_path(planting) + + - photo.harvests.each do |harvest| + %li + = harvest_icon + = link_to t('photos.show.harvest', crop: harvest.crop.name, owner: harvest.owner.to_s), harvest_path(harvest) + + - photo.gardens.each do |garden| + %li + = garden_icon + = link_to t('photos.show.garden', garden: garden.to_s, owner: garden.owner.to_s), garden_path(garden) + + - photo.seeds.each do |seed| + %li + = seed_icon + = link_to t('photos.show.seed', seed: seed.to_s, owner: seed.owner.to_s), seed_path(seed) + - else = link_to event.event_type, event %small #{time_ago_in_words(event.event_at)} ago From bd897efccee5e3f9f89c9f6333611989ce897dbf Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 21 May 2019 12:06:52 +1200 Subject: [PATCH 113/549] Addprogress back to plantings --- app/views/plantings/_card.html.haml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/views/plantings/_card.html.haml b/app/views/plantings/_card.html.haml index f02729e21..b192ffbc7 100644 --- a/app/views/plantings/_card.html.haml +++ b/app/views/plantings/_card.html.haml @@ -3,3 +3,21 @@ = image_tag planting_image_path(planting, full_size: true), class: 'img-card', alt: planting .card-body.text-center %h5= link_to planting.crop, planting + .text-center= render 'plantings/badges', planting: planting + - if planting.percentage_grown.present? + .card-footer= render 'plantings/progress', planting: planting + -# - if can? :edit, planting + -# .card-footer + -# .dropup + -# %button#dropdownMenuButton.btn.btn-sm.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} + -# .dropdown-menu{"aria-labelledby" => "dropdownMenuButton"} + -# = planting_edit_button(planting) + -# = add_photo_button(planting) + + -# - if planting.active? + -# = planting_finish_button(planting) + -# = planting_harvest_button(planting) + -# = planting_save_seeds_button(planting) + + -# - if can? :destroy, planting + -# = delete_button(planting) \ No newline at end of file From d2e0331539532fb26169dc9f6de5aeb3d6be6564 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 21 May 2019 13:37:31 +1200 Subject: [PATCH 114/549] DRY the photos icon use --- app/views/photos/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 806284e6f..8d06e2f73 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -19,7 +19,7 @@ - if @crops.size.positive? %p= render @crops %p - %i.fas.fa-camera-retro + = photo_icon %strong Photo by = link_to @photo.owner, @photo.owner Taken on #{@photo.date_taken} From 3559780fb405d78c185b08fbe546ec7bed40f5f3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 21 May 2019 13:37:43 +1200 Subject: [PATCH 115/549] Plant something button --- app/helpers/buttons_helper.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 628799555..5893592a1 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,11 +1,19 @@ module ButtonsHelper include IconsHelper def garden_plant_something_button(garden) + return unless can? :edit, garden link_to new_planting_path(garden_id: garden.id), class: "btn btn-default" do planting_icon + ' ' + t('buttons.plant_something_here') end end + def plant_something_button + return unless can? :create, Planting + link_to new_planting_path, class: "btn btn-default" do + planting_icon + ' ' + t('buttons.plant_something') + end + end + def garden_mark_active_button(garden) link_to t('buttons.mark_as_active'), garden_path(garden, garden: { active: 1 }), From a8f17405842a69169d6de5b55275537776b4d40d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 21 May 2019 13:39:56 +1200 Subject: [PATCH 116/549] Re-instate the buttons --- app/views/shared/_global_actions.html.haml | 48 +++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 5d9254622..a69ad3936 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,27 +1,27 @@ --# - if signed_in? --# .row --# .col-md-12 --# .btn-group --# = link_to member_gardens_path(member_slug: current_member.slug), --# class: 'btn btn-default' do --# = garden_icon --# -# = t('.my_gardens') --# = link_to new_planting_path, --# class: 'btn btn-default' do --# = planting_icon --# -# = t('plantings.plant') +- if signed_in? + .row + .col-md-12 + .btn-group + = link_to member_gardens_path(member_slug: current_member.slug), + class: 'btn btn-default' do + = garden_icon + -# = t('.my_gardens') + = link_to new_planting_path, + class: 'btn btn-default' do + = planting_icon + -# = t('plantings.plant') --# = link_to new_harvest_path, --# class: 'btn btn-default' do --# = harvest_icon --# -# = t('harvests.harvest') + = link_to new_harvest_path, + class: 'btn btn-default' do + = harvest_icon + -# = t('harvests.harvest') --# = link_to new_seed_path, --# class: 'btn btn-default' do --# = seed_icon --# -# = t('buttons.save_seeds') + = link_to new_seed_path, + class: 'btn btn-default' do + = seed_icon + -# = t('buttons.save_seeds') --# = link_to new_post_path, --# class: 'btn btn-default' do --# = blog_icon --# -# = t 'posts.write_blog' \ No newline at end of file + = link_to new_post_path, + class: 'btn btn-default' do + = blog_icon + -# = t 'posts.write_blog' \ No newline at end of file From 7cb0002b37730d53ba39db81b83d2fd3fccc002f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 21 May 2019 14:04:11 +1200 Subject: [PATCH 117/549] Convert to scss --- .gitignore | 3 + app/assets/stylesheets/application.sass | 25 - app/assets/stylesheets/application.scss | 23 + app/assets/stylesheets/crops.sass | 13 - app/assets/stylesheets/crops.scss | 16 + app/assets/stylesheets/harvests.sass | 7 - app/assets/stylesheets/harvests.scss | 10 + app/assets/stylesheets/homepage.sass | 37 -- app/assets/stylesheets/homepage.scss | 44 ++ app/assets/stylesheets/leaflet_overrides.sass | 10 - app/assets/stylesheets/leaflet_overrides.scss | 13 + app/assets/stylesheets/members.sass | 22 - app/assets/stylesheets/members.scss | 28 + app/assets/stylesheets/overrides.sass | 409 -------------- app/assets/stylesheets/overrides.scss | 499 ++++++++++++++++++ app/assets/stylesheets/photos.sass | 27 - app/assets/stylesheets/photos.scss | 32 ++ app/assets/stylesheets/plantings.sass | 72 --- app/assets/stylesheets/plantings.scss | 109 ++++ app/assets/stylesheets/predictions.sass | 14 - app/assets/stylesheets/predictions.scss | 21 + app/assets/stylesheets/seeds.sass | 7 - app/assets/stylesheets/seeds.scss | 10 + app/assets/stylesheets/variables.sass | 57 -- app/assets/stylesheets/variables.scss | 57 ++ 25 files changed, 865 insertions(+), 700 deletions(-) delete mode 100644 app/assets/stylesheets/application.sass create mode 100644 app/assets/stylesheets/application.scss delete mode 100644 app/assets/stylesheets/crops.sass create mode 100644 app/assets/stylesheets/crops.scss delete mode 100644 app/assets/stylesheets/harvests.sass create mode 100644 app/assets/stylesheets/harvests.scss delete mode 100644 app/assets/stylesheets/homepage.sass create mode 100644 app/assets/stylesheets/homepage.scss delete mode 100644 app/assets/stylesheets/leaflet_overrides.sass create mode 100644 app/assets/stylesheets/leaflet_overrides.scss delete mode 100644 app/assets/stylesheets/members.sass create mode 100644 app/assets/stylesheets/members.scss delete mode 100644 app/assets/stylesheets/overrides.sass create mode 100644 app/assets/stylesheets/overrides.scss delete mode 100644 app/assets/stylesheets/photos.sass create mode 100644 app/assets/stylesheets/photos.scss delete mode 100644 app/assets/stylesheets/plantings.sass create mode 100644 app/assets/stylesheets/plantings.scss delete mode 100644 app/assets/stylesheets/predictions.sass create mode 100644 app/assets/stylesheets/predictions.scss delete mode 100644 app/assets/stylesheets/seeds.sass create mode 100644 app/assets/stylesheets/seeds.scss delete mode 100644 app/assets/stylesheets/variables.sass create mode 100644 app/assets/stylesheets/variables.scss diff --git a/.gitignore b/.gitignore index dfd273d9d..0cb26bd3b 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,6 @@ config/database.yml cc-test-reporter elasticsearch-*.deb elasticsearch-*.deb.sha512 + +app/assets/images/*.svg +app/assets/images/icons/*.svg diff --git a/app/assets/stylesheets/application.sass b/app/assets/stylesheets/application.sass deleted file mode 100644 index cba18af5c..000000000 --- a/app/assets/stylesheets/application.sass +++ /dev/null @@ -1,25 +0,0 @@ -@import 'material' -@import 'variables' -@import 'overrides' - - -@import 'jquery-ui/autocomplete' -@import 'bootstrap-datepicker' -@import 'leaflet' -@import 'leaflet.markercluster' - -@import 'predictions' -@import 'plantings' -@import 'members' -@import 'harvests' -@import 'seeds' -@import 'crops' - -@import 'homepage' -@import 'photos' - -// Font Awesome -@import 'font-awesome-sprockets' -@import 'font-awesome' -@import 'material_icons' - diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss new file mode 100644 index 000000000..4031e6db5 --- /dev/null +++ b/app/assets/stylesheets/application.scss @@ -0,0 +1,23 @@ +@import "material"; +@import "variables"; +@import "overrides"; + +@import "jquery-ui/autocomplete"; +@import "bootstrap-datepicker"; +@import "leaflet"; +@import "leaflet.markercluster"; + +@import "predictions"; +@import "plantings"; +@import "members"; +@import "harvests"; +@import "seeds"; +@import "crops"; + +@import "homepage"; +@import "photos"; + +// Font Awesome +@import "font-awesome-sprockets"; +@import "font-awesome"; +@import "material_icons"; diff --git a/app/assets/stylesheets/crops.sass b/app/assets/stylesheets/crops.sass deleted file mode 100644 index b5cc39b5e..000000000 --- a/app/assets/stylesheets/crops.sass +++ /dev/null @@ -1,13 +0,0 @@ -.planting - .crop-card - width: 100px - min-height: 300px - margin: 0.1em - height: 100% - - - .img-thumbnail - width: 100% - -.crop-photos - margin-left: 3em \ No newline at end of file diff --git a/app/assets/stylesheets/crops.scss b/app/assets/stylesheets/crops.scss new file mode 100644 index 000000000..646f1e4d7 --- /dev/null +++ b/app/assets/stylesheets/crops.scss @@ -0,0 +1,16 @@ +.planting { + .crop-card { + width: 100px; + min-height: 300px; + margin: 0.1em; + height: 100%; + } + + .img-thumbnail { + width: 100%; + } +} + +.crop-photos { + margin-left: 3em; +} diff --git a/app/assets/stylesheets/harvests.sass b/app/assets/stylesheets/harvests.sass deleted file mode 100644 index a4a6281c5..000000000 --- a/app/assets/stylesheets/harvests.sass +++ /dev/null @@ -1,7 +0,0 @@ -.harvest-cards - display: flex - flex: none - flex-wrap: wrap - .card - max-width: 200px - margin: 1em \ No newline at end of file diff --git a/app/assets/stylesheets/harvests.scss b/app/assets/stylesheets/harvests.scss new file mode 100644 index 000000000..e69a6e68b --- /dev/null +++ b/app/assets/stylesheets/harvests.scss @@ -0,0 +1,10 @@ +.harvest-cards { + display: flex; + flex: none; + flex-wrap: wrap; + + .card { + max-width: 200px; + margin: 1em; + } +} diff --git a/app/assets/stylesheets/homepage.sass b/app/assets/stylesheets/homepage.sass deleted file mode 100644 index 9c2b3a0c9..000000000 --- a/app/assets/stylesheets/homepage.sass +++ /dev/null @@ -1,37 +0,0 @@ -// let's condense the hero unit a little -.jumbotron - //padding-top: 30px - //padding-bottom: 30px - -// info under the main heading on homepage -.jumbotron .info - // padding-top: 15px - -// signup widget on homepage -.jumbotron .signup - background-color: lighten($green, 40%) - border: 1px solid lighten($green, 20%) - border-radius: 6px - line-height: 200% - padding: 15px - text-align: center - -.homepage-cards,.homepage-thumbnails - display: flex - flex: none - flex-wrap: wrap - margin: 0.5em - left: -0.5em - .card - width: 200px - min-height: 100px - margin: 0.5em - padding: 0 - left: -0.5em - - %h3.crop-name - font-size: 2.0em - - .thumbnail - margin: 0.5em - diff --git a/app/assets/stylesheets/homepage.scss b/app/assets/stylesheets/homepage.scss new file mode 100644 index 000000000..b75f13ee0 --- /dev/null +++ b/app/assets/stylesheets/homepage.scss @@ -0,0 +1,44 @@ +// let's condense the hero unit a little +.jumbotron { + //padding-top: 30px + //padding-bottom: 30px +} + +// info under the main heading on homepage +.jumbotron .info { + // padding-top: 15px +} + +// signup widget on homepage +.jumbotron .signup { + background-color: lighten($green, 40%); + border: 1px solid lighten($green, 20%); + border-radius: 6px; + line-height: 200%; + padding: 15px; + text-align: center; +} + +.homepage-cards, .homepage-thumbnails { + display: flex; + flex: none; + flex-wrap: wrap; + margin: 0.5em; + left: -0.5em; + + .card { + width: 200px; + min-height: 100px; + margin: 0.5em; + padding: 0; + left: -0.5em; + + %h3.crop-name { + font-size: 2em; + } + } + + .thumbnail { + margin: 0.5em; + } +} diff --git a/app/assets/stylesheets/leaflet_overrides.sass b/app/assets/stylesheets/leaflet_overrides.sass deleted file mode 100644 index 78a7dac7e..000000000 --- a/app/assets/stylesheets/leaflet_overrides.sass +++ /dev/null @@ -1,10 +0,0 @@ -.leaflet-popup-content-wrapper, -.leaflet-popup-tip - border: none - -.thumbnail - background: #fff !important - border: solid 1px whitesmoke - -.thumbnail .crop-thumbnail .cropinfo - padding-top: 14px diff --git a/app/assets/stylesheets/leaflet_overrides.scss b/app/assets/stylesheets/leaflet_overrides.scss new file mode 100644 index 000000000..aa69bb297 --- /dev/null +++ b/app/assets/stylesheets/leaflet_overrides.scss @@ -0,0 +1,13 @@ +.leaflet-popup-content-wrapper, +.leaflet-popup-tip { + border: none; +} + +.thumbnail { + background: #fff !important; + border: solid 1px whitesmoke; +} + +.thumbnail .crop-thumbnail .cropinfo { + padding-top: 14px; +} diff --git a/app/assets/stylesheets/members.sass b/app/assets/stylesheets/members.sass deleted file mode 100644 index 43da58188..000000000 --- a/app/assets/stylesheets/members.sass +++ /dev/null @@ -1,22 +0,0 @@ -.member-cards - display: flex - flex: none - flex-wrap: wrap - .card - max-width: 200px - margin: 1em - -.member-thumbnail - padding: .25em - margin: 1em - border-radius: 12px - height: 200px - - div - width: 5em - display: inline-block - vertical-align: top - -.member-thumbnail div~div - padding-left: 1em - width: 15em diff --git a/app/assets/stylesheets/members.scss b/app/assets/stylesheets/members.scss new file mode 100644 index 000000000..433d8ab0a --- /dev/null +++ b/app/assets/stylesheets/members.scss @@ -0,0 +1,28 @@ +.member-cards { + display: flex; + flex: none; + flex-wrap: wrap; + + .card { + max-width: 200px; + margin: 1em; + } +} + +.member-thumbnail { + padding: 0.25em; + margin: 1em; + border-radius: 12px; + height: 200px; + + div { + width: 5em; + display: inline-block; + vertical-align: top; + } +} + +.member-thumbnail div ~ div { + padding-left: 1em; + width: 15em; +} diff --git a/app/assets/stylesheets/overrides.sass b/app/assets/stylesheets/overrides.sass deleted file mode 100644 index 07bf5371d..000000000 --- a/app/assets/stylesheets/overrides.sass +++ /dev/null @@ -1,409 +0,0 @@ -//@import "bootstrap-sprockets" -//@import "bootstrap" -// this padding needs to be done before the responsive stuff is imported -body - background-color: $beige - font-family: $font-family-sans-serif - // padding-top: $navbar-height - -// Font Awesome -@import "font-awesome-sprockets" -@import "font-awesome" - -section - padding-top: 1em - margin: 0 -a - color: $green -a:hover - color: $white - background-color: $green - -span.badge - background-color: $brown - a - color: $white - -.list-inline > li.first - padding-left: 0px - -.activity-list - list-style-type: none - padding: 0 - -h2 - font-size: 150% - -h3 - font-size: 120% - -.main - padding-right: 1em - -// .navbar .navbar-form -// padding-top: 0 -// padding-bottom: 0 -// margin-right: 0 -// margin-left: 15px -// border: 0 -// -webkit-box-shadow: none -// box-shadow: none - -.img-square - object-fit: cover - height: 150px - width: 150px - -.img-card - object-fit: cover - height: 150px - width: 100% - -.img-responsive - max-width: 100% - - -.avatar - border-radius: 50% - z-index: 2 - position: relative - -.profile-sidebar - margin-top: -5rem - -.profile-activity - background: white - padding: 2em - margin-top: 2em - -.sidebar - border-left: 1px solid darken($beige, 10%) - margin-left: -1px - padding-left: 1em - -// this is used for eg. crops and members index pages -.six-across:nth-child(6n+1) - margin-left: 0px - -.three-across:nth-child(3n+1) - margin-left: 0px - clear: both - -// let's condense the hero unit a little -.jumbotron - background-color: darken($beige, 10%) - text-color: $white - padding-top: 30px - padding-bottom: 30px - -// info under the main heading on homepage -.jumbotron .info - //padding-top: 15px - padding: 0.5em - text-align: center - -// signup widget on homepage -.jumbotron .signup - background-color: lighten($green, 40%) - border: 1px solid lighten($green, 20%) - border-radius: 6px - line-height: 200% - padding: 15px - text-align: center - -// stats shown on homepage. eg. "999 members..." -p.stats - font-weight: bold - -.card-row - display: grid - grid-template-columns: 50% 50% - grid-gap: 25px - grid-row-gap: 5px - - -.progress - border-radius: 0 - .progress-bar-text - text-align: center - -.layout-actions - -#placesmap, #cropmap - height: 500px - -#membermap - height: 250px - z-index: 0 - -.location-not-set - height: 250px - width: 100% - background-image: image-url('location-not-set.en.png') - background-repeat: no-repeat - background-position: center - -.member-location - font-size: small - font-style: italic - - -.member-location a - color: $brown - -.associations - list-style-type: none - -.photo-thumbnail - padding: 0 - position: relative - - img - width: 100% - - .text - display: none - color: #000 - position: absolute - bottom: 0 - background: rgba(0, 0, 0, 0.8) - width: 100% - margin: 0 - - p - padding: 5px - margin: 0 - color: #fff - - &:hover - .text - display: block - -// .thumbnail -// // border: 1px solid lighten($green, 20%) -// text-align: center -// margin-bottom: 1.5em -// max-width: 160px -// //max-height: 220px -// //height: 180px - -// .seed-thumbnail -// height: 220px -// .seedinfo -// .seed-name -// font-size: 120% -// overflow: hidden - - -// .member-thumbnail -// text-align: left -// img -// height: 85px -// width: 85px -// max-width: 85px - -// .crop-thumbnail -// .cropinfo -// margin-top: 0.5em -// display: inline-block -// max-width: 100% -// white-space: nowrap -// line-height: 1em -// padding-bottom: 2px - -// .cropname -// overflow: hidden -// text-overflow: ellipsis -// font-size: 120% - - -// .scientificname -// font-size: small -// font-style: italic -// overflow: hidden -// text-overflow: ellipsis -// font-size: 70% - -// .plantingcount -// font-size: small -// .planting-lifespan -// font-size: 70% - -// .crop-name a -// padding-top: 2px - -// .scientific-name small -// margin-bottom: -2px - -li.crop-hierarchy - list-style-type: disc - -.navbar-brand - margin: 0px - padding: 0px - -.navbar-bottom - margin: 40px 0px 0px 0px !important - -.post-actions - margin-bottom: 1rem - -// footer -footer - #footer1, #footer2, #footer3 - text-align: left - padding-top: 1em - padding-bottom: 2em - ul - list-style-type: none - list-style-position: outside - padding-left: 0px - margin-left: 0px - - a - color: $navbar-default-link-color - text-decoration: none - - a:hover - color: $navbar-default-link-hover-color - - a:active - color: $navbar-default-link-active-color - - //.navbar-bottom.navbar - // border-radius: 0 - -// ensure footer is pushed to bottom of browser window - -#maincontainer - min-height: 80% - //padding: 50px - -#global-actions - padding-top: 10px - -html, body - height: 100% - -.member-image - border-radius: 50% - -// Autosuggest -.ui-autocomplete - background: white - //z-index: $zindex-tooltip - -.alert - a - font-weight: 800 - - -/* override "info" alert boxes to be green, not blue, on Growstuff */ -$state-info-text: darken($green, 10%) -$state-info-bg: lighten($green, 50%) - -/* and set "success" to be the same, as it was just very slightly - * different because the default bootstrap green is slightly different - * from ours */ -$state-success-text: darken($green, 10%) -$state-success-bg: lighten($green, 50%) - -.hide - display: none - -#add-sci_name-row, #remove-sci_name-row, #add-alt_name-row, #remove-alt_name-row - display: none - -.panel-footer - height: 6em - -.panel - .dl-horizontal - text-overflow: ellipsis - overflow: hidden - -.form-group.required .control-label:before - content: "* " - color: red - -.margin-bottom - margin-bottom: 1em - -.red - color: red - -.truncate - overflow: hidden - text-overflow: ellipsis - white-space: nowrap - -ul.plantings - list-style-type: none - -ul.thumbnail-buttons - list-style-type: none - text-align: right - - -.hover-wrapper .text - position: absolute - visibility: hidden - -.hover-wrapper:hover .text - visibility: visible - -.homepage-listing - padding-bottom: 6px - -.container - max-width: 1500px - -@include media-breakpoint-up(md) - .planting-thumbnail - dl.planting-attributes - width: 100% - - dt - text-align: left - width: 120px - dd - padding-left: 120px - margin-left: auto - - //.navbar .navbar-form - // width: 250px - -.form-page - text-align: center - .form-card - max-width: 500px - text-align: center - display: inline-block - padding: 1em - -// Overrides applying only to mobile view. This must be at the end of the overrides file. -@include media-breakpoint-up(sm) - .sidebar - margin-left: 0 - border-left: none - padding-left: 0 - - #map - height: 300px - - .navbar .nav > li - display: block - - .navbar .navbar-form - //width: 185px - padding-left: 0 - padding-right: 0 - .navbar-search - width: auto - - //.homepage - // .thumbnail - // height: 180px - - #maincontainer - padding: 10px diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss new file mode 100644 index 000000000..85169ce10 --- /dev/null +++ b/app/assets/stylesheets/overrides.scss @@ -0,0 +1,499 @@ +//@import "bootstrap-sprockets" +//@import "bootstrap" +// this padding needs to be done before the responsive stuff is imported +body { + background-color: $beige; + font-family: $font-family-sans-serif; + + // padding-top: $navbar-height +} + +// Font Awesome +@import "font-awesome-sprockets"; +@import "font-awesome"; + +section { + padding-top: 1em; + margin: 0; +} + +a { + color: $green; +} + +a:hover { + color: $white; + background-color: $green; +} + +span.badge { + background-color: $brown; + + a { + color: $white; + } +} + +.list-inline > li.first { + padding-left: 0px; +} + +.activity-list { + list-style-type: none; + padding: 0; +} + +h2 { + font-size: 150%; +} + +h3 { + font-size: 120%; +} + +.main { + padding-right: 1em; +} + +// .navbar .navbar-form +// padding-top: 0 +// padding-bottom: 0 +// margin-right: 0 +// margin-left: 15px +// border: 0 +// -webkit-box-shadow: none +// box-shadow: none + +.img-square { + object-fit: cover; + height: 150px; + width: 150px; +} + +.img-card { + object-fit: cover; + height: 150px; + width: 100%; +} + +.img-responsive { + max-width: 100%; +} + +.avatar { + border-radius: 50%; + z-index: 2; + position: relative; +} + +.profile-sidebar { + margin-top: -5rem; +} + +.profile-activity { + background: white; + padding: 2em; + margin-top: 2em; +} + +.sidebar { + border-left: 1px solid darken($beige, 10%); + margin-left: -1px; + padding-left: 1em; +} + +// this is used for eg. crops and members index pages +.six-across:nth-child(6n+1) { + margin-left: 0px; +} + +.three-across:nth-child(3n+1) { + margin-left: 0px; + clear: both; +} + +// let's condense the hero unit a little +.jumbotron { + background-color: darken($beige, 10%); + text-color: $white; + padding-top: 30px; + padding-bottom: 30px; +} + +// info under the main heading on homepage +.jumbotron .info { + //padding-top: 15px + padding: 0.5em; + text-align: center; +} + +// signup widget on homepage +.jumbotron .signup { + background-color: lighten($green, 40%); + border: 1px solid lighten($green, 20%); + border-radius: 6px; + line-height: 200%; + padding: 15px; + text-align: center; +} + +// stats shown on homepage. eg. "999 members..." +p.stats { + font-weight: bold; +} + +.card-row { + display: grid; + grid-template-columns: 50% 50%; + grid-gap: 25px; + grid-row-gap: 5px; +} + +.progress { + border-radius: 0; + + .progress-bar-text { + text-align: center; + } +} + +.layout-actions {} + +#placesmap, #cropmap { + height: 500px; +} + +#membermap { + height: 250px; + z-index: 0; +} + +.location-not-set { + height: 250px; + width: 100%; + background-image: image-url("location-not-set.en.png"); + background-repeat: no-repeat; + background-position: center; +} + +.member-location { + font-size: small; + font-style: italic; +} + +.member-location a { + color: $brown; +} + +.associations { + list-style-type: none; +} + +.photo-thumbnail { + padding: 0; + position: relative; + + img { + width: 100%; + } + + .text { + display: none; + color: #000; + position: absolute; + bottom: 0; + background: rgba(0, 0, 0, 0.8); + width: 100%; + margin: 0; + } + + p { + padding: 5px; + margin: 0; + color: #fff; + } + + &:hover { + .text { + display: block; + } + } +} + +// .thumbnail +// // border: 1px solid lighten($green, 20%) +// text-align: center +// margin-bottom: 1.5em +// max-width: 160px +// //max-height: 220px +// //height: 180px + +// .seed-thumbnail +// height: 220px +// .seedinfo +// .seed-name +// font-size: 120% +// overflow: hidden + +// .member-thumbnail +// text-align: left +// img +// height: 85px +// width: 85px +// max-width: 85px + +// .crop-thumbnail +// .cropinfo +// margin-top: 0.5em +// display: inline-block +// max-width: 100% +// white-space: nowrap +// line-height: 1em +// padding-bottom: 2px + +// .cropname +// overflow: hidden +// text-overflow: ellipsis +// font-size: 120% + +// .scientificname +// font-size: small +// font-style: italic +// overflow: hidden +// text-overflow: ellipsis +// font-size: 70% + +// .plantingcount +// font-size: small +// .planting-lifespan +// font-size: 70% + +// .crop-name a +// padding-top: 2px + +// .scientific-name small +// margin-bottom: -2px + +li.crop-hierarchy { + list-style-type: disc; +} + +.navbar-brand { + margin: 0px; + padding: 0px; +} + +.navbar-bottom { + margin: 40px 0px 0px 0px !important; +} + +.post-actions { + margin-bottom: 1rem; +} + +// footer +footer { + #footer1, #footer2, #footer3 { + text-align: left; + padding-top: 1em; + padding-bottom: 2em; + + ul { + list-style-type: none; + list-style-position: outside; + padding-left: 0px; + margin-left: 0px; + } + + a { + color: $navbar-default-link-color; + text-decoration: none; + } + + a:hover { + color: $navbar-default-link-hover-color; + } + + a:active { + color: $navbar-default-link-active-color; + } + } + + //.navbar-bottom.navbar + // border-radius: 0 +} + +// ensure footer is pushed to bottom of browser window + +#maincontainer { + min-height: 80%; + + //padding: 50px +} + +#global-actions { + padding-top: 10px; +} + +html, body { + height: 100%; +} + +.member-image { + border-radius: 50%; +} + +// Autosuggest +.ui-autocomplete { + background: white; + + //z-index: $zindex-tooltip +} + +.alert { + a { + font-weight: 800; + } +} + +/* override "info" alert boxes to be green, not blue, on Growstuff */ +$state-info-text: darken($green, 10%); +$state-info-bg: lighten($green, 50%); + +/* and set "success" to be the same, as it was just very slightly + * different because the default bootstrap green is slightly different + * from ours */ +$state-success-text: darken($green, 10%); +$state-success-bg: lighten($green, 50%); + +.hide { + display: none; +} + +#add-sci_name-row, #remove-sci_name-row, #add-alt_name-row, #remove-alt_name-row { + display: none; +} + +.panel-footer { + height: 6em; +} + +.panel { + .dl-horizontal { + text-overflow: ellipsis; + overflow: hidden; + } +} + +.form-group.required .control-label:before { + content: "* "; + color: red; +} + +.margin-bottom { + margin-bottom: 1em; +} + +.red { + color: red; +} + +.truncate { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +ul.plantings { + list-style-type: none; +} + +ul.thumbnail-buttons { + list-style-type: none; + text-align: right; +} + +.hover-wrapper .text { + position: absolute; + visibility: hidden; +} + +.hover-wrapper:hover .text { + visibility: visible; +} + +.homepage-listing { + padding-bottom: 6px; +} + +.container { + max-width: 1500px; +} + +@include media-breakpoint-up(md) { + .planting-thumbnail { + dl.planting-attributes { + width: 100%; + + dt { + text-align: left; + width: 120px; + } + + dd { + padding-left: 120px; + margin-left: auto; + } + } + } + + //.navbar .navbar-form + // width: 250px +} + + +.form-page { + text-align: center; + + .form-card { + max-width: 500px; + text-align: center; + display: inline-block; + padding: 1em; + } +} + +// Overrides applying only to mobile view. This must be at the end of the overrides file. +@include media-breakpoint-up(sm) { + .sidebar { + margin-left: 0; + border-left: none; + padding-left: 0; + } + + #map { + height: 300px; + } + + .navbar .nav > li { + display: block; + } + + .navbar .navbar-form { + //width: 185px + padding-left: 0; + padding-right: 0; + + .navbar-search { + width: auto; + } + } + + //.homepage + // .thumbnail + // height: 180px + + #maincontainer { + padding: 10px; + } +} diff --git a/app/assets/stylesheets/photos.sass b/app/assets/stylesheets/photos.sass deleted file mode 100644 index 93f697c58..000000000 --- a/app/assets/stylesheets/photos.sass +++ /dev/null @@ -1,27 +0,0 @@ -.photo-grid - background: #DDD - -.photo-grid-item - //background: #e6e5e4 - //border: 2px solid #b6b5b4 - //height: 100px - - -/* clear fix */ -.photo-grid:after - content: '' - display: block - clear: both - -/* ---- .photo-grid-item ---- */ - -.photo-grid-sizer, -.photo-grid-item - //width: 33.333% - -.photo-grid-item - float: left - -.photo-grid-item img - display: block - max-width: 100% diff --git a/app/assets/stylesheets/photos.scss b/app/assets/stylesheets/photos.scss new file mode 100644 index 000000000..c6f2d896a --- /dev/null +++ b/app/assets/stylesheets/photos.scss @@ -0,0 +1,32 @@ +.photo-grid { + background: #DDD; +} + +.photo-grid-item { + //background: #e6e5e4 + //border: 2px solid #b6b5b4 + //height: 100px +} + +/* clear fix */ +.photo-grid:after { + content: ""; + display: block; + clear: both; +} + +/* ---- .photo-grid-item ---- */ + +.photo-grid-sizer, +.photo-grid-item { + //width: 33.333% +} + +.photo-grid-item { + float: left; +} + +.photo-grid-item img { + display: block; + max-width: 100%; +} diff --git a/app/assets/stylesheets/plantings.sass b/app/assets/stylesheets/plantings.sass deleted file mode 100644 index e19e0c5b7..000000000 --- a/app/assets/stylesheets/plantings.sass +++ /dev/null @@ -1,72 +0,0 @@ -.planting - padding: 0.5em - .planting-badges - font-size: 100% - position: absolute - top: 3em - .badge-super-late - background-color: $red - .badge-harvest - background-color: $blue - .planting-super-late - .planting-late - background-color: $beige - - .planting-thumbnail - width: 150px - padding: 0em - margin-bottom: 0.5em - margin-top: 0.5em - - .badge - font-size: 100% - .planting-full-badges - .badge - font-size: 200% - - .planting-name - position: relative - text-align: center - top: 0em - .planting-quick-actions - position: absolute - //Mine - top: 0px - left: 130px - //Upstream - //left: 142px - //top: 6px - - .planting-thumbnail-photo - height: 150px - - dl.planting-attributes - dt - text-align: left - dd - margin-left: auto - -.planting-facts - display: flex - flex: none - flex-wrap: wrap - margin: 0.5em - .fact - text-align: center - height: 160px - width: 160px - border: 1px solid lighten($green, 20%) - border-radius: 5% - background: $white - padding: 1em - margin: 0.5em - left: -0.5em - strong - font-size: 3em - font-align: center - h3 - padding-top: 1em - span - display: block - img - height: 50% diff --git a/app/assets/stylesheets/plantings.scss b/app/assets/stylesheets/plantings.scss new file mode 100644 index 000000000..cf06c1bb9 --- /dev/null +++ b/app/assets/stylesheets/plantings.scss @@ -0,0 +1,109 @@ +.planting { + padding: 0.5em; + + .planting-badges { + font-size: 100%; + position: absolute; + top: 3em; + + .badge-super-late { + background-color: $red; + } + + .badge-harvest { + background-color: $blue; + } + + .planting-super-late {} + + .planting-late { + background-color: $beige; + } + } + + .planting-thumbnail { + width: 150px; + padding: 0em; + margin-bottom: 0.5em; + margin-top: 0.5em; + + .badge { + font-size: 100%; + } + } + + .planting-full-badges { + .badge { + font-size: 200%; + } + } + + .planting-name { + position: relative; + text-align: center; + top: 0em; + } + + .planting-quick-actions { + position: absolute; + + //Mine + top: 0px; + left: 130px; + + //Upstream + //left: 142px + //top: 6px + + } + + .planting-thumbnail-photo { + height: 150px; + } + + dl.planting-attributes { + dt { + text-align: left; + } + + dd { + margin-left: auto; + } + } +} + +.planting-facts { + display: flex; + flex: none; + flex-wrap: wrap; + margin: 0.5em; + + .fact { + text-align: center; + height: 160px; + width: 160px; + border: 1px solid lighten($green, 20%); + border-radius: 5%; + background: $white; + padding: 1em; + margin: 0.5em; + left: -0.5em; + + strong { + font-size: 3em; + font-align: center; + } + + h3 { + padding-top: 1em; + } + + span { + display: block; + } + + img { + height: 50%; + } + } +} diff --git a/app/assets/stylesheets/predictions.sass b/app/assets/stylesheets/predictions.sass deleted file mode 100644 index 0cea3bdf2..000000000 --- a/app/assets/stylesheets/predictions.sass +++ /dev/null @@ -1,14 +0,0 @@ -.predictions - .predictions-card - text-align: center - max-width: 200px - border: 1px solid lighten($green, 20%) - border-radius: 5% - background: $white - margin: 1em - strong - font-size: 4em - font-align: center - h3 - span - display: block diff --git a/app/assets/stylesheets/predictions.scss b/app/assets/stylesheets/predictions.scss new file mode 100644 index 000000000..c1d9860a8 --- /dev/null +++ b/app/assets/stylesheets/predictions.scss @@ -0,0 +1,21 @@ +.predictions { + .predictions-card { + text-align: center; + max-width: 200px; + border: 1px solid lighten($green, 20%); + border-radius: 5%; + background: $white; + margin: 1em; + + strong { + font-size: 4em; + font-align: center; + } + + h3 {} + + span { + display: block; + } + } +} diff --git a/app/assets/stylesheets/seeds.sass b/app/assets/stylesheets/seeds.sass deleted file mode 100644 index 987324aac..000000000 --- a/app/assets/stylesheets/seeds.sass +++ /dev/null @@ -1,7 +0,0 @@ -.seed-cards - display: flex - flex: none - flex-wrap: wrap - .card - max-width: 200px - margin: 1em \ No newline at end of file diff --git a/app/assets/stylesheets/seeds.scss b/app/assets/stylesheets/seeds.scss new file mode 100644 index 000000000..f9c02e8ef --- /dev/null +++ b/app/assets/stylesheets/seeds.scss @@ -0,0 +1,10 @@ +.seed-cards { + display: flex; + flex: none; + flex-wrap: wrap; + + .card { + max-width: 200px; + margin: 1em; + } +} diff --git a/app/assets/stylesheets/variables.sass b/app/assets/stylesheets/variables.sass deleted file mode 100644 index 6b03469bd..000000000 --- a/app/assets/stylesheets/variables.sass +++ /dev/null @@ -1,57 +0,0 @@ -// Use this file to override Twitter Bootstrap variables or define own variables. - -// Import original variables so they can be used in overrides -@import 'bootstrap/variables.scss' -//$screen-md-min: 1028px - -// Base colours -$beige: #f3f1ee -$brown: #413f3b - -$green: #5f8e43 -$blue: #2f4365 -$red: #ff4d43 -$orange: #ffa500 -$yellow: #b2935c -$white: #ffffff - -$body-bg: $beige -$text-color: $brown -$link-color: $green -$graph-hover: $orange - -$brand-primary: $green - -$font-family-sans-serif: "Helvetica Neue", Helvetica, Arial, sans-serif -$font-family-serif: Georgia, "Times New Roman", Times, serif -$font-family-mono: Monaco, Menlo, Consolas, "Courier New", monospace - -$font-size-base: 14px -$font-family-base: $font-family-sans-serif -$line-height-base: 1.5 -$alt-font-family: $font-family-serif - -$headings-font-family: $font-family-sans-serif -$headings-font-weight: bold // instead of browser default, bold -$headings-color: inherit // empty to use BS default, $textColor - -// Hero unit -$jumbotron-bg: darken($body-bg, 10%) - -// Nav bar -$navbar-default-bg: $brown -$navbar-default-bg-highlight: $brown -$navbar-default-color: $beige -$navbar-default-link-color: darken($beige, 20%) -$navbar-default-link-hover-color: $beige -$navbar-default-link-active-color: darken($beige,80%) -$navbar-default-brand-color: lighten($green, 20%) - -// Top nav collapse threshold -//$grid-float-breakpoint: $screen-md-min - -$dropdown-bg: lighten($beige, 10%) -$dropdown-link-color: $brown -$dropdown-link-hover-color: $brown -$dropdown-link-hover-bg: lighten($green, 50%) - diff --git a/app/assets/stylesheets/variables.scss b/app/assets/stylesheets/variables.scss new file mode 100644 index 000000000..2994e991b --- /dev/null +++ b/app/assets/stylesheets/variables.scss @@ -0,0 +1,57 @@ +// Use this file to override Twitter Bootstrap variables or define own variables. + +// Import original variables so they can be used in overrides +@import "bootstrap/variables.scss"; + +//$screen-md-min: 1028px + +// Base colours +$beige: #f3f1ee; +$brown: #413f3b; + +$green: #5f8e43; +$blue: #2f4365; +$red: #ff4d43; +$orange: #ffa500; +$yellow: #b2935c; +$white: #ffffff; + +$body-bg: $beige; +$text-color: $brown; +$link-color: $green; +$graph-hover: $orange; + +$brand-primary: $green; + +$font-family-sans-serif: "Helvetica Neue", Helvetica, Arial, sans-serif; +$font-family-serif: Georgia, "Times New Roman", Times, serif; +$font-family-mono: Monaco, Menlo, Consolas, "Courier New", monospace; + +$font-size-base: 14px; +$font-family-base: $font-family-sans-serif; +$line-height-base: 1.5; +$alt-font-family: $font-family-serif; + +$headings-font-family: $font-family-sans-serif; +$headings-font-weight: bold; +$headings-color: inherit; + +// Hero unit +$jumbotron-bg: darken($body-bg, 10%); + +// Nav bar +$navbar-default-bg: $brown; +$navbar-default-bg-highlight: $brown; +$navbar-default-color: $beige; +$navbar-default-link-color: darken($beige, 20%); +$navbar-default-link-hover-color: $beige; +$navbar-default-link-active-color: darken($beige, 80%); +$navbar-default-brand-color: lighten($green, 20%); + +// Top nav collapse threshold +//$grid-float-breakpoint: $screen-md-min + +$dropdown-bg: lighten($beige, 10%); +$dropdown-link-color: $brown; +$dropdown-link-hover-color: $brown; +$dropdown-link-hover-bg: lighten($green, 50%); From 6216601d2a3911d56c129bc4078bc1ed778b18aa Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 22 May 2019 16:53:14 +1200 Subject: [PATCH 118/549] Tidy up plantings#new --- Gemfile | 3 + Gemfile.lock | 4 + app/assets/stylesheets/application.scss | 1 + app/views/plantings/_form.html.haml | 110 +++++++++--------------- 4 files changed, 50 insertions(+), 68 deletions(-) diff --git a/Gemfile b/Gemfile index 363fa5012..a6373f97b 100644 --- a/Gemfile +++ b/Gemfile @@ -83,6 +83,9 @@ gem 'geocoder', '1.4.9' # TODO: Fails on version 1.5.0. Needs investigation # For easy calendar selection gem 'bootstrap-datepicker-rails' +# DRY-er easier bootstrap 4 forms +gem "bootstrap_form", ">= 4.2.0" + # For connecting to other services (eg Twitter) gem 'omniauth', '~> 1.3' gem 'omniauth-facebook' diff --git a/Gemfile.lock b/Gemfile.lock index a9c51362a..aa292da60 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -77,6 +77,9 @@ GEM bootstrap-kaminari-views (0.0.5) kaminari (>= 0.13) rails (>= 3.1) + bootstrap_form (4.2.0) + actionpack (>= 5.0) + activemodel (>= 5.0) builder (3.2.3) bullet (6.0.0) activesupport (>= 3.0.0) @@ -536,6 +539,7 @@ DEPENDENCIES bootstrap (= 4.1.1) bootstrap-datepicker-rails bootstrap-kaminari-views + bootstrap_form (>= 4.2.0) bullet bundler (>= 1.1.5) byebug diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 4031e6db5..1fa07ad01 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -21,3 +21,4 @@ @import "font-awesome-sprockets"; @import "font-awesome"; @import "material_icons"; +@import 'rails_bootstrap_forms'; \ No newline at end of file diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml index d7cadf83d..8aa5da484 100644 --- a/app/views/plantings/_form.html.haml +++ b/app/views/plantings/_form.html.haml @@ -1,11 +1,11 @@ .card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 - .card-body + .card-header - if content_for? :title %h1.h2-responsive.text-center %strong=yield :title - = required_field_help_text + = bootstrap_form_for(@planting) do |f| + .card-body - = form_for(@planting, html: { class: "form-horizontal", role: "form" }) do |f| - if @planting.errors.any? #error_explanation %h2 @@ -15,70 +15,44 @@ - @planting.errors.full_messages.each do |msg| %li= msg - .form-group.required - = f.label :crop, 'What did you plant?', class: 'control-label col-md-2' - .col-md-8 - - if @seed.present? - = link_to @seed, seed_path(@seed) - = f.hidden_field :parent_seed_id, value: @seed.id - - else - = auto_suggest @planting, :crop, class: 'form-control', default: @crop - %span.help-inline - Can't find what you're looking for? - = link_to "Request new crops.", new_crop_path - .form-group.required - = f.label :garden_id, 'Where did you plant it?', class: 'control-label col-md-2' - .col-md-8 - = collection_select(:planting, :garden_id, - current_member.gardens.active.order_by_name, - :id, :name, - selected: @planting.garden_id || @garden.id, - class: 'form-control') - %span.help-inline - = link_to "Add a garden.", new_garden_path - .form-group - = f.label :planted_at, 'When?', class: 'control-label col-md-2' - .col-md-2 - = f.text_field :planted_at, - value: @planting.planted_at ? @planting.planted_at.to_s(:ymd) : '', - class: 'add-datepicker form-control' - = render partial: 'shared/form_optional' - .form-group - = f.label :quantity, 'How many?', class: 'control-label col-md-2' - .col-md-2 - = f.number_field :quantity, class: 'form-control' - = render partial: 'shared/form_optional' - .form-group - = f.label :planted_from, 'Planted from:', class: 'control-label col-md-2' - .col-md-8 - = f.select(:planted_from, Planting::PLANTED_FROM_VALUES, { include_blank: '' }, class: 'form-control') - = render partial: 'shared/form_optional' - .form-group - = f.label :sunniness, 'Sun or shade?', class: 'control-label col-md-2' - .col-md-8 - = f.select(:sunniness, Planting::SUNNINESS_VALUES, { include_blank: '' }, class: 'form-control') - = render partial: 'shared/form_optional' - .form-group - = f.label :description, 'Tell us more about it', class: 'control-label col-md-2' - .col-md-8 - = f.text_area :description, rows: 6, class: 'form-control' - = render partial: 'shared/form_optional' - .form-group - = f.label :finished, 'Mark as finished', class: 'control-label col-md-2' - .col-md-8 - = f.check_box :finished - = render partial: 'shared/form_optional' - %span.help-block - = t('.finish_helper') + = f.label :crop, 'What did you plant?' + - if @seed.present? + = link_to @seed, seed_path(@seed) + = f.hidden_field :parent_seed_id, value: @seed.id + - else + = auto_suggest @planting, :crop, class: 'form-control', default: @crop + %span.help-inline + Can't find what you're looking for? + = link_to "Request new crops.", new_crop_path - .form-group - = f.label :finished_at, 'Finished date', class: 'control-label col-md-2' - .col-md-2 + .row + .col-md-8 + = f.collection_radio_buttons(:garden_id, + @planting.owner.gardens.active.order_by_name, :id, :name, required: true, + label: 'Where did you plant it?') + = link_to "Add a garden.", new_garden_path + .col-md-4 + = f.text_field :planted_at, + value: @planting.planted_at ? @planting.planted_at.to_s(:ymd) : '', + class: 'add-datepicker', label: 'When?' + -# = render partial: 'shared/form_optional' + + .row + .col-md-4= f.select(:planted_from, Planting::PLANTED_FROM_VALUES, { include_blank: '' }, label: 'Planted from') + .col-md-4= f.select(:sunniness, Planting::SUNNINESS_VALUES, { include_blank: '' }, label: 'Sun or shade?') + .col-md-4= f.number_field :quantity, label: 'How many?' + = f.text_area :description, rows: 6, label: 'Tell us more about it' + + .row + .col-md-6 + = f.check_box :finished, label: 'Mark as finished' + %span.help-block= t('.finish_helper') + .col-md-6 = f.text_field :finished_at, - value: @planting.finished_at ? @planting.finished_at.to_s(:ymd) : '', - class: 'add-datepicker form-control', - placeholder: 'optional' - = render partial: 'shared/form_optional' - .form-group - .form-actions.col-md-offset-2.col-md-8 - = f.submit 'Save', class: 'btn btn-primary' + value: @planting.finished_at ? @planting.finished_at.to_s(:ymd) : '', + class: 'add-datepicker', + label: 'Finished date', + placeholder: 'optional' + + .card-footer + .text-right= f.submit 'Save' From a43b2858d433b12598c8164e2c8f148fed6d5027 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 23 May 2019 22:44:18 +1200 Subject: [PATCH 119/549] harvest form tidy up --- app/views/harvests/_form.html.haml | 80 ++++++++++++------------------ 1 file changed, 31 insertions(+), 49 deletions(-) diff --git a/app/views/harvests/_form.html.haml b/app/views/harvests/_form.html.haml index c1e5af31f..99e27afdb 100644 --- a/app/views/harvests/_form.html.haml +++ b/app/views/harvests/_form.html.haml @@ -1,73 +1,55 @@ .card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 - .card-body + .card-header - if content_for? :title %h1.h2-responsive.text-center %strong=yield :title + .card-body = required_field_help_text - = form_for(@harvest, html: { class: "form-horizontal", role: :form }) do |f| + = bootstrap_form_for(@harvest) do |f| - if @harvest.errors.any? #error_explanation - %h2 - = pluralize(@harvest.errors.size, "error") - prohibited this harvest from being saved:" + %h2 #{pluralize(@harvest.errors.size, "error")} prohibited this harvest from being saved:" %ul - @harvest.errors.full_messages.each do |msg| %li= msg - .form-group.required - = f.label :crop, 'What did you harvest?', class: 'control-label col-md-2' - - if @planting - .col-md-8 + .row + .col-8 + = f.label :crop, 'What did you harvest?' + - if @planting = link_to @planting.crop.name, planting_path(@planting) from = link_to @planting.garden.name, garden_path(@planting.garden) = f.hidden_field :planting_id, value: @planting.id - - else - .col-md-4 - = auto_suggest @harvest, :crop, class: 'form-control col-md-2', default: @crop + - else + = auto_suggest @harvest, :crop, class: 'form-control', default: @crop + - unless @planting + %span.help-block.col-md-8 + Can't find what you're looking for? + = link_to "Request new crops.", new_crop_path - .col-md-4 - = collection_select(:harvest, :plant_part_id, PlantPart.all, - :id, :name, { selected: @harvest.plant_part_id }, - class: 'form-control', prompt: 'e.g. fruit', required: "required") - - unless @planting - %span.help-block.col-md-8 - Can't find what you're looking for? - = link_to "Request new crops.", new_crop_path + .col-4 + = f.select :plant_part_id, PlantPart.all.collect {|p| [ p.name, p.id ] },include_blank: '', prompt: 'e.g. fruit', required: true, selected: @harvest.plant_part_id, required: true - .form-group - = f.label :harvested_at, 'When?', class: 'control-label col-md-2' - .col-md-2 - = f.text_field :harvested_at, value: @harvest.harvested_at ? @harvest.harvested_at.to_s(:ymd) : '', - class: 'add-datepicker form-control' - = render partial: 'shared/form_optional' + = f.text_field :harvested_at, value: @harvest.harvested_at ? @harvest.harvested_at.to_s(:ymd) : '', + class: 'add-datepicker', label: 'When?' - .form-group - = f.label :quantity, 'How many?', class: 'control-label col-md-2' - .col-md-2 - -# Some browsers (eg Firefox for Android) assume "number" means - -# "integer" unless you specify step="any": - -# http://blog.isotoma.com/2012/03/html5-input-typenumber-and-decimalsfloats-in-chrome/ - = f.number_field :quantity, class: 'input-small form-control', step: 'any' - = render partial: 'shared/form_optional' - .col-md-2 + -# Some browsers (eg Firefox for Android) assume "number" means + -# "integer" unless you specify step="any": + -# http://blog.isotoma.com/2012/03/html5-input-typenumber-and-decimalsfloats-in-chrome/ + .row + .col-4 + = f.number_field :quantity, class: 'input-small form-control', step: 'any', label: 'How many?' + .col-8 = f.select(:unit, Harvest::UNITS_VALUES, { include_blank: false }, class: 'input-medium form-control') - - .form-group - = f.label :weight_quantity, 'Weighing (in total):', class: 'control-label col-md-2' - .col-md-2 + .row + .col-4 = f.number_field :weight_quantity, class: 'input-small form-control', step: 'any' - = render partial: 'shared/form_optional' - .col-md-2 + .col-8 = f.select(:weight_unit, Harvest::WEIGHT_UNITS_VALUES, { include_blank: false }, class: 'form-control') - .form-group - = f.label :description, 'Notes', class: 'control-label col-md-2' - .col-md-8 - = f.text_area :description, rows: 6, class: 'form-control' - = render partial: 'shared/form_optional' + = f.text_area :description, rows: 6, label: 'Notes' - .form-group - .form-actions.col-md-offset-2.col-md-8 - = f.submit 'Save', class: 'btn btn-primary' + + .text-right= f.submit 'Save' From 2f4a3fdceec43f6945b9c516e3e7ed450776c939 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 23 May 2019 22:54:38 +1200 Subject: [PATCH 120/549] tidy up seeds form --- app/views/seeds/_form.html.haml | 132 +++++++++++--------------------- 1 file changed, 45 insertions(+), 87 deletions(-) diff --git a/app/views/seeds/_form.html.haml b/app/views/seeds/_form.html.haml index 3746c0725..0daf2a17e 100644 --- a/app/views/seeds/_form.html.haml +++ b/app/views/seeds/_form.html.haml @@ -5,7 +5,7 @@ %strong=yield :title = required_field_help_text - = form_for(@seed, html: { class: "form-horizontal", role: "form" }) do |f| + = bootstrap_form_for(@seed) do |f| - if @seed.errors.any? #error_explanation %h2 @@ -14,90 +14,48 @@ %ul - @seed.errors.full_messages.each do |msg| %li= msg - .form-group.required - = f.label :crop, 'Crop:', class: 'control-label col-md-2' - .col-md-8 - - if @planting - = link_to @planting, planting_path(@planting) - = f.hidden_field :parent_planting_id, value: @planting.id - - else - = auto_suggest @seed, :crop, class: 'form-control', default: @crop - %span.help-inline - Can't find what you're looking for? - = link_to "Request new crops.", new_crop_path - .form-group - = f.label :quantity, 'Quantity:', class: 'control-label col-md-2' - .col-md-2 - = f.number_field :quantity, class: 'form-control' - = render partial: 'shared/form_optional' - .form-group - = f.label :plant_before, 'Plant before:', class: 'control-label col-md-2' - .col-md-2 - = f.text_field :plant_before, class: 'add-datepicker form-control', - value: @seed.plant_before ? @seed.plant_before.to_s(:ymd) : '' - = render partial: 'shared/form_optional' - .form-group - = f.label :finished, 'Mark as finished', class: 'control-label col-md-2' - .col-md-8 - = f.check_box :finished - = render partial: 'shared/form_optional' - %span.help-block - = t('.finish_helper') - .form-group - = f.label :finished_at, 'Finished at:', class: 'control-label col-md-2' - .col-md-2 - = f.text_field :finished_at, class: 'add-datepicker form-control', - value: @seed.finished_at ? @seed.finished_at.to_s(:ymd) : '' - = render partial: 'shared/form_optional' - .form-group - = f.label :days_until_maturity_min, 'Days until maturity:', class: 'control-label col-md-2' - %fieldset - .col-md-2 - = f.number_field :days_until_maturity_min, class: 'form-control' - = render partial: 'shared/form_optional' - .col-md-1 - = f.label :days_until_maturity_max, 'to', class: 'control-label' - .col-md-2 - = f.number_field :days_until_maturity_max, class: 'form-control' - = render partial: 'shared/form_optional' - .col-md-1 - = f.label :dummy, 'days', class: 'control-label' + = f.label :crop, 'Crop:', class: 'control-label col-md-2' + - if @planting + = link_to @planting, planting_path(@planting) + = f.hidden_field :parent_planting_id, value: @planting.id + - else + = auto_suggest @seed, :crop, class: 'form-control', default: @crop + %span.help-inline + Can't find what you're looking for? + = link_to "Request new crops.", new_crop_path + = f.number_field :quantity, label: 'Quantity' + = f.text_field :plant_before, class: 'add-datepicker', + value: @seed.plant_before ? @seed.plant_before.to_s(:ymd) : '' + .row + .col-4 + = f.check_box :finished, label: 'Mark as finished' + = t('.finish_helper') + .col-8 + = f.text_field :finished_at, class: 'add-datepicker', + value: @seed.finished_at ? @seed.finished_at.to_s(:ymd) : '' - .form-group.required - = f.label :organic, 'Organic?', class: 'control-label col-md-2' - .col-md-8 - = f.select(:organic, Seed::ORGANIC_VALUES, {}, class: 'form-control', default: 'unknown') - .form-group.required - = f.label :gmo, 'GMO?', class: 'control-label col-md-2' - .col-md-8 - = f.select(:gmo, Seed::GMO_VALUES, {}, class: 'form-control', default: 'unknown') - .form-group.required - = f.label :heirloom, 'Heirloom?', class: 'control-label col-md-2' - .col-md-8 - = f.select(:heirloom, Seed::HEIRLOOM_VALUES, {}, class: 'form-control', default: 'unknown') - .form-group - = f.label :description, 'Description:', class: 'control-label col-md-2' - .col-md-8 - = f.text_area :description, rows: 6, class: 'form-control' - = render partial: 'shared/form_optional' - .form-group - .col-md-offset-2.col-md-8 - %span.help-block - = t('.trade_help', site_name: ENV['GROWSTUFF_SITE_NAME']) - .form-group.required - = f.label :tradable_to, 'Will trade:', class: 'control-label col-md-2' - .col-md-8 - = f.select(:tradable_to, Seed::TRADABLE_TO_VALUES, {}, class: 'form-control') - %span.help_inline - - if current_member.location.blank? - Don't forget to - = succeed "." do - = link_to "set your location", edit_member_registration_path - - else - from - = succeed "." do - = link_to current_member.location, place_path(current_member.location) - = link_to "Change your location.", edit_member_registration_path - .form-group - .form-actions.col-md-offset-2.col-md-8 - = f.submit 'Save', class: 'btn btn-primary' + .row + .col-4= f.number_field :days_until_maturity_min + .col-4= f.number_field :days_until_maturity_max + .col-4= f.label :dummy, 'days' + + .row + .col-4= f.select(:organic, Seed::ORGANIC_VALUES, {}, default: 'unknown') + .col-4= f.select(:gmo, Seed::GMO_VALUES, {}, class: 'form-control', default: 'unknown') + .col-4= f.select(:heirloom, Seed::HEIRLOOM_VALUES, {}, class: 'form-control', default: 'unknown') + = f.text_area :description, rows: 6, class: 'form-control' + + %hr/ + = t('.trade_help', site_name: ENV['GROWSTUFF_SITE_NAME']) + = f.select(:tradable_to, Seed::TRADABLE_TO_VALUES, {}, label: 'Will trade') + %span.help_inline + - if current_member.location.blank? + Don't forget to + = succeed "." do + = link_to "set your location", edit_member_registration_path + - else + from + = succeed "." do + = link_to current_member.location, place_path(current_member.location) + = link_to "Change your location.", edit_member_registration_path + .text-right= f.submit 'Save', class: 'btn btn-primary' From 9fd2f34bf770aa619952988a000b1211006bda79 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 23 May 2019 11:30:10 +0000 Subject: [PATCH 121/549] [CodeFactor] Apply fixes --- app/helpers/buttons_helper.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 5893592a1..06257c4d0 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -2,6 +2,7 @@ module ButtonsHelper include IconsHelper def garden_plant_something_button(garden) return unless can? :edit, garden + link_to new_planting_path(garden_id: garden.id), class: "btn btn-default" do planting_icon + ' ' + t('buttons.plant_something_here') end @@ -9,6 +10,7 @@ module ButtonsHelper def plant_something_button return unless can? :create, Planting + link_to new_planting_path, class: "btn btn-default" do planting_icon + ' ' + t('buttons.plant_something') end From 20fbec96d48263c57d48eaae56eabd570ca3af47 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 24 May 2019 20:14:13 +1200 Subject: [PATCH 122/549] Tidying up forms --- app/controllers/plantings_controller.rb | 2 +- app/views/gardens/_form.html.haml | 84 +++++++++---------------- app/views/harvests/_form.html.haml | 17 ++--- app/views/plantings/_form.html.haml | 4 +- app/views/posts/_form.html.haml | 32 +++++----- 5 files changed, 54 insertions(+), 85 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index c71fb6a5d..54ef9563f 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -41,7 +41,7 @@ class PlantingsController < ApplicationController end def new - @planting = Planting.new(planted_at: Time.zone.today) + @planting = Planting.new(planted_at: Time.zone.today, owner: current_member ) @seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id] # using find_by_id here because it returns nil, unlike find diff --git a/app/views/gardens/_form.html.haml b/app/views/gardens/_form.html.haml index 3e14520d3..1f40366d8 100644 --- a/app/views/gardens/_form.html.haml +++ b/app/views/gardens/_form.html.haml @@ -1,11 +1,11 @@ .card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 - .card-body + = bootstrap_form_for(@garden) do |f| - if content_for? :title - %h1.h2-responsive.text-center - %strong=yield :title - = required_field_help_text - - = form_for(@garden, html: { class: "form-horizontal", role: "form" }) do |f| + .card-header + %h1.h2-responsive.text-center + %strong=yield :title + .card-body + = required_field_help_text - if @garden.errors.any? #error_explanation %h2 @@ -15,55 +15,27 @@ - @garden.errors.full_messages.each do |msg| %li= msg - .form-group.required - = f.label :name, class: 'control-label col-md-2' - .col-md-8 - = f.text_field :name, class: 'form-control', maxlength: 255, required: "required" + = f.text_field :name, maxlength: 255, required: "required" + = f.text_area :description, rows: 6 - .form-group - = f.label :description, class: 'control-label col-md-2' - .col-md-8 - = f.text_area :description, rows: 6, class: 'form-control' - = render partial: 'shared/form_optional' + = f.text_field :location, + value: @garden.location || current_member.location, + class: 'form-control', maxlength: 255 + = render partial: 'shared/form_optional' + %span.help-block + = t('.location_helper') + - if current_member.location.blank? + = link_to "Set your location now.", edit_member_registration_path + - else + = link_to "Change your location.", edit_member_registration_path + .row + .col-3= f.number_field :area, class: 'input-small' + .col-3= f.select(:area_unit, Garden::AREA_UNITS_VALUES, { include_blank: false }) + .col-6= f.select(:garden_type_id, GardenType.all.order(:name).pluck(:name, :id), + selected: @garden.garden_type_id) - .form-group - = f.label :location, class: 'control-label col-md-2' - .col-md-8 - = f.text_field :location, - value: @garden.location || current_member.location, - class: 'form-control', maxlength: 255 - = render partial: 'shared/form_optional' - %span.help-block - = t('.location_helper') - - if current_member.location.blank? - = link_to "Set your location now.", edit_member_registration_path - - else - = link_to "Change your location.", edit_member_registration_path - - .form-group - = f.label :area, class: 'control-label col-md-2' - .col-md-2 - = f.number_field :area, class: 'input-small form-control' - = render partial: 'shared/form_optional' - .col-md-2 - = f.select(:area_unit, Garden::AREA_UNITS_VALUES, { include_blank: false }, class: 'form-control') - - .form-group - = f.label :garden_type, class: 'control-label col-md-2' - .col-md-2 - = collection_select(:garden, :garden_type_id, - GardenType.all.order(:name), - :id, :name, - selected: @garden.garden_type_id, - class: 'form-control') - - .form-group - = f.label :active, 'Active? ', class: 'control-label col-md-2' - .col-md-8 - = f.check_box :active - You can mark a garden as inactive if you no longer use it. Note: - this will mark all plantings in the garden as "finished". - - .form-group - .form-actions.col-md-offset-2.col-md-8 - = f.submit 'Save Garden', class: 'btn btn-primary' + = f.check_box :active, label: 'Active?' + You can mark a garden as inactive if you no longer use it. Note: + this will mark all plantings in the garden as "finished". + .card-footer + .text-right= f.submit 'Save Garden' diff --git a/app/views/harvests/_form.html.haml b/app/views/harvests/_form.html.haml index 99e27afdb..53d1b9702 100644 --- a/app/views/harvests/_form.html.haml +++ b/app/views/harvests/_form.html.haml @@ -1,12 +1,13 @@ .card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 - .card-header - - if content_for? :title - %h1.h2-responsive.text-center - %strong=yield :title - .card-body - = required_field_help_text - = bootstrap_form_for(@harvest) do |f| + = bootstrap_form_for(@harvest) do |f| + .card-header + - if content_for? :title + %h1.h2-responsive.text-center + = harvest_icon + %strong=yield :title + .card-body + = required_field_help_text - if @harvest.errors.any? #error_explanation %h2 #{pluralize(@harvest.errors.size, "error")} prohibited this harvest from being saved:" @@ -50,6 +51,6 @@ = f.select(:weight_unit, Harvest::WEIGHT_UNITS_VALUES, { include_blank: false }, class: 'form-control') = f.text_area :description, rows: 6, label: 'Notes' - + .card-footer .text-right= f.submit 'Save' diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml index 8aa5da484..0be7dd0dd 100644 --- a/app/views/plantings/_form.html.haml +++ b/app/views/plantings/_form.html.haml @@ -28,14 +28,14 @@ .row .col-md-8 = f.collection_radio_buttons(:garden_id, - @planting.owner.gardens.active.order_by_name, :id, :name, required: true, + @planting.owner.gardens.active.order_by_name, + :id, :name, required: true, label: 'Where did you plant it?') = link_to "Add a garden.", new_garden_path .col-md-4 = f.text_field :planted_at, value: @planting.planted_at ? @planting.planted_at.to_s(:ymd) : '', class: 'add-datepicker', label: 'When?' - -# = render partial: 'shared/form_optional' .row .col-md-4= f.select(:planted_from, Planting::PLANTED_FROM_VALUES, { include_blank: '' }, label: 'Planted from') diff --git a/app/views/posts/_form.html.haml b/app/views/posts/_form.html.haml index aa115588a..3a70c5b65 100644 --- a/app/views/posts/_form.html.haml +++ b/app/views/posts/_form.html.haml @@ -1,9 +1,9 @@ .card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 - .card-body - - if content_for? :title - %h1.h2-responsive.text-center - %strong=yield :title - = form_for(@post, html: { role: "form" }) do |f| + = bootstrap_form_for(@post) do |f| + .card-body + - if content_for? :title + %h1.h2-responsive.text-center + %strong=yield :title - if @post.errors.any? #error_explanation %h2 @@ -13,18 +13,14 @@ - @post.errors.full_messages.each do |msg| %li= msg - .form-group - = label_tag :post, "Subject", class: 'control-label' - = f.text_field :subject, class: 'form-control', autofocus: 'autofocus', maxlength: 255 + = f.text_field :subject, autofocus: 'autofocus', maxlength: 255 - .form-group - - if @post.forum || @forum - = label_tag :body, "What's up?", class: 'control-label' - - else - = label_tag :body, "What's going on in your food garden?" - = f.text_area :body, rows: 12, class: 'form-control' - %span.help-block - = render partial: "shared/markdown_help" + - if @post.forum || @forum + = label_tag :body, "What's up?" + - else + = label_tag :body, "What's going on in your food garden?" + = f.text_area :body, rows: 12 + %span.help-block= render partial: "shared/markdown_help" - if @post.forum || @forum - forum = @post.forum || @forum @@ -33,5 +29,5 @@ = link_to forum.name, forum .field = f.hidden_field :forum_id, value: forum.id - - = f.submit "Post", class: 'btn btn-primary' + .card-footer + .text-right= f.submit "Post", class: 'btn btn-primary' From b4b1a97a2ac08b368084bdb80b91ea8e8e724c8a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 24 May 2019 20:14:47 +1200 Subject: [PATCH 123/549] Tidy harvest#index --- app/assets/stylesheets/harvests.scss | 2 +- app/views/harvests/_card.html.haml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/harvests.scss b/app/assets/stylesheets/harvests.scss index e69a6e68b..5ce20fa07 100644 --- a/app/assets/stylesheets/harvests.scss +++ b/app/assets/stylesheets/harvests.scss @@ -4,7 +4,7 @@ flex-wrap: wrap; .card { - max-width: 200px; + width: 200px; margin: 1em; } } diff --git a/app/views/harvests/_card.html.haml b/app/views/harvests/_card.html.haml index 8e7c2f1ac..7ab8e7b10 100644 --- a/app/views/harvests/_card.html.haml +++ b/app/views/harvests/_card.html.haml @@ -1,7 +1,7 @@ .card = link_to harvest do - = image_tag harvest_image_path(harvest, full_size: true), alt: harvest, class: 'img-fluid card-img-top' - .card-body.text-center + = image_tag harvest_image_path(harvest, full_size: true), alt: harvest, class: 'img-card' + .card-body %h5 %strong= link_to "#{harvest.crop} #{harvest.plant_part}", harvest %span.badge.badge-pill.badge-info= link_to harvest.plant_part, harvest.plant_part From a18f0f4d38a85039d36f459abd66d4cd543bfd52 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 24 May 2019 20:15:01 +1200 Subject: [PATCH 124/549] rubocop lint --- app/helpers/buttons_helper.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 5893592a1..06257c4d0 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -2,6 +2,7 @@ module ButtonsHelper include IconsHelper def garden_plant_something_button(garden) return unless can? :edit, garden + link_to new_planting_path(garden_id: garden.id), class: "btn btn-default" do planting_icon + ' ' + t('buttons.plant_something_here') end @@ -9,6 +10,7 @@ module ButtonsHelper def plant_something_button return unless can? :create, Planting + link_to new_planting_path, class: "btn btn-default" do planting_icon + ' ' + t('buttons.plant_something') end From cb5c28f0a37542e9c4811ffeac3b6f5adffd1cf0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 24 May 2019 20:36:57 +1200 Subject: [PATCH 125/549] seeds forms --- app/views/seeds/_form.html.haml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/app/views/seeds/_form.html.haml b/app/views/seeds/_form.html.haml index 0daf2a17e..99ace72fb 100644 --- a/app/views/seeds/_form.html.haml +++ b/app/views/seeds/_form.html.haml @@ -1,11 +1,10 @@ .card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 - .card-body - - if content_for? :title - %h1.h2-responsive.text-center - %strong=yield :title - = required_field_help_text - - = bootstrap_form_for(@seed) do |f| + = bootstrap_form_for(@seed) do |f| + .card-header + - if content_for? :title + %h1.h2-responsive.text-center + %strong=yield :title + .card-body - if @seed.errors.any? #error_explanation %h2 @@ -14,7 +13,7 @@ %ul - @seed.errors.full_messages.each do |msg| %li= msg - = f.label :crop, 'Crop:', class: 'control-label col-md-2' + = f.label :crop, 'Crop:', class: 'control-label' - if @planting = link_to @planting, planting_path(@planting) = f.hidden_field :parent_planting_id, value: @planting.id @@ -23,9 +22,12 @@ %span.help-inline Can't find what you're looking for? = link_to "Request new crops.", new_crop_path - = f.number_field :quantity, label: 'Quantity' - = f.text_field :plant_before, class: 'add-datepicker', - value: @seed.plant_before ? @seed.plant_before.to_s(:ymd) : '' + .row + .col-4= f.number_field :quantity, label: 'Quantity' + .col-8 + = f.text_field :plant_before, class: 'add-datepicker', + value: @seed.plant_before ? @seed.plant_before.to_s(:ymd) : '' + .row .col-4 = f.check_box :finished, label: 'Mark as finished' @@ -37,7 +39,6 @@ .row .col-4= f.number_field :days_until_maturity_min .col-4= f.number_field :days_until_maturity_max - .col-4= f.label :dummy, 'days' .row .col-4= f.select(:organic, Seed::ORGANIC_VALUES, {}, default: 'unknown') @@ -58,4 +59,5 @@ = succeed "." do = link_to current_member.location, place_path(current_member.location) = link_to "Change your location.", edit_member_registration_path - .text-right= f.submit 'Save', class: 'btn btn-primary' + .card-footer + .text-right= f.submit 'Save' From c67adc1bd0ece2dbff7413a0dd7add1e249ff385 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 24 May 2019 20:37:06 +1200 Subject: [PATCH 126/549] move global actions buttons --- app/views/layouts/application.html.haml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 5dd7ccd33..0da5bda15 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -8,14 +8,13 @@ -# anchor tag for accessibility link to skip the navigation menu %a{ name: 'skipnav' } #maincontainer.container + .float-right= render 'shared/global_actions' .row .col-md-12 - if content_for?(:breadcrumbs) .float-left= yield(:breadcrumbs) - .float-right - = render 'shared/global_actions' - - if content_for?(:buttonbar) - = yield(:buttonbar) + - if content_for?(:buttonbar) + = yield(:buttonbar) - if content_for?(:subtitle) %small= yield(:subtitle) From f711b7e3b79cd4780686e6b9e2cceb9f56b10b51 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 24 May 2019 20:37:16 +1200 Subject: [PATCH 127/549] Add crops new to the percy specs --- spec/features/percy/percy_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index b7665ade2..b83757d40 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -229,6 +229,11 @@ I noticed a couple of days ago on the way to work that there's a place near home Percy.snapshot(page, name: "#{prefix}/plantings#new") end + it 'loads crops#new' do + visit new_crop_path + Percy.snapshot(page, name: "#{prefix}/crops#new") + end + describe '#new' do it 'loads gardens#new' do visit new_garden_path From e4a375de79208fb4c5ae37f66f861ea968c10dba Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 24 May 2019 20:37:32 +1200 Subject: [PATCH 128/549] Add missing translations --- config/locales/en.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 35884fb05..2142c6d6c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -298,6 +298,8 @@ en: Are you interested in trading or swapping seeds with other %{site_name} members? If you list your seeds as available for trade, other members can contact you to request seeds. You can list any conditions or other information in the description, above. + finish_helper: > + Seeds are finished when you've planted them all, or you've traded them all away. index: title: crop_seeds: Everyone's %{crop} seeds From ca17e6a258f2befd647d85bc21750e42fbda615b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 24 May 2019 20:37:56 +1200 Subject: [PATCH 129/549] Starting to tidy the crops form --- app/views/crops/_form.html.haml | 74 ++++++++++++++------------------- 1 file changed, 32 insertions(+), 42 deletions(-) diff --git a/app/views/crops/_form.html.haml b/app/views/crops/_form.html.haml index 5ae0b586b..d3f41c853 100644 --- a/app/views/crops/_form.html.haml +++ b/app/views/crops/_form.html.haml @@ -1,9 +1,10 @@ .card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 - .card-body - - if content_for? :title - %h1.h2-responsive.text-center - %strong=yield :title - = form_for @crop, html: { class: 'form-horizontal', role: "form" } do |f| + = bootstrap_form_for(@crop) do |f| + .card-header + - if content_for? :title + %h1.h2-responsive.text-center + %strong=yield :title + .card-body - if @crop.errors.any? #error_explanation %h3 @@ -25,40 +26,31 @@ %h2 Basic information .form-group#new_crop - = f.label :name, class: 'control-label col-md-2' - .col-md-8 - = f.text_field :name, class: 'form-control' - %span.help-block - The common name for the crop, in English (required). - - if can? :wrangle, @crop - Wranglers: please ensure this is singular, and capitalize - proper nouns only. + = f.text_field :name + %span.help-block + The common name for the crop, in English (required). + - if can? :wrangle, @crop + Wranglers: please ensure this is singular, and capitalize + proper nouns only. - .form-group - = f.label :perennial, 'Lifespan', class: 'control-label col-md-2' - .col-md-8 - = f.radio_button(:perennial, false) - = f.label(:perennial_false, "Annual") - %span.help-block Living and reproducing in a single year or less - = f.radio_button(:perennial, true) - = f.label(:perennial_true, "Perennial") - %span.help-block Living more than two years - .form-group - = f.label :en_wikipedia_url, 'Wikipedia URL', class: 'control-label col-md-2' - .col-md-8 - = f.text_field :en_wikipedia_url, class: 'form-control', id: "en_wikipedia_url" - %span.help-block - Link to the crop's page on the English language Wikipedia (required). + %h2 Lifespan + %p + = f.radio_button(:perennial, false, label: 'Annual') + %span.help-block Living and reproducing in a single year or less + %p + = f.radio_button(:perennial, true, label: "Perennial") + %span.help-block Living more than two years + + = f.text_field :en_wikipedia_url, id: "en_wikipedia_url", label: 'Wikipedia URL' + %span.help-block + Link to the crop's page on the English language Wikipedia (required). -# Only crop wranglers see the crop hierarchy (for now) - if can? :wrangle, @crop - .form-group - = f.label :parent_id, 'Parent crop', class: 'control-label col-md-2' - .col-md-8 - = collection_select(:crop, :parent_id, Crop.all.order(:name), :id, :name, - { include_blank: true }, class: 'form-control') - %span.help-block Optional. For setting up crop hierarchies for varieties etc. + = f.collection_select(:parent_id, Crop.all.order(:name), :id, :name, + { include_blank: true, label: 'Parent crop'}) + %span.help-block Optional. For setting up crop hierarchies for varieties etc. -# Everyone (wranglers and requesters) gets to add scientific names @@ -73,10 +65,8 @@ .col-md-2 = label_tag :scientific_names, "Scientific name #{index + 1}:", class: 'control-label' .col-md-8 - = text_field_tag "sci_name[#{index + 1}]", sci.name, id: "sci_name[#{index + 1}]", class: 'form-control' + = text_field_tag "sci_name[#{index + 1}]", sci.name, id: "sci_name[#{index + 1}]" %span.help-block Scientific name of crop. - .col-md-2 - %h2 Alternate names = button_tag "+", id: "add-alt_name-row", type: "button" @@ -88,7 +78,7 @@ .col-md-2 = label_tag :alternate_names, "Alternate name #{index + 1}:", class: 'control-label' .col-md-8 - = text_field_tag "alt_name[#{index + 1}]", alt.name, id: "alt_name[#{index + 1}]", class: 'form-control' + = text_field_tag "alt_name[#{index + 1}]", alt.name, id: "alt_name[#{index + 1}]" %span.help-block Alternate name of crop. .col-md-2 @@ -100,7 +90,7 @@ .form-group = f.label :request_notes, 'Comments', class: 'control-label col-md-2' .col-md-8 - = f.text_area :request_notes, rows: 3, class: 'form-control', id: 'request_notes' + = f.text_area :request_notes, rows: 3, id: 'request_notes' -# A final explanation of what's going to happen next, for crop requesters - unless can? :wrangle, @crop @@ -114,17 +104,17 @@ .form-group = f.label :approval_status, 'Approval status', class: 'control-label col-md-2' .col-md-8 - = f.select(:approval_status, @crop.approval_statuses, {}, class: 'form-control') + = f.select(:approval_status, @crop.approval_statuses, {}) .form-group = f.label :reason_for_rejection, 'Reason for rejection', class: 'control-label col-md-2' .col-md-8 - = f.select(:reason_for_rejection, @crop.reasons_for_rejection, include_blank: true, class: 'form-control') + = f.select(:reason_for_rejection, @crop.reasons_for_rejection, include_blank: true) .form-group = f.label :rejection_notes, 'Rejection notes', class: 'control-label col-md-2' .col-md-8 - = f.text_area :rejection_notes, rows: 3, class: 'form-control' + = f.text_area :rejection_notes, rows: 3 %span.help-block Please provide additional notes why this crop request was rejected if the above reasons do not apply. From 334037ed1e8a5496e453ea6bbc3f86d4e8ae3ddf Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 24 May 2019 20:43:00 +1200 Subject: [PATCH 130/549] form tidy --- app/views/crops/_form.html.haml | 42 ++++++++++++++++----------------- app/views/posts/_form.html.haml | 2 +- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/app/views/crops/_form.html.haml b/app/views/crops/_form.html.haml index d3f41c853..873a1195d 100644 --- a/app/views/crops/_form.html.haml +++ b/app/views/crops/_form.html.haml @@ -1,4 +1,4 @@ -.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 +.card.col-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 = bootstrap_form_for(@crop) do |f| .card-header - if content_for? :title @@ -33,7 +33,6 @@ Wranglers: please ensure this is singular, and capitalize proper nouns only. - %h2 Lifespan %p = f.radio_button(:perennial, false, label: 'Annual') @@ -61,11 +60,11 @@ .form-group#scientific_names - @crop.scientific_names.each.with_index do |sci, index| - .template.col-md-12{ id: "sci_template[#{index + 1}]" } - .col-md-2 + .template.col-12{ id: "sci_template[#{index + 1}]" } + .col-2 = label_tag :scientific_names, "Scientific name #{index + 1}:", class: 'control-label' - .col-md-8 - = text_field_tag "sci_name[#{index + 1}]", sci.name, id: "sci_name[#{index + 1}]" + .col-8 + = text_field_tag "sci_name[#{index + 1}]", sci.name, id: "sci_name[#{index + 1}]", class: 'form-control' %span.help-block Scientific name of crop. %h2 Alternate names @@ -74,13 +73,13 @@ .form-group#alternate_names - @crop.alternate_names.each.with_index do |alt, index| - .template.col-md-12{ id: "alt_template[#{index + 1}]" } - .col-md-2 + .template.col-12{ id: "alt_template[#{index + 1}]" } + .col-2 = label_tag :alternate_names, "Alternate name #{index + 1}:", class: 'control-label' - .col-md-8 - = text_field_tag "alt_name[#{index + 1}]", alt.name, id: "alt_name[#{index + 1}]" + .col-8 + = text_field_tag "alt_name[#{index + 1}]", alt.name, id: "alt_name[#{index + 1}]", class: 'form-control' %span.help-block Alternate name of crop. - .col-md-2 + .col-2 -# This is used for comments from crop requesters. We need to show it -# to everyone, but we don't include it on new crops from wranglers. @@ -88,8 +87,8 @@ - if (can?(:wrangle, @crop) && @crop.requester) || (cannot?(:wrangle, @crop) && @crop.new_record?) %h2 Crop request notes .form-group - = f.label :request_notes, 'Comments', class: 'control-label col-md-2' - .col-md-8 + = f.label :request_notes, 'Comments', class: 'control-label col-2' + .col-8 = f.text_area :request_notes, rows: 3, id: 'request_notes' -# A final explanation of what's going to happen next, for crop requesters @@ -102,22 +101,21 @@ - if can?(:wrangle, @crop) && @crop.requester %h2 Approve or reject pending crops .form-group - = f.label :approval_status, 'Approval status', class: 'control-label col-md-2' - .col-md-8 + = f.label :approval_status, 'Approval status', class: 'control-label col-2' + .col-8 = f.select(:approval_status, @crop.approval_statuses, {}) .form-group - = f.label :reason_for_rejection, 'Reason for rejection', class: 'control-label col-md-2' - .col-md-8 + = f.label :reason_for_rejection, 'Reason for rejection', class: 'control-label col-2' + .col-8 = f.select(:reason_for_rejection, @crop.reasons_for_rejection, include_blank: true) .form-group - = f.label :rejection_notes, 'Rejection notes', class: 'control-label col-md-2' - .col-md-8 + = f.label :rejection_notes, 'Rejection notes', class: 'control-label col-2' + .col-8 = f.text_area :rejection_notes, rows: 3 %span.help-block Please provide additional notes why this crop request was rejected if the above reasons do not apply. - .form-group - .form-actions.col-md-offset-2.col-md-8 - = f.submit 'Save', class: 'btn btn-primary' + .card-footer + .text-right= f.submit 'Save' diff --git a/app/views/posts/_form.html.haml b/app/views/posts/_form.html.haml index 3a70c5b65..7452f4e9f 100644 --- a/app/views/posts/_form.html.haml +++ b/app/views/posts/_form.html.haml @@ -30,4 +30,4 @@ .field = f.hidden_field :forum_id, value: forum.id .card-footer - .text-right= f.submit "Post", class: 'btn btn-primary' + .text-right= f.submit "Post" From 95ed451c21507591f3d0dd4b5ed32b5874614440 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 24 May 2019 20:46:54 +1200 Subject: [PATCH 131/549] post header --- app/views/posts/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/posts/_form.html.haml b/app/views/posts/_form.html.haml index 7452f4e9f..bf9c985e9 100644 --- a/app/views/posts/_form.html.haml +++ b/app/views/posts/_form.html.haml @@ -1,6 +1,6 @@ .card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 = bootstrap_form_for(@post) do |f| - .card-body + .card-header - if content_for? :title %h1.h2-responsive.text-center %strong=yield :title From 3ec02945653a9efcc5d1f4d27d26412d2b419149 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 24 May 2019 20:47:18 +1200 Subject: [PATCH 132/549] post body --- app/views/posts/_form.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/posts/_form.html.haml b/app/views/posts/_form.html.haml index bf9c985e9..3c14dad19 100644 --- a/app/views/posts/_form.html.haml +++ b/app/views/posts/_form.html.haml @@ -13,6 +13,7 @@ - @post.errors.full_messages.each do |msg| %li= msg + .card-body = f.text_field :subject, autofocus: 'autofocus', maxlength: 255 - if @post.forum || @forum From b07f5526f19f2de08f838ec60c21458f502c5752 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 24 May 2019 20:50:17 +1200 Subject: [PATCH 133/549] Vertical buttons --- app/views/shared/_global_actions.html.haml | 44 +++++++++++----------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index a69ad3936..e023c27e6 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,27 +1,25 @@ - if signed_in? - .row - .col-md-12 - .btn-group - = link_to member_gardens_path(member_slug: current_member.slug), - class: 'btn btn-default' do - = garden_icon - -# = t('.my_gardens') - = link_to new_planting_path, - class: 'btn btn-default' do - = planting_icon - -# = t('plantings.plant') + .btn-group-vertical + = link_to member_gardens_path(member_slug: current_member.slug), + class: 'btn btn-default' do + = garden_icon + -# = t('.my_gardens') + = link_to new_planting_path, + class: 'btn btn-default' do + = planting_icon + -# = t('plantings.plant') - = link_to new_harvest_path, - class: 'btn btn-default' do - = harvest_icon - -# = t('harvests.harvest') + = link_to new_harvest_path, + class: 'btn btn-default' do + = harvest_icon + -# = t('harvests.harvest') - = link_to new_seed_path, - class: 'btn btn-default' do - = seed_icon - -# = t('buttons.save_seeds') + = link_to new_seed_path, + class: 'btn btn-default' do + = seed_icon + -# = t('buttons.save_seeds') - = link_to new_post_path, - class: 'btn btn-default' do - = blog_icon - -# = t 'posts.write_blog' \ No newline at end of file + = link_to new_post_path, + class: 'btn btn-default' do + = blog_icon + -# = t 'posts.write_blog' \ No newline at end of file From 5c544e3026113ea9f812d5fb5af2381e88857825 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 24 May 2019 21:15:36 +1200 Subject: [PATCH 134/549] smaller planting cards --- app/views/plantings/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index 09369ad73..5c016b0b3 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -15,7 +15,7 @@ .row - @plantings.each do |planting| - .col-md-3.col-sm-4.col-6= render 'plantings/card', planting: planting + .col-2.col-xs-6= render 'plantings/card', planting: planting .pagination = page_entries_info @plantings From 3ad36c647b51ce274447129d8a6cf38cbc7dca0e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 24 May 2019 21:15:45 +1200 Subject: [PATCH 135/549] seed form --- app/views/seeds/_form.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/seeds/_form.html.haml b/app/views/seeds/_form.html.haml index 99ace72fb..7a97fda55 100644 --- a/app/views/seeds/_form.html.haml +++ b/app/views/seeds/_form.html.haml @@ -37,8 +37,8 @@ value: @seed.finished_at ? @seed.finished_at.to_s(:ymd) : '' .row - .col-4= f.number_field :days_until_maturity_min - .col-4= f.number_field :days_until_maturity_max + .col-4= f.number_field :days_until_maturity_min, append: " days" + .col-4= f.number_field :days_until_maturity_max, append: " days" .row .col-4= f.select(:organic, Seed::ORGANIC_VALUES, {}, default: 'unknown') From 6af086e94d57423727b23665466372ef44a0df89 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 10:04:16 +1200 Subject: [PATCH 136/549] Tidy up percy specs for major #new pages --- spec/features/percy/percy_spec.rb | 60 +++++++++++++++++-------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index b83757d40..d21f51113 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -224,41 +224,47 @@ I noticed a couple of days ago on the way to work that there's a place near home Percy.snapshot(page, name: "#{prefix}/self/gardens#show") end - it 'loads plantings#new' do - visit new_planting_path - Percy.snapshot(page, name: "#{prefix}/plantings#new") - end - - it 'loads crops#new' do - visit new_crop_path - Percy.snapshot(page, name: "#{prefix}/crops#new") - end - describe '#new' do - it 'loads gardens#new' do - visit new_garden_path - Percy.snapshot(page, name: "#{prefix}/gardens#new") - end - - it 'loads harvests#new' do - visit new_harvest_path - Percy.snapshot(page, name: "#{prefix}/harvests#new") - end - - it 'loads plantings#new' do + it 'plantings#new' do visit new_planting_path Percy.snapshot(page, name: "#{prefix}/plantings#new") end - it 'loads posts#new' do - visit new_post_path - Percy.snapshot(page, name: "#{prefix}/posts#new") - end - - it 'loads crops#new' do + it 'crops#new' do visit new_crop_path Percy.snapshot(page, name: "#{prefix}/crops#new") end + + it 'gardens#new' do + visit new_garden_path + Percy.snapshot(page, name: "#{prefix}/gardens#new") + end + + it 'harvests#new' do + visit new_harvest_path + Percy.snapshot(page, name: "#{prefix}/harvests#new") + fill_in(id: 'crop', with: 'tom') + Percy.snapshot(page, name: "#{prefix}/harvests#new-autosuggest") + end + + it 'plantings#new' do + visit new_planting_path + Percy.snapshot(page, name: "#{prefix}/plantings#new") + fill_in(id: 'crop', with: 'tom') + Percy.snapshot(page, name: "#{prefix}/plantings#new-autosuggest") + end + + it 'seeds#new' do + visit new_seed_path + Percy.snapshot(page, name: "#{prefix}/seeds#new") + fill_in(id: 'crop', with: 'tom') + Percy.snapshot(page, name: "#{prefix}/seeds#new-autosuggest") + end + + it 'posts#new' do + visit new_post_path + Percy.snapshot(page, name: "#{prefix}/posts#new") + end end describe '#edit' do From 4caa30b2f5eda8e3585b19d57cc8b081b0391721 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 10:22:57 +1200 Subject: [PATCH 137/549] button horizontal again --- app/views/shared/_global_actions.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index e023c27e6..56dd01127 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,5 +1,5 @@ - if signed_in? - .btn-group-vertical + .btn-group = link_to member_gardens_path(member_slug: current_member.slug), class: 'btn btn-default' do = garden_icon From 7ffefcf1b5400a64f8486a739395dc85477753d7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 10:24:31 +1200 Subject: [PATCH 138/549] Add admin and crop wrangling to percy spec --- spec/features/percy/percy_spec.rb | 64 +++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index d21f51113..5b260a68f 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -1,11 +1,19 @@ require 'rails_helper' describe 'Test with visual testing', type: :feature, js: true do - let(:member) { FactoryBot.create :member, login_name: 'percy', preferred_avatar_uri: gravatar } - let(:someone_else) { FactoryBot.create :edinburgh_member, login_name: 'ruby', preferred_avatar_uri: gravatar2 } + # Use the same random seed every time so our random data is the same + # on every run, so doesn't trigger percy to see changes + before { Faker::Config.random = Random.new(42) } + let!(:member) { FactoryBot.create :member, login_name: 'percy', preferred_avatar_uri: gravatar } + let!(:crop_wrangler) { FactoryBot.create :crop_wrangling_member, login_name: 'croppy', preferred_avatar_uri: gravatar2 } + let!(:admin_user) { FactoryBot.create :admin_member, login_name: 'janitor', preferred_avatar_uri: gravatar3 } + let!(:someone_else) { FactoryBot.create :edinburgh_member, login_name: 'ruby', preferred_avatar_uri: gravatar4 } let(:gravatar) { 'http://www.gravatar.com/avatar/d021434aac03a7f7c7c0de60d07dad1c?size=150&default=identicon' } let(:gravatar2) { 'http://www.gravatar.com/avatar/353d83d3677b142520987e1936fd093c?size=150&default=identicon' } + let(:gravatar3) { 'http://www.gravatar.com/avatar/622db62c7beab8d5d8b7a80aa6385b2f?size=150&default=identicon' } + let(:gravatar4) { 'http://www.gravatar.com/avatar/7fd767571ff5ceefc7a687a543b2c402?size=150&default=identicon' } + let!(:tomato) { FactoryBot.create :tomato, creator: someone_else } let(:plant_part) { FactoryBot.create :plant_part, name: 'fruit' } @@ -38,7 +46,7 @@ I noticed a couple of days ago on the way to work that there's a place near home let(:post) { FactoryBot.create :post, author: member, subject: "Watering", body: post_body } before do # Freeze time, so we don't have variations in timestamps on the page - Timecop.freeze(Time.local(2019, 1, 1)) + Timecop.freeze(Time.zone.local(2019, 1, 1)) { chard: 'https://farm9.staticflickr.com/8516/8519911893_1759c28965_q.jpg', @@ -260,7 +268,7 @@ I noticed a couple of days ago on the way to work that there's a place near home fill_in(id: 'crop', with: 'tom') Percy.snapshot(page, name: "#{prefix}/seeds#new-autosuggest") end - + it 'posts#new' do visit new_post_path Percy.snapshot(page, name: "#{prefix}/posts#new") @@ -309,4 +317,52 @@ I noticed a couple of days ago on the way to work that there's a place near home end end end + + context 'wrangling crops' do + let(:prefix) { 'crop-wrangler' } + before { login_as crop_wrangler } + let!(:candy) { FactoryBot.create :crop_request, name: 'candy' } + + it 'crop wrangling page' do + visit wrangle_crops_path + Percy.snapshot(page, 'crops wrangle') + click_link 'Pending approval' + Percy.snapshot(page, 'crops pending approval') + click_link 'candy' + Percy.snapshot(page, 'editing pending crop') + end + end + context 'admin' do + before do + login_as admin_user + visit admin_path + end + it 'admin page' do + Percy.snapshot(page) + end + it 'Roles' do + click_link 'Roles' + Percy.snapshot(page) + end + it 'CMS' do + click_link 'CMS' + Percy.snapshot(page) + end + it 'Garden Types' do + click_link 'Garden Types' + Percy.snapshot(page) + end + it 'Alternate names' do + click_link 'Alternate names' + Percy.snapshot(page) + end + it 'Scientific names' do + click_link 'Scientific names' + Percy.snapshot(page) + end + it 'Members' do + click_link 'Members' + Percy.snapshot(page) + end + end end From 4c92c97aaafd0abd9c95412c9d3a53c35eae7880 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 10:29:40 +1200 Subject: [PATCH 139/549] Add names to admin pages in percy spec --- spec/features/percy/percy_spec.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 5b260a68f..a2422b951 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -325,11 +325,11 @@ I noticed a couple of days ago on the way to work that there's a place near home it 'crop wrangling page' do visit wrangle_crops_path - Percy.snapshot(page, 'crops wrangle') + Percy.snapshot(page, name: 'crops wrangle') click_link 'Pending approval' - Percy.snapshot(page, 'crops pending approval') + Percy.snapshot(page, name: 'crops pending approval') click_link 'candy' - Percy.snapshot(page, 'editing pending crop') + Percy.snapshot(page, name: 'editing pending crop') end end context 'admin' do @@ -338,31 +338,31 @@ I noticed a couple of days ago on the way to work that there's a place near home visit admin_path end it 'admin page' do - Percy.snapshot(page) + Percy.snapshot(page, name: 'Admin') end it 'Roles' do click_link 'Roles' - Percy.snapshot(page) + Percy.snapshot(page, name: 'Admin Roles') end it 'CMS' do click_link 'CMS' - Percy.snapshot(page) + Percy.snapshot(page, name: 'CMS') end it 'Garden Types' do click_link 'Garden Types' - Percy.snapshot(page) + Percy.snapshot(page, name: 'Admin Garden type') end it 'Alternate names' do click_link 'Alternate names' - Percy.snapshot(page) + Percy.snapshot(page, name: 'Admin Alternate names') end it 'Scientific names' do click_link 'Scientific names' - Percy.snapshot(page) + Percy.snapshot(page, name: 'Admin Scientific names') end it 'Members' do click_link 'Members' - Percy.snapshot(page) + Percy.snapshot(page, name: 'Admin Members') end end end From 54f54f020aa79c4f2d36b0fcb3d43f2bccbe873a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 10:31:26 +1200 Subject: [PATCH 140/549] Make sure we precompile the assets before running percy --- script/percy.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/script/percy.sh b/script/percy.sh index 33c43ce7b..8df5ba590 100755 --- a/script/percy.sh +++ b/script/percy.sh @@ -1,2 +1,3 @@ #!/bin/bash +bundle exec rails assets:precompile PERCY_TARGET_BRANCH=dev npx percy exec -- bundle exec rspec spec/features/percy/ From e4be6feaed5d9fc87244d9f606e14cf75042c464 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 14:26:31 +1200 Subject: [PATCH 141/549] Tidy up forms form --- app/views/forums/_form.html.haml | 44 +++++++++++++++----------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/app/views/forums/_form.html.haml b/app/views/forums/_form.html.haml index bf2217cbd..d7685b724 100644 --- a/app/views/forums/_form.html.haml +++ b/app/views/forums/_form.html.haml @@ -1,25 +1,21 @@ -= form_for @forum, html: { class: 'form-horizontal', role: "form" } do |f| - - if @forum.errors.any? - #error_explanation - %h2 - = pluralize(@forum.errors.size, "error") - prohibited this forum from being saved: - %ul - - @forum.errors.full_messages.each do |msg| - %li= msg +.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 + .card-header + - if content_for? :title + %h1.h2-responsive.text-center + %strong=yield :title + = bootstrap_form_for(@forum) do |f| + .card-body + - if @forum.errors.any? + #error_explanation + %h2 + = pluralize(@forum.errors.size, "error") + prohibited this forum from being saved: + %ul + - @forum.errors.full_messages.each do |msg| + %li= msg - .form-group - = f.label :name, class: 'control-label col-md-2' - .col-md-8 - = f.text_field :name, class: 'form-control' - .form-group - = f.label :description, class: 'control-label col-md-2' - .col-md-8 - = f.text_area :description, rows: 6, class: 'form-control' - .form-group - = f.label :owner_id, class: 'control-label col-md-2' - .col-md-8 - = collection_select(:forum, :owner_id, Member.all, :id, :login_name, {}, class: 'form-control') - .form-group - .form-actions.col-md-offset-2.col-md-8 - = f.submit 'Save', class: 'btn btn-primary' + = f.text_field :name + = f.text_area :description, rows: 6 + = f.select(:owner_id, Member.all.order(:login_name).pluck(:login_name, :id)) + .card-footer + .text-right= f.submit 'save' From f822b32ac86022541356c471cd2711ec71259d75 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 15:11:07 +1200 Subject: [PATCH 142/549] More Actions into drop down --- app/views/plantings/_actions.html.haml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/views/plantings/_actions.html.haml b/app/views/plantings/_actions.html.haml index 3de6ce339..72d19241f 100644 --- a/app/views/plantings/_actions.html.haml +++ b/app/views/plantings/_actions.html.haml @@ -1,13 +1,17 @@ - if can?(:edit, planting) - .planting-actions - .btn-group - = planting_edit_button(planting) + .dropdown.float-right.planting-actions + %button#post-edit-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions + .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "post-edit-button"} + = link_to edit_planting_path(planting), class: 'dropdown-item' do + = edit_icon + = t('.edit') + = link_to new_photo_path(id: planting.id, type: 'planting'), class: "dropdown-item" do + = photo_icon + = t('buttons.add_photo') = add_photo_button(planting) - - if planting.active? = planting_finish_button(planting) = planting_harvest_button(planting) = planting_save_seeds_button(planting) - - - if can? :destroy, planting - = delete_button(planting) + - if can? :destroy, planting + = delete_button(planting) From 94aa920360583b91fdf5666eb2e2849cfd1fb75c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 15:14:02 +1200 Subject: [PATCH 143/549] Fix button id --- app/views/plantings/_actions.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/plantings/_actions.html.haml b/app/views/plantings/_actions.html.haml index 72d19241f..2191358e6 100644 --- a/app/views/plantings/_actions.html.haml +++ b/app/views/plantings/_actions.html.haml @@ -1,7 +1,7 @@ - if can?(:edit, planting) .dropdown.float-right.planting-actions - %button#post-edit-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions - .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "post-edit-button"} + %button#planting-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions + .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "planting-actions-button"} = link_to edit_planting_path(planting), class: 'dropdown-item' do = edit_icon = t('.edit') From b21aa502036fb201501d69c09e591d9d5839bb57 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 15:18:43 +1200 Subject: [PATCH 144/549] Tidy up seeds on homepage --- app/views/home/_seeds.html.haml | 2 +- app/views/home/index.html.haml | 21 ++++++++------------- app/views/seeds/_list.html.haml | 13 +------------ 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml index 525b0dc6f..942422782 100644 --- a/app/views/home/_seeds.html.haml +++ b/app/views/home/_seeds.html.haml @@ -1,3 +1,3 @@ - cache cache_key_for(Seed) do %h2= t('.title') - = render 'seeds/list', seeds: Seed.current.tradable.includes(:owner, :crop).order(created_at: :desc).limit(6) + .homepage-cards= render 'seeds/list', seeds: Seed.current.tradable.includes(:owner, :crop).order(created_at: :desc).limit(6) diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 59ae38890..073629344 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -10,7 +10,7 @@ .jumbotron= render 'blurb' .row - .col-xl-7.col-md-12 + .col-xl-8.col-md-12 %section.crops %h2= t('.some_of_our_crops') .homepage-cards= render 'crops' @@ -19,22 +19,17 @@ - cache cache_key_for(Crop, 'recent') do %h3= t('.recently_added') != Crop.recent.limit(30).map { |c| link_to(c, c) }.join(", ") + .col-xl-4 + .row + .col-md-6.col-sm-12=render 'plantings' + .col-md-6.col-sm-12= render 'harvests' + .col-12 %section.seeds %h2.text-center= t('.seeds_available_to_trade') - .homepage-cards - .card-row.mx-auto= render Seed.current.tradable.recent.includes(:owner, :crop).limit(12), full: true + = render 'seeds' .align-bottom %p.text-right= link_to "#{t('home.seeds.view_all')} »", seeds_path, class: 'btn' %section.members= render 'members' - - .col-xl-5 - .row - .col-md-6.col-sm-12=render 'plantings' - .col-md-6.col-sm-12= render 'harvests' - .row - .col-12 - %section.members= render 'discuss' - - + %section.members= render 'discuss' \ No newline at end of file diff --git a/app/views/seeds/_list.html.haml b/app/views/seeds/_list.html.haml index 45715a1ce..2f503aba9 100644 --- a/app/views/seeds/_list.html.haml +++ b/app/views/seeds/_list.html.haml @@ -1,13 +1,2 @@ - seeds.each do |seed| - .card - .card-image - = link_to seed do - = image_tag(seed_image_path(seed, full_size: true), alt: seed, class: 'card-img-top img-responsive') - .card-body - %h5.card-title= link_to seed, seed - %p - %i #{seed.owner.location} - %p Will trade #{seed.tradable_to} - %p.float-right - = link_to seed.owner do - = image_tag(avatar_uri(seed.owner, 50), alt: '', class: 'img img-responsive avatar rounded') \ No newline at end of file + = render 'seeds/card', seed: seed From 1e03d15434060858e7ed102d0210ea49a6ef91b1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 15:18:58 +1200 Subject: [PATCH 145/549] Move post actions to own file --- app/views/posts/_actions.html.haml | 11 +++++++++++ app/views/posts/show.html.haml | 12 +----------- 2 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 app/views/posts/_actions.html.haml diff --git a/app/views/posts/_actions.html.haml b/app/views/posts/_actions.html.haml new file mode 100644 index 000000000..64cbf0748 --- /dev/null +++ b/app/views/posts/_actions.html.haml @@ -0,0 +1,11 @@ +.dropdown.float-right + %button#post-edit-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions + .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "post-edit-button"} + - if can? :edit, post + = link_to edit_post_path(post), class: 'dropdown-item' do + = edit_icon + Edit + - if can? :delete, post + = link_to post_path(post), class: 'dropdown-item text-danger', data: { confirm: 'Are you sure?' } do + = delete_icon + Delete \ No newline at end of file diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index 91143f0bd..578d0af68 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -41,17 +41,7 @@ .card-header %h2.display-3.float-left = @post.subject - .dropdown.float-right - %button#post-edit-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions - .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "post-edit-button"} - - if can? :edit, @post - = link_to edit_post_path(@post), class: 'dropdown-item' do - = edit_icon - Edit - - if can? :delete, @post - = link_to post_path(@post), class: 'dropdown-item text-danger', data: { confirm: 'Are you sure?' } do - = delete_icon - Delete + = render 'posts/actions', post: @post .card-body= render 'posts/single', post: @post .card-footer From fcabfef8d907fa14159556fbf3f8b5da7c0b9483 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 15:19:15 +1200 Subject: [PATCH 146/549] Put planting owner details in a card --- app/views/plantings/show.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/plantings/show.html.haml b/app/views/plantings/show.html.haml index 785134dde..d43563634 100644 --- a/app/views/plantings/show.html.haml +++ b/app/views/plantings/show.html.haml @@ -28,7 +28,8 @@ %hr/ = render 'plantings/photos', photos: @photos, planting: @planting .col-md-4.col-xs-12.text-right - = render 'plantings/owner', planting: @planting + .card + .card-body= render 'plantings/owner', planting: @planting = render @planting.crop .row .col-md-12 From c7e4216a31e127b0a5e27170810a8269f9fbf4cf Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 17:01:28 +1200 Subject: [PATCH 147/549] move global actions --- app/views/layouts/application.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 0da5bda15..d62e4f4bf 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -8,9 +8,9 @@ -# anchor tag for accessibility link to skip the navigation menu %a{ name: 'skipnav' } #maincontainer.container - .float-right= render 'shared/global_actions' .row - .col-md-12 + .col-12 + .float-right= render 'shared/global_actions' - if content_for?(:breadcrumbs) .float-left= yield(:breadcrumbs) - if content_for?(:buttonbar) From 62214d6e36ea92354703a0625c0cb7079fcc22b3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 17:01:53 +1200 Subject: [PATCH 148/549] allow plantings factor boxes to be bigger --- app/assets/stylesheets/predictions.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/predictions.scss b/app/assets/stylesheets/predictions.scss index c1d9860a8..82a69ee56 100644 --- a/app/assets/stylesheets/predictions.scss +++ b/app/assets/stylesheets/predictions.scss @@ -1,7 +1,7 @@ .predictions { .predictions-card { text-align: center; - max-width: 200px; + max-width: 250px; border: 1px solid lighten($green, 20%); border-radius: 5%; background: $white; From 70d4b85f98ac2b9e50c630410032eb53fff09833 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 17:02:06 +1200 Subject: [PATCH 149/549] Member actions --- app/views/members/_actions.html.haml | 16 ++++++++++++++++ app/views/members/show.html.haml | 17 +---------------- 2 files changed, 17 insertions(+), 16 deletions(-) create mode 100644 app/views/members/_actions.html.haml diff --git a/app/views/members/_actions.html.haml b/app/views/members/_actions.html.haml new file mode 100644 index 000000000..58c1b152e --- /dev/null +++ b/app/views/members/_actions.html.haml @@ -0,0 +1,16 @@ +-# - content_for :buttonbar do +-# %p.btn-group +-# - if can? :update, @member +-# = link_to edit_member_registration_path, class: 'btn btn-default text-right' do +-# = edit_icon +-# = t('members.edit_profile') + +-# - if can?(:create, Notification) && current_member != @member +-# = link_to 'Send message', new_notification_path(recipient_id: @member.id), class: 'btn btn-default' + +-# - if current_member && current_member != @member # must be logged in, can't follow yourself +-# - follow = current_member.get_follow(@member) +-# - if !follow && can?(:create, Follow) # not already following +-# = link_to 'Follow', follows_path(followed: @member), method: :post, class: 'btn btn-default text-right' +-# - if follow && can?(:destroy, follow) # already following +-# = link_to 'Unfollow', follow_path(follow), method: :delete, class: 'btn btn-default text-right' \ No newline at end of file diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 484fe122d..df696b343 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -9,22 +9,7 @@ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) --# - content_for :buttonbar do --# %p.btn-group --# - if can? :update, @member --# = link_to edit_member_registration_path, class: 'btn btn-default text-right' do --# = edit_icon --# = t('members.edit_profile') - --# - if can?(:create, Notification) && current_member != @member --# = link_to 'Send message', new_notification_path(recipient_id: @member.id), class: 'btn btn-default' - --# - if current_member && current_member != @member # must be logged in, can't follow yourself --# - follow = current_member.get_follow(@member) --# - if !follow && can?(:create, Follow) # not already following --# = link_to 'Follow', follows_path(followed: @member), method: :post, class: 'btn btn-default text-right' --# - if follow && can?(:destroy, follow) # already following --# = link_to 'Unfollow', follow_path(follow), method: :delete, class: 'btn btn-default text-right' += render 'members/actions', member: @member - content_for :member_rss_login_name, @member.login_name - content_for :member_rss_slug, @member.slug From ac52fb743ce9a0affeef3e93d8774b10e9bf202b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 17:02:16 +1200 Subject: [PATCH 150/549] tidy post display on small screens --- app/views/posts/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index 578d0af68..dc20c7193 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -35,7 +35,7 @@ %li.breadcrumb-item.active{"aria-current" => "page"}= @post.subject .row - .col-8.col-xs-12 + .col-md-8.col-12 %section.blog-post .card.post{ id: "post-#{@post.id}" } .card-header From 91894db0dbec955e009e3b66960f7856026c6ed2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 17:02:26 +1200 Subject: [PATCH 151/549] Remove unused grid sizer class --- app/views/plantings/_facts.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/plantings/_facts.haml b/app/views/plantings/_facts.haml index 45cc28381..d63a56162 100644 --- a/app/views/plantings/_facts.haml +++ b/app/views/plantings/_facts.haml @@ -9,7 +9,7 @@ - if planting.finished - .fact.card.grid-sizer + .fact.card %h3 Planted %strong=planting_icon - if planting.quantity.present? From 0d3bdc09abbb6e5c1b1171dbc17a2f115c4a64f3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 17:17:25 +1200 Subject: [PATCH 152/549] Tool tips on actions --- app/views/shared/_global_actions.html.haml | 15 +++++---------- config/locales/en.yml | 4 ++++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 56dd01127..a2a60d3a8 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,25 +1,20 @@ - if signed_in? .btn-group = link_to member_gardens_path(member_slug: current_member.slug), - class: 'btn btn-default' do + class: 'btn btn-default', 'data-toggle': "tooltip", 'data-placement': "bottom", title: t('buttons.my_gardens') do = garden_icon - -# = t('.my_gardens') = link_to new_planting_path, - class: 'btn btn-default' do + class: 'btn btn-default', 'data-toggle': "tooltip", 'data-placement': "bottom", title: t('buttons.new_planting') do = planting_icon - -# = t('plantings.plant') = link_to new_harvest_path, - class: 'btn btn-default' do + class: 'btn btn-default', 'data-toggle': "tooltip", 'data-placement': "bottom", title: t('buttons.new_harvest') do = harvest_icon - -# = t('harvests.harvest') = link_to new_seed_path, - class: 'btn btn-default' do + class: 'btn btn-default', 'data-toggle': "tooltip", 'data-placement': "bottom", title: t('buttons.new_seeds') do = seed_icon - -# = t('buttons.save_seeds') = link_to new_post_path, - class: 'btn btn-default' do + class: 'btn btn-default', 'data-toggle': "tooltip", 'data-placement': "bottom", title: t('buttons.new_post') do = blog_icon - -# = t 'posts.write_blog' \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 2142c6d6c..ee6d23382 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -79,6 +79,10 @@ en: mark_as_active: Mark as active mark_as_finished: Mark as finished mark_as_inactive: Mark as inactive + new_seeds: New saved seed + new_planting: New planting + new_post: Write new post + new_harvest: New harvest plant: Plant plant_crop: Plant %{crop_name} plant_something_here: Plant something here From 08116990201d92acebab4c43cf8d8abdb4eb16fa Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 19:15:27 +1200 Subject: [PATCH 153/549] USe search bar partial --- app/views/crops/_search_bar.haml | 13 ++++++------- app/views/layouts/_header.html.haml | 8 +------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/app/views/crops/_search_bar.haml b/app/views/crops/_search_bar.haml index 6d0d412f7..bea22af51 100644 --- a/app/views/crops/_search_bar.haml +++ b/app/views/crops/_search_bar.haml @@ -1,7 +1,6 @@ -= form_tag search_crops_path, method: :get, class: 'navbar-form navbar-left', id: 'navbar-search' do - .input-group.navbar-search - = label_tag :term, "Search crop database:", class: 'sr-only' - = text_field_tag 'term', nil, class: 'search-query input-medium form-control text-white', placeholder: t('crops.search') - .input-group-btn - %button.btn.btn-default{ style: "height: 34px;" } - %span.glyphicon.glyphicon-search += form_tag search_crops_path, method: :get, class: 'form-inline my-2 my-lg-0', id: 'navbar-search' do + .input-group + %input.form-control.mr-sm-2{name: 'term', "aria-label" => "Search", placeholder: "Search", type: "search"}/ + %button.btn.btn-default.text-white{type: "submit"} + = icon 'fas', 'search' + Search \ No newline at end of file diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 30ba563e1..42e1f7245 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -66,10 +66,4 @@ - else %li.nav-item= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin', class: 'btn nav-link' %li.nav-item= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup', class: 'btn nav-link' - - - = form_tag search_crops_path, method: :get, class: 'form-inline my-2 my-lg-0' do - .input-group - %input.form-control.mr-sm-2{name: 'term', "aria-label" => "Search", placeholder: "Search", type: "search"}/ - %button.btn.btn-default.text-white{type: "submit"} - = icon 'fas', 'search' + = render 'crops/search_bar' From 73c834adf3b419fae4693541cf1da329c74c9f3b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 19:15:35 +1200 Subject: [PATCH 154/549] added missing translation --- config/locales/en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index ee6d23382..5c3514fe7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -79,6 +79,7 @@ en: mark_as_active: Mark as active mark_as_finished: Mark as finished mark_as_inactive: Mark as inactive + my_gardens: My Gardens new_seeds: New saved seed new_planting: New planting new_post: Write new post From 223e61b8a8ce307e2ff64022ca8f0af60d041c91 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 19:15:46 +1200 Subject: [PATCH 155/549] Re-instate search title --- app/views/crops/search.html.haml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/crops/search.html.haml b/app/views/crops/search.html.haml index 4dee37fa5..f1c283fbb 100644 --- a/app/views/crops/search.html.haml +++ b/app/views/crops/search.html.haml @@ -1,9 +1,12 @@ - if @term - content_for :title, "Crops matching \"#{@term}\"" + %h1 "Crops matching \"#{@term}\"" - if @crops - - content_for :subtitle, "#{@crops.size} total" + %h2 "#{@crops.size} total" + - else - content_for :title, "Crop search" + %h1 Crop search - content_for :breadcrumbs do %nav{"aria-label" => "breadcrumb"} From 028e149338aee2c4771bfcf5c39c2ef3acc1df0a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 25 May 2019 19:17:53 +1200 Subject: [PATCH 156/549] button label matching spec --- app/views/crops/_actions.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/crops/_actions.html.haml b/app/views/crops/_actions.html.haml index 8060884d1..d3e62d739 100644 --- a/app/views/crops/_actions.html.haml +++ b/app/views/crops/_actions.html.haml @@ -14,4 +14,4 @@ - if can? :create, Seed = link_to new_seed_path(crop_id: crop.id), class: 'btn btn-sm' do = seed_icon - = t('buttons.save_seeds', crop_name: crop.name) + = t('buttons.add_seed_to_stash', crop_name: crop.name) From e220b3dcd83e1e60a9e8e17c3d22df3e3c258b32 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 27 May 2019 08:08:27 +1200 Subject: [PATCH 157/549] MAtching to the specs --- app/views/crops/_photos.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index a32ef2099..56e89f56d 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -6,7 +6,8 @@ - [Planting, Harvest, Seed].each do |model_name| - if photos.by_model(model_name).size.positive? %h3 - %i #{@crop.name} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} + %i + #{@crop.name.capitalize} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} .row - photos.by_model(model_name).limit(4).each do |photo| = render 'photos/thumbnail', photo: photo From 8d07cc6c39fc5c15a64949dce26994e68e25758e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 27 May 2019 08:36:35 +1200 Subject: [PATCH 158/549] More crops tidy --- app/views/crops/_alternate_names.html.haml | 4 +-- app/views/crops/_photos.html.haml | 27 ++++++++++----------- app/views/crops/_scientific_names.html.haml | 17 +++++++++---- app/views/crops/_wrangle.html.haml | 10 +++++--- app/views/crops/search.html.haml | 4 +-- app/views/crops/show.html.haml | 20 ++++++--------- 6 files changed, 43 insertions(+), 39 deletions(-) diff --git a/app/views/crops/_alternate_names.html.haml b/app/views/crops/_alternate_names.html.haml index 02227e6c9..72c798c38 100644 --- a/app/views/crops/_alternate_names.html.haml +++ b/app/views/crops/_alternate_names.html.haml @@ -3,9 +3,9 @@ - if crop.alternate_names.empty? %p None known. - else - %ul + %ul.list-group.list-group-flush - crop.alternate_names.each do |an| - %li + %li.list-group-item.d-flex.justify-content-between.align-items-center = an.name - if can? :edit, an = link_to 'Edit', edit_alternate_name_path(an), class: 'btn btn-default btn-xs' diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index 56e89f56d..6713d8f75 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -1,16 +1,15 @@ -.crop-photos - - if @crop.photos.size.positive? - %h2 - = photo_icon - Photos - - [Planting, Harvest, Seed].each do |model_name| - - if photos.by_model(model_name).size.positive? - %h3 - %i - #{@crop.name.capitalize} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} +- if @crop.photos.size.positive? + %h2 + = photo_icon + Photos + - [Planting, Harvest, Seed].each do |model_name| + - if photos.by_model(model_name).size.positive? + .crop-photos + %h3.font-italic + #{@crop.name.capitalize} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} .row - - photos.by_model(model_name).limit(4).each do |photo| - = render 'photos/thumbnail', photo: photo + - photos.by_model(model_name).limit(6).each do |photo| + .col-2.col-xs-6= render 'photos/thumbnail', photo: photo - %p.text-right= link_to 'more photos »', crop_photos_path(@crop), class: 'btn btn-info' - %hr/ + %p.text-right= link_to 'more photos »', crop_photos_path(@crop), class: 'btn btn-info' + %hr/ diff --git a/app/views/crops/_scientific_names.html.haml b/app/views/crops/_scientific_names.html.haml index 88d93e7a5..b815d018b 100644 --- a/app/views/crops/_scientific_names.html.haml +++ b/app/views/crops/_scientific_names.html.haml @@ -3,14 +3,21 @@ - if crop.scientific_names.empty? %p None known. - else - %ul + %ul.list-group.list-group-flush - crop.scientific_names.each do |sn| - %li + %li.list-group-item.d-flex.justify-content-between.align-items-center = sn.name - if can? :edit, sn - = link_to 'Edit', edit_scientific_name_path(sn), class: 'btn btn-default btn-xs' - - if can? :destroy, sn - = link_to 'Delete', sn, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs' + .dropdown.planting-actions + %button#planting-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} + .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "planting-actions-button"} + = link_to edit_scientific_name_path(sn), class: 'dropdown-item' do + = edit_icon + = t('.edit') + = link_to sn, method: :delete, data: { confirm: 'Are you sure?' }, class: 'dropdown-item' do + = delete_icon + = t('.delete') + %p - if can? :edit, crop = link_to 'Add', new_scientific_name_path(crop_id: crop.id), class: 'btn btn-default btn-xs' diff --git a/app/views/crops/_wrangle.html.haml b/app/views/crops/_wrangle.html.haml index 4260bbfe2..5f4db6057 100644 --- a/app/views/crops/_wrangle.html.haml +++ b/app/views/crops/_wrangle.html.haml @@ -4,6 +4,10 @@ You are a = succeed "." do %strong CROP WRANGLER - - %p= crop_edit_button(crop) if can? :edit, crop - %p= delete_button(crop) if can? :destroy, crop + .dropdown.crop-actions + %button#crop-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions + .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "crop-actions-button"} + = link_to edit_crop_path(crop), class: 'dropdown-item' do + = edit_icon + = t('.edit') + = delete_button(crop) if can? :destroy, crop diff --git a/app/views/crops/search.html.haml b/app/views/crops/search.html.haml index f1c283fbb..5c1578224 100644 --- a/app/views/crops/search.html.haml +++ b/app/views/crops/search.html.haml @@ -1,8 +1,8 @@ - if @term - content_for :title, "Crops matching \"#{@term}\"" - %h1 "Crops matching \"#{@term}\"" + %h1 Crops matching "#{@term}" - if @crops - %h2 "#{@crops.size} total" + %h2 #{@crops.size} total - else - content_for :title, "Crop search" diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index dea9795b2..50da44eac 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -41,24 +41,18 @@ = render 'predictions', crop: @crop %hr/ - = render 'crops/photos', photos: @photos + = render 'crops/photos', photos: @photos, crop: @crop .card-deck.text-center .col-md-4 - .card - .card-body - %h3.section-heading.h3.pt-4 Sunniness - = pie_chart crop_sunniness_path(@crop, format: :json), legend: "bottom" + %h3.section-heading.h3.pt-4 Sunniness + = pie_chart crop_sunniness_path(@crop, format: :json), legend: "bottom" .col-md-4 - .card - .card-body - %h3.section-heading.h3.pt-4 Planted from - = pie_chart crop_planted_from_path(@crop, format: :json), legend: "bottom" + %h3.section-heading.h3.pt-4 Planted from + = pie_chart crop_planted_from_path(@crop, format: :json), legend: "bottom" .col-md-4 - .card - .card-body - %h3.section-heading.h3.pt-4 Harvested for - = pie_chart crop_harvested_for_path(@crop, format: :json), legend: "bottom" + %h3.section-heading.h3.pt-4 Harvested for + = pie_chart crop_harvested_for_path(@crop, format: :json), legend: "bottom" .varieties= render 'varieties', crop: @crop From 27b3f5fac967a94a254a837851a27e68bc4784da Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 27 May 2019 08:36:46 +1200 Subject: [PATCH 159/549] turn of shadow on thumbnails --- app/views/photos/_thumbnail.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/photos/_thumbnail.html.haml b/app/views/photos/_thumbnail.html.haml index 1e7d0044d..7ee9c2da8 100644 --- a/app/views/photos/_thumbnail.html.haml +++ b/app/views/photos/_thumbnail.html.haml @@ -1,6 +1,6 @@ .thumbnail .photo-thumbnail - = link_to image_tag(photo.thumbnail_url, alt: photo.title, class: 'img img-responsive rounded shadow'), photo + = link_to image_tag(photo.thumbnail_url, alt: photo.title, class: 'img img-responsive rounded'), photo .text %p = link_to photo.title, photo From 8d6e48ad3d785ce5882ba8369d78790c7a19c664 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 27 May 2019 09:27:43 +1200 Subject: [PATCH 160/549] tidy up crops form --- app/views/crops/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/crops/_form.html.haml b/app/views/crops/_form.html.haml index 873a1195d..43ddc23f8 100644 --- a/app/views/crops/_form.html.haml +++ b/app/views/crops/_form.html.haml @@ -1,4 +1,4 @@ -.card.col-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2 +.card.col-12.col-md-8.mx-auto.float-none.white.z-depth-1.py-2.px-2 = bootstrap_form_for(@crop) do |f| .card-header - if content_for? :title From 390ac6587f62e4af58bb691fec35bc35c24714c4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 27 May 2019 09:29:32 +1200 Subject: [PATCH 161/549] Seed cards title smaller, fit more on screen --- app/views/seeds/_card.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index 64f8ce6a6..a42b51606 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -36,7 +36,7 @@ = link_to seed do = image_tag(seed_image_path(seed, full_size: true), alt: seed, class: 'img-card') .card-body - %h5.card-title= link_to seed, seed + %h5= link_to seed, seed - if seed.tradable? %span.badge.badge-pill.badge-secondary Will trade #{seed.tradable_to} .card-footer From 2f4fc948db87436e54d8b82a24f44517b0ef195c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 29 May 2019 10:48:26 +1200 Subject: [PATCH 162/549] Move overrides last --- app/assets/stylesheets/application.scss | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 1fa07ad01..0753bfd64 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -1,6 +1,5 @@ @import "material"; @import "variables"; -@import "overrides"; @import "jquery-ui/autocomplete"; @import "bootstrap-datepicker"; @@ -21,4 +20,6 @@ @import "font-awesome-sprockets"; @import "font-awesome"; @import "material_icons"; -@import 'rails_bootstrap_forms'; \ No newline at end of file +@import 'rails_bootstrap_forms'; + +@import "overrides"; \ No newline at end of file From 73996317d5ba4eae88628502860ab11cc732d921 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 29 May 2019 10:48:56 +1200 Subject: [PATCH 163/549] Fixing display on small screens --- app/assets/stylesheets/homepage.scss | 27 ++++++++++++++++++++++++++- app/assets/stylesheets/overrides.scss | 18 ++++++++++++------ app/views/home/_crops.html.haml | 2 +- app/views/home/_seeds.html.haml | 5 +++-- app/views/plantings/index.html.haml | 2 +- app/views/seeds/_card.html.haml | 2 +- 6 files changed, 44 insertions(+), 12 deletions(-) diff --git a/app/assets/stylesheets/homepage.scss b/app/assets/stylesheets/homepage.scss index b75f13ee0..ec64154d0 100644 --- a/app/assets/stylesheets/homepage.scss +++ b/app/assets/stylesheets/homepage.scss @@ -27,7 +27,6 @@ left: -0.5em; .card { - width: 200px; min-height: 100px; margin: 0.5em; padding: 0; @@ -37,8 +36,34 @@ font-size: 2em; } } + .crop-card { + width: 120px; + min-height: 80px; + } .thumbnail { margin: 0.5em; } } + +@include media-breakpoint-down(sm) { + .seed-card { + width: 100%; + min-height: 80px; + align: center; + } + .img-card { + object-fit: cover; + height: 75px; + width: 100%; + } +} + +@include media-breakpoint-up(md) { + + .homepage-cards { + .card { + width: 200px; + } + } +} diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index 85169ce10..f0155bbd5 100644 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -430,7 +430,8 @@ ul.thumbnail-buttons { max-width: 1500px; } -@include media-breakpoint-up(md) { +// Small devices (landscape phones, less than 768px) +@include media-breakpoint-down(md) { .planting-thumbnail { dl.planting-attributes { width: 100%; @@ -461,10 +462,14 @@ ul.thumbnail-buttons { display: inline-block; padding: 1em; } + .crop-card { + width: 100px; + } } // Overrides applying only to mobile view. This must be at the end of the overrides file. -@include media-breakpoint-up(sm) { +// Extra small devices (portrait phones, less than 576px) +@include media-breakpoint-down(xs) { .sidebar { margin-left: 0; border-left: none; @@ -489,11 +494,12 @@ ul.thumbnail-buttons { } } - //.homepage - // .thumbnail - // height: 180px - #maincontainer { padding: 10px; } + .homepage-cards { + .crop-card { + width: 50px; + } + } } diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml index 6aabdc6db..bfcfa85b2 100644 --- a/app/views/home/_crops.html.haml +++ b/app/views/home/_crops.html.haml @@ -1,4 +1,4 @@ - cache cache_key_for(Crop, 'homepage'), expires_in: 1.day do - Crop.interesting.includes(:scientific_names, :photos).shuffle.first(12).each do |crop| - = render 'crops/thumbnail', crop: crop + .col-6.col-md-3= render 'crops/thumbnail', crop: crop diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml index 942422782..98d1e5f6f 100644 --- a/app/views/home/_seeds.html.haml +++ b/app/views/home/_seeds.html.haml @@ -1,3 +1,4 @@ - cache cache_key_for(Seed) do - %h2= t('.title') - .homepage-cards= render 'seeds/list', seeds: Seed.current.tradable.includes(:owner, :crop).order(created_at: :desc).limit(6) + .homepage-cards + - Seed.current.tradable.includes(:owner, :crop).order(created_at: :desc).limit(3).each do |seed| + = render 'seeds/card', seed: seed diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index 5c016b0b3..2ffa77097 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -15,7 +15,7 @@ .row - @plantings.each do |planting| - .col-2.col-xs-6= render 'plantings/card', planting: planting + .col-6.col-md-2= render 'plantings/card', planting: planting .pagination = page_entries_info @plantings diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index a42b51606..002855cb7 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -32,7 +32,7 @@ -# %p= render 'seeds/actions', seed: seed -.card +.card.seed-card = link_to seed do = image_tag(seed_image_path(seed, full_size: true), alt: seed, class: 'img-card') .card-body From 210b91285939949efdefd670be68983a30491abf Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 29 May 2019 15:06:09 +1200 Subject: [PATCH 164/549] Home page tidy --- app/assets/stylesheets/homepage.scss | 9 ++++----- app/assets/stylesheets/members.scss | 2 +- app/views/home/_discuss.html.haml | 20 +------------------- app/views/home/_members.html.haml | 4 ++-- app/views/home/_plantings.html.haml | 2 +- app/views/home/index.html.haml | 17 ++++++++--------- app/views/members/_member.haml | 20 ++++++++++++-------- 7 files changed, 29 insertions(+), 45 deletions(-) diff --git a/app/assets/stylesheets/homepage.scss b/app/assets/stylesheets/homepage.scss index ec64154d0..72672142f 100644 --- a/app/assets/stylesheets/homepage.scss +++ b/app/assets/stylesheets/homepage.scss @@ -52,15 +52,14 @@ min-height: 80px; align: center; } - .img-card { - object-fit: cover; - height: 75px; - width: 100%; + .member-card { + width: 150px; + min-height: 80px; + align: center; } } @include media-breakpoint-up(md) { - .homepage-cards { .card { width: 200px; diff --git a/app/assets/stylesheets/members.scss b/app/assets/stylesheets/members.scss index 433d8ab0a..5e8d3b09d 100644 --- a/app/assets/stylesheets/members.scss +++ b/app/assets/stylesheets/members.scss @@ -4,7 +4,7 @@ flex-wrap: wrap; .card { - max-width: 200px; + width: 150px; margin: 1em; } } diff --git a/app/views/home/_discuss.html.haml b/app/views/home/_discuss.html.haml index 54d627214..c8ceb404e 100644 --- a/app/views/home/_discuss.html.haml +++ b/app/views/home/_discuss.html.haml @@ -1,22 +1,4 @@ -%h2= t('.discussion') - --# - Post.order(created_at: :desc).limit(6).each do |post| - --# = link_to truncate(strip_tags(post.subject), length: 40, separator: ' '), post --# by --# = link_to post.author, post.author - --# - cache cache_key_for(Forum) do --# - forums = Forum.all.order(:name) --# - if forums --# %ul.list-inline --# %li --# %strong #{t('.forums')}: --# - forums.each do |f| --# %li= link_to f.name, f - - - +%h2.text-center= t('.discussion') .list-group - Post.order(created_at: :desc).limit(3).each do |post| = link_to post, class: 'list-group-item list-group-item-action flex-column align-items-start' do diff --git a/app/views/home/_members.html.haml b/app/views/home/_members.html.haml index fec54fbb8..c18ccfc93 100644 --- a/app/views/home/_members.html.haml +++ b/app/views/home/_members.html.haml @@ -1,8 +1,8 @@ - cache cache_key_for(Member) do - .hidden-xs.well + .hidden-xs - members = Member.includes(plantings: :crop).interesting.first(6) - if members.present? - %h2= t('.title') + %h2.text-center= t('.title') .member-cards = render members diff --git a/app/views/home/_plantings.html.haml b/app/views/home/_plantings.html.haml index 82f68f0bf..c06951ada 100644 --- a/app/views/home/_plantings.html.haml +++ b/app/views/home/_plantings.html.haml @@ -2,7 +2,7 @@ %h5= t('.recently_planted') - Planting.has_photos.recent.includes(:crop, garden: :owner).limit(6).each do |planting| - .card + .card.planting-card = link_to planting, class: 'list-group-item list-group-item-action flex-column align-items-start' do .d-flex.w-100.justify-content-between %p.mb-2= image_tag planting_image_path(planting), width: 75, class: 'rounded shadow' diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 073629344..75c96dbda 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -2,7 +2,7 @@ = ENV['GROWSTUFF_SITE_NAME'] - if member_signed_in? - %h1= t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) + %h1.display-5= t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) %p= render 'stats' - else @@ -24,12 +24,11 @@ .col-md-6.col-sm-12=render 'plantings' .col-md-6.col-sm-12= render 'harvests' - .col-12 - %section.seeds - %h2.text-center= t('.seeds_available_to_trade') - = render 'seeds' - .align-bottom - %p.text-right= link_to "#{t('home.seeds.view_all')} »", seeds_path, class: 'btn' + %section.seeds.mx-auto + %h2.text-center= t('.seeds_available_to_trade') + = render 'seeds' + .align-bottom + %p.text-right= link_to "#{t('home.seeds.view_all')} »", seeds_path, class: 'btn' - %section.members= render 'members' - %section.members= render 'discuss' \ No newline at end of file + %section.members.mx-auto= render 'members' + %section.discussion.mx-auto= render 'discuss' \ No newline at end of file diff --git a/app/views/members/_member.haml b/app/views/members/_member.haml index 69d879f7c..2782c1106 100644 --- a/app/views/members/_member.haml +++ b/app/views/members/_member.haml @@ -1,12 +1,10 @@ - cache member do - .card.text-center + .card.member-card.text-center .avatar.mx-auto = link_to member do = image_tag(avatar_uri(member, 150), class: 'rounded-circle img-fluid shadow member-avatar', alt: member) .card-body - / Name - %h4.card-title - = link_to member, member + %h4.card-title= link_to member, member %hr/ %p %small @@ -14,7 +12,13 @@ = distance_of_time_in_words(member.created_at, Time.zone.now) ago. %p - %ul.nav.md-pills.nav-justified.small - %li.nav-item= link_to localize_plural(member.plantings, Planting), member_plantings_path(member) - %li.nav-item= link_to localize_plural(member.harvests, Harvest), member_harvests_path(member) - %li.nav-item= link_to localize_plural(member.seeds, Seed), member_seeds_path(member) + %ul.nav.nav-justified.small + %li.nav-item.border-right + = link_to member_plantings_path(member) do + = localize_plural(member.plantings, Planting) + %li.nav-item.border-right + = link_to member_harvests_path(member) do + = localize_plural(member.harvests, Harvest) + %li.nav-item + = link_to member_seeds_path(member) do + = localize_plural(member.seeds, Seed) From f0d49b7e9d5ce5b3b8779727086acdb0be40a65a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 29 May 2019 15:09:34 +1200 Subject: [PATCH 165/549] capitalize to match the specs --- app/views/crops/show.html.haml | 18 ++++++++++++++---- app/views/members/_bio.html.haml | 2 +- script/percy-new.sh | 4 ++++ 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100755 script/percy-new.sh diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 50da44eac..45be7da6f 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -87,18 +87,18 @@ .list-group-item.list-group-flush.d-flex.justify-content-between.align-items-center = link_to crop_plantings_path(@crop), class: 'card-link' do = planting_icon - #{@crop.name} plantings + #{@crop.name.capitalize} plantings %span.badge.badge-primary.badge-pill=@crop.plantings.size .list-group-item.d-flex.justify-content-between.align-items-center = link_to crop_harvests_path(@crop) do = harvest_icon - #{@crop.name} harvests + #{@crop.name.capitalize} harvests %span.badge.badge-primary.badge-pill=@crop.harvests.size .list-group-item.d-flex.justify-content-between.align-items-center = link_to crop_seeds_path(@crop) do = seed_icon - #{@crop.name} seeds + #{@crop.name.capitalize} seeds %span.badge.badge-primary.badge-pill=@crop.seeds.size - if member_signed_in? @@ -109,10 +109,20 @@ .card-body = render 'scientific_names', crop: @crop = render 'alternate_names', crop: @crop + .card-body + %h3 See who's planted #{@crop.name.pluralize} + %ul.list-group.list-group-flush + - @crop.plantings.order(planted_at: :desc).limit(5).each do |planting| + %li.list-group-item + = link_to planting do + = planting_icon + = planting + - if planting.owner.location.present? + %small=planting.owner.location + %hr/ - = render 'find_seeds', crop: @crop %hr/ diff --git a/app/views/members/_bio.html.haml b/app/views/members/_bio.html.haml index 3858d224c..f22d7eeb0 100644 --- a/app/views/members/_bio.html.haml +++ b/app/views/members/_bio.html.haml @@ -1,7 +1,7 @@ %h2 All about #{member.login_name} - if member.bio.blank? - if can? :edit, member - = link_to "Add a bio to complete your profile." + = link_to "Add a bio to complete your profile.", edit_member_path(member) - else #{member.login_name} hasn't written a bio yet. - else diff --git a/script/percy-new.sh b/script/percy-new.sh new file mode 100755 index 000000000..e5db82272 --- /dev/null +++ b/script/percy-new.sh @@ -0,0 +1,4 @@ +#!/bin/bash +bundle exec rails assets:precompile +export PERCY_TOKEN=047f5b0ecf3ca0a2bc94a6cfc837e625ace93ef0d81cc8ac82e3fb3aebd5c17f +PERCY_TARGET_BRANCH=dev npx percy exec -- bundle exec rspec spec/features/percy/ From 7f1bb7913c5787c0dcd71acd33196133f74270eb Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Wed, 29 May 2019 21:48:42 +0000 Subject: [PATCH 166/549] [CodeFactor] Apply fixes --- app/assets/stylesheets/overrides.scss | 16 ++++++++-------- app/assets/stylesheets/plantings.scss | 6 +++--- app/controllers/plantings_controller.rb | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) mode change 100644 => 100755 app/assets/stylesheets/overrides.scss mode change 100644 => 100755 app/assets/stylesheets/plantings.scss diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss old mode 100644 new mode 100755 index f0155bbd5..d3a79291f --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -35,7 +35,7 @@ span.badge { } .list-inline > li.first { - padding-left: 0px; + padding-left: 0; } .activity-list { @@ -104,11 +104,11 @@ h3 { // this is used for eg. crops and members index pages .six-across:nth-child(6n+1) { - margin-left: 0px; + margin-left: 0; } .three-across:nth-child(3n+1) { - margin-left: 0px; + margin-left: 0; clear: both; } @@ -279,12 +279,12 @@ li.crop-hierarchy { } .navbar-brand { - margin: 0px; - padding: 0px; + margin: 0; + padding: 0; } .navbar-bottom { - margin: 40px 0px 0px 0px !important; + margin: 40px 0 0 !important; } .post-actions { @@ -301,8 +301,8 @@ footer { ul { list-style-type: none; list-style-position: outside; - padding-left: 0px; - margin-left: 0px; + padding-left: 0; + margin-left: 0; } a { diff --git a/app/assets/stylesheets/plantings.scss b/app/assets/stylesheets/plantings.scss old mode 100644 new mode 100755 index cf06c1bb9..7cfe505c2 --- a/app/assets/stylesheets/plantings.scss +++ b/app/assets/stylesheets/plantings.scss @@ -23,7 +23,7 @@ .planting-thumbnail { width: 150px; - padding: 0em; + padding: 0; margin-bottom: 0.5em; margin-top: 0.5em; @@ -41,14 +41,14 @@ .planting-name { position: relative; text-align: center; - top: 0em; + top: 0; } .planting-quick-actions { position: absolute; //Mine - top: 0px; + top: 0; left: 130px; //Upstream diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 54ef9563f..e1e0847ed 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -41,7 +41,7 @@ class PlantingsController < ApplicationController end def new - @planting = Planting.new(planted_at: Time.zone.today, owner: current_member ) + @planting = Planting.new(planted_at: Time.zone.today, owner: current_member) @seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id] # using find_by_id here because it returns nil, unlike find From 85410858cc0e2580d35a2c82d9e078fe49aff6fd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 30 May 2019 09:49:37 +1200 Subject: [PATCH 167/549] Tidy up the delete link in crops actions --- app/views/crops/_wrangle.html.haml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/views/crops/_wrangle.html.haml b/app/views/crops/_wrangle.html.haml index 5f4db6057..2add6dbe0 100644 --- a/app/views/crops/_wrangle.html.haml +++ b/app/views/crops/_wrangle.html.haml @@ -10,4 +10,9 @@ = link_to edit_crop_path(crop), class: 'dropdown-item' do = edit_icon = t('.edit') - = delete_button(crop) if can? :destroy, crop + + - if can? :destroy, crop + .dropdown-divider + = link_to crop, method: :delete, class: 'dropdown-item bg-danger' do + = delete_icon + Delete From f7db832a0e8d0f83273903b107f4e1b65fbfb113 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 30 May 2019 09:49:50 +1200 Subject: [PATCH 168/549] Match the tests further --- app/views/crops/show.html.haml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 45be7da6f..2e8f26b7d 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -19,7 +19,7 @@ %li.breadcrumb-item.active= link_to @crop, @crop %h1 - = @crop.name + = @crop.name.titleize %small= @crop.default_scientific_name = render 'approval_status_message', crop: @crop @@ -30,13 +30,17 @@ .row .col-md-9 - %h2 + %p - if !@crop.plantings.empty? #{@crop.name.titleize} has been planted = pluralize(@crop.plantings.size, "time") by #{ENV['GROWSTUFF_SITE_NAME']} members. - else Nobody is growing this yet. You could be the first! + - if @crop.perennial? + #{@crop.name.titleize} is a perennial crop (living more than two years) + - else + #{@crop.name.titleize} is an annual crop (living and reproducing in a single year or less) %hr/ = render 'predictions', crop: @crop From 5255b5d57248348e84b11115b37ffff5c9e85eaf Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 3 Jun 2019 22:22:28 +1200 Subject: [PATCH 169/549] More crops tidy up --- app/views/crops/_actions.html.haml | 2 +- app/views/crops/_alternate_names.html.haml | 21 +++++++++++++++------ app/views/crops/_scientific_names.html.haml | 8 ++++---- app/views/crops/index.html.haml | 6 +----- app/views/crops/show.html.haml | 17 +++++------------ 5 files changed, 26 insertions(+), 28 deletions(-) diff --git a/app/views/crops/_actions.html.haml b/app/views/crops/_actions.html.haml index d3e62d739..2d5ed101f 100644 --- a/app/views/crops/_actions.html.haml +++ b/app/views/crops/_actions.html.haml @@ -1,4 +1,4 @@ -- if signed_in? +- if @crop.approved? && signed_in? .crop-actions .btn-group - if can? :create, Planting diff --git a/app/views/crops/_alternate_names.html.haml b/app/views/crops/_alternate_names.html.haml index 72c798c38..54623730d 100644 --- a/app/views/crops/_alternate_names.html.haml +++ b/app/views/crops/_alternate_names.html.haml @@ -8,9 +8,18 @@ %li.list-group-item.d-flex.justify-content-between.align-items-center = an.name - if can? :edit, an - = link_to 'Edit', edit_alternate_name_path(an), class: 'btn btn-default btn-xs' - - if can? :destroy, an - = link_to 'Delete', an, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs' - %p - - if can? :edit, crop - = link_to 'Add', new_alternate_name_path(crop_id: crop.id), class: 'btn btn-default btn-xs' + .dropdown.planting-actions + %a#planting-actions-scinames.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} + .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "planting-actions-button"} + - if can? :edit, an + = link_to edit_alternate_name_path(an), class: 'dropdown-item' do + = edit_icon + = t('.edit') + - if can? :destroy, an + = link_to an, method: :delete, data: { confirm: 'Are you sure?' }, class: 'dropdown-item' do + = delete_icon + = t('.delete') + + %p.text-right + - if can? :edit, crop + = link_to 'Add', new_alternate_name_path(crop_id: crop.id), class: 'btn btn-default btn-xs' diff --git a/app/views/crops/_scientific_names.html.haml b/app/views/crops/_scientific_names.html.haml index b815d018b..7a566d689 100644 --- a/app/views/crops/_scientific_names.html.haml +++ b/app/views/crops/_scientific_names.html.haml @@ -9,7 +9,7 @@ = sn.name - if can? :edit, sn .dropdown.planting-actions - %button#planting-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} + %a#planting-actions-scinames.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "planting-actions-button"} = link_to edit_scientific_name_path(sn), class: 'dropdown-item' do = edit_icon @@ -18,6 +18,6 @@ = delete_icon = t('.delete') - %p - - if can? :edit, crop - = link_to 'Add', new_scientific_name_path(crop_id: crop.id), class: 'btn btn-default btn-xs' + %p.text-right + - if can? :edit, crop + = link_to 'Add', new_scientific_name_path(crop_id: crop.id), class: 'btn btn-default btn-xs' diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml index 19bb52b41..f405e4645 100644 --- a/app/views/crops/index.html.haml +++ b/app/views/crops/index.html.haml @@ -7,11 +7,7 @@ = link_to 'Add new Crop', new_crop_path, class: 'btn btn-primary' - content_for :breadcrumbs do - %nav{"aria-label" => "breadcrumb"} - %ol.breadcrumb - %li.breadcrumb-item - = link_to 'Home', root_path - %li.breadcrumb-item.active= link_to 'Crops', crops_path + %li.breadcrumb-item.active= link_to 'Crops', crops_path %h1=t('.title') %p diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 2e8f26b7d..2abffc22b 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -11,23 +11,16 @@ = javascript_include_tag "charts" - content_for :breadcrumbs do - %nav{"aria-label" => "breadcrumb"} - %ol.breadcrumb - %li.breadcrumb-item - = link_to 'Home', root_path - %li.breadcrumb-item= link_to 'Crops', crops_path - %li.breadcrumb-item.active= link_to @crop, @crop + %li.breadcrumb-item= link_to 'Crops', crops_path + %li.breadcrumb-item.active= link_to @crop, @crop %h1 - = @crop.name.titleize - %small= @crop.default_scientific_name + %strong= @crop.name.titleize + %small.text-muted= @crop.default_scientific_name +%p= render 'crops/actions', crop: @crop = render 'approval_status_message', crop: @crop -- if @crop.approved? - - content_for :buttonbar do - = render 'crops/actions', crop: @crop - .row .col-md-9 %p From 7c45647ff2fd4d138bcf7421d6416c2793dd2f32 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 3 Jun 2019 22:22:40 +1200 Subject: [PATCH 170/549] gardens tidy up --- app/views/gardens/_actions.html.haml | 26 ++++--- app/views/gardens/index.html.haml | 14 +++- app/views/gardens/show.html.haml | 107 +++++++++++++++------------ 3 files changed, 87 insertions(+), 60 deletions(-) diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index ea97a3931..0d28c1092 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -1,14 +1,16 @@ -.garden-actions - - if can?(:edit, garden) - = garden_plant_something_button(garden) if garden.active - .btn-group - - if garden.active - = garden_mark_inactive_button(garden) - - else - = garden_mark_active_button(garden) +- if can?(:edit, garden) + .dropdown.float-right.garden-actions + %a#garden-actions-button.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} + .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "garden-actions-button"} + - if can?(:edit, garden) + .dropdown-item= garden_plant_something_button(garden) if garden.active + - if garden.active + .dropdown-item= garden_mark_inactive_button(garden) + - else + .dropdown-item= garden_mark_active_button(garden) - = garden_edit_button(garden) - = add_photo_button(garden) + .dropdown-item= garden_edit_button(garden) + .dropdown-item= add_photo_button(garden) - - if can?(:destroy, garden) - = delete_button(garden, message: 'All plantings associated with this garden will also be deleted. Are you sure?') + - if can?(:destroy, garden) + .dropdown-item= delete_button(garden, message: 'All plantings associated with this garden will also be deleted. Are you sure?') diff --git a/app/views/gardens/index.html.haml b/app/views/gardens/index.html.haml index aa9552041..17248030b 100644 --- a/app/views/gardens/index.html.haml +++ b/app/views/gardens/index.html.haml @@ -15,7 +15,19 @@ %p There are no gardens to display. - else - @gardens.each do |garden| - = render 'overview', garden: garden + %section.border-top + .row + .col-md-2.border-right + %h2 + %strong= link_to garden, garden + = render 'gardens/actions', garden: garden + %p + = pluralize(garden.plantings.active.size, "planting") + .col-md-10 + .row + - garden.plantings.active.each do |planting| + .col-6.col-md-2= render 'plantings/card', planting: planting + .pagination = page_entries_info @gardens diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index a021ea0c0..009c8490d 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -14,9 +14,11 @@ = javascript_include_tag "charts" = javascript_include_tag "https://www.gstatic.com/charts/loader.js" --content_for(:buttonbar) do - = render 'gardens/actions', garden: @garden - +.row + .col-md-9.col-sm-12 + %h2.h1 + %strong= @garden + = render 'gardens/actions', garden: @garden .row .col-md-9 - unless @garden.active @@ -39,48 +41,61 @@ Why not = link_to 'tell us more.', edit_garden_path(@garden) - %h3 Garden timeline .row - .col-md-12= timeline garden_timeline_path(@garden), adapter: "google" + .col-md-12 + %section.card + .card-header + %h3 Garden timeline + .card-body= timeline garden_timeline_path(@garden), adapter: "google" - %h3 Current plantings in garden - .row - - if @current_plantings.size.positive? - - @current_plantings.each do |planting| - .col-xs-12.col-3= render "plantings/card", planting: planting - - else - .col-md-12 - %p Nothing is currently planted here. - %h3 Previously planted in this garden - .row - - if @finished_plantings.size.positive? - - @finished_plantings.each do |planting| - .col-xs-6.col-md-2 - = render "plantings/thumbnail", planting: planting - - else - %p Nothing has been planted here. + %section + %h3.h3 Current plantings in garden + .row + - if @current_plantings.size.positive? + - @current_plantings.each do |planting| + .col-xs-12.col-3= render "plantings/card", planting: planting + - else + .col-md-12 + %p Nothing is currently planted here. + %section + %h3.h3 Previously planted in this garden + .row + - if @finished_plantings.size.positive? + - @finished_plantings.each do |planting| + .col-xs-6.col-md-2 + = render "plantings/thumbnail", planting: planting + - else + %p Nothing has been planted here. .col-md-3 - %h4 About this garden - %p - %strong Owner: - = link_to @garden.owner, @garden.owner - - unless @garden.location.blank? - %p - %strong Location: - = @garden.location - - unless @garden.area.blank? - %p - %strong Area: - = pluralize(@garden.area, @garden.area_unit) - - %h4 "#{@garden.owner}'s gardens" - %ul - - @garden.owner.gardens.active.each do |othergarden| - %li - - if @garden == othergarden - = @garden - - else - = link_to othergarden, garden_path(othergarden) + .card + .card-image + = image_tag garden_image_path(@garden, full_size: true), class: 'img-card', alt: 'photo of this garden' + .card-body + %h4 About this garden + %p + %strong Owner: + = link_to @garden.owner, @garden.owner + - unless @garden.location.blank? + %p + %strong Location: + = @garden.location + - unless @garden.area.blank? + %p + %strong Area: + = pluralize(@garden.area, @garden.area_unit) + %hr/ + .card + .card-header + %h4 #{@garden.owner}'s gardens + .card-body + %ul.list-group.list-group-flush + - @garden.owner.gardens.active.each do |garden| + %li.list-group-item.list-group-flush + = garden_icon + - if @garden == garden + = @garden + - else + = link_to garden, garden_path(garden) - unless @garden.owner.gardens.inactive.empty? %h4 Inactive gardens @@ -98,11 +113,9 @@ Add New Garden - if can?(:edit, @garden) && can?(:create, Photo) - %p - = link_to new_photo_path(type: "garden", id: @garden.id), - class: 'btn btn-primary' do - %span.glyphicon.glyphicon-camera{ title: "Add photo" } - Add photo + %%p + = add_photo_button(@garden) + - if @garden.photos.size.positive? %h3= localize_plural(@garden.photos, Photo) .row From 11afea1c542e3fb069fe3253cf007b38bad0fd79 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 3 Jun 2019 22:22:53 +1200 Subject: [PATCH 171/549] fixing plantings form --- app/controllers/plantings_controller.rb | 2 +- app/views/plantings/_form.html.haml | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index e1e0847ed..22cf9fe68 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -46,7 +46,7 @@ class PlantingsController < ApplicationController # using find_by_id here because it returns nil, unlike find @crop = Crop.approved.find_by(id: params[:crop_id]) || Crop.new - @garden = Garden.find_by(owner: current_member, id: params[:garden_id]) || Garden.new + @garden = Garden.find_by(owner: current_member, id: params[:garden_id]) respond_with @planting end diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml index 0be7dd0dd..21448b179 100644 --- a/app/views/plantings/_form.html.haml +++ b/app/views/plantings/_form.html.haml @@ -27,11 +27,15 @@ .row .col-md-8 - = f.collection_radio_buttons(:garden_id, - @planting.owner.gardens.active.order_by_name, - :id, :name, required: true, - label: 'Where did you plant it?') - = link_to "Add a garden.", new_garden_path + - if @garden.present? + %p Planted in #{link_to @garden, @garden} + = f.hidden_field :garden_id, value: @garden.id + - else + = f.collection_radio_buttons(:garden_id, + @planting.owner.gardens.active.order_by_name, + :id, :name, required: true, + label: 'Where did you plant it?') + = link_to "Add a garden.", new_garden_path .col-md-4 = f.text_field :planted_at, value: @planting.planted_at ? @planting.planted_at.to_s(:ymd) : '', From 6bc32911854f789e2356a559444c615afcb9157f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 3 Jun 2019 22:23:06 +1200 Subject: [PATCH 172/549] tidy up plantings --- app/views/plantings/_actions.html.haml | 19 +++++++------------ app/views/plantings/index.html.haml | 9 ++++++++- app/views/plantings/show.html.haml | 7 ++++--- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/app/views/plantings/_actions.html.haml b/app/views/plantings/_actions.html.haml index 2191358e6..87486c194 100644 --- a/app/views/plantings/_actions.html.haml +++ b/app/views/plantings/_actions.html.haml @@ -1,17 +1,12 @@ - if can?(:edit, planting) .dropdown.float-right.planting-actions - %button#planting-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions + %a#planting-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "planting-actions-button"} - = link_to edit_planting_path(planting), class: 'dropdown-item' do - = edit_icon - = t('.edit') - = link_to new_photo_path(id: planting.id, type: 'planting'), class: "dropdown-item" do - = photo_icon - = t('buttons.add_photo') - = add_photo_button(planting) + .dropdown-item= planting_edit_button(planting) + .dropdown-item= add_photo_button(planting) - if planting.active? - = planting_finish_button(planting) - = planting_harvest_button(planting) - = planting_save_seeds_button(planting) + .dropdown-item= planting_finish_button(planting) + .dropdown-item= planting_harvest_button(planting) + .dropdown-item= planting_save_seeds_button(planting) - if can? :destroy, planting - = delete_button(planting) + .dropdown-item= delete_button(planting) diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index 2ffa77097..6787f86a3 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -1,7 +1,14 @@ -- content_for :title, title('plantings', @owner, @crop, @planting) +%h1=title('plantings', @owner, @crop, @planting) = render 'layouts/nav', model: Planting +- content_for :breadcrumbs do + - if @owner + %li.breadcrumb-item= link_to 'Plantings', plantings_path + %li.breadcrumb-item.active= link_to "#{@owner}'s plantings", plantings_path(owner: @owner) + - else + %li.breadcrumb-item.active= link_to 'Plantings', plantings_path + = link_to plantings_active_tickbox_path(@owner, @show_all) do = check_box_tag 'active', 'all', @show_all include in-active diff --git a/app/views/plantings/show.html.haml b/app/views/plantings/show.html.haml index d43563634..d191ac693 100644 --- a/app/views/plantings/show.html.haml +++ b/app/views/plantings/show.html.haml @@ -9,13 +9,14 @@ = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) -- content_for :buttonbar do - = render 'plantings/actions', planting: @planting .planting .row .col-md-8.col-xs-12 - %h2.h1= @planting + %h2.h1 + %strong= @planting + = render 'plantings/actions', planting: @planting + = render 'facts', planting: @planting - if @planting.description.present? %hr/ From 00010d3a0f0eb83be47cc6a36551bac57c359c16 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 3 Jun 2019 22:23:36 +1200 Subject: [PATCH 173/549] Breadcrumps --- app/views/harvests/index.html.haml | 9 ++++++++- app/views/layouts/application.html.haml | 9 +++++++-- app/views/photos/index.html.haml | 4 +++- app/views/photos/show.html.haml | 4 ++++ app/views/seeds/_card.html.haml | 1 - app/views/seeds/index.html.haml | 9 ++++++++- app/views/seeds/show.html.haml | 4 ++++ 7 files changed, 34 insertions(+), 6 deletions(-) diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index ca8bc773c..7eafe377d 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -1,4 +1,4 @@ -- content_for :title, title('harvests', @owner, @crop, @planting) +%h1=title('harvests', @owner, @crop, @planting) - if @owner = link_to "View #{@owner}'s profile >>", member_path(@owner) @@ -9,6 +9,13 @@ = render 'layouts/nav', model: Harvest +- content_for :breadcrumbs do + - if @owner + %li.breadcrumb-item= link_to 'Harvests', harvests_path + %li.breadcrumb-item.active= link_to "#{@owner}'s harvests", harvests_path(owner: @owner) + - else + %li.breadcrumb-item.active= link_to "Harvests", harvests_path + .pagination = page_entries_info @harvests = will_paginate @harvests diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index d62e4f4bf..802f7255d 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -12,9 +12,14 @@ .col-12 .float-right= render 'shared/global_actions' - if content_for?(:breadcrumbs) - .float-left= yield(:breadcrumbs) + .float-left + %nav{"aria-label" => "breadcrumb"} + %ol.breadcrumb + %li.breadcrumb-item= link_to 'Home', root_path + = yield(:breadcrumbs) + - if content_for?(:buttonbar) - = yield(:buttonbar) + .float-right= yield(:buttonbar) - if content_for?(:subtitle) %small= yield(:subtitle) diff --git a/app/views/photos/index.html.haml b/app/views/photos/index.html.haml index 7e4acc53c..3ebb3de2d 100644 --- a/app/views/photos/index.html.haml +++ b/app/views/photos/index.html.haml @@ -1,4 +1,4 @@ -- content_for :title do +%h1 - if @crop Photos of #{@crop.name} - elsif @planting.present? @@ -6,6 +6,8 @@ - else Most recent photos added to #{ENV['GROWSTUFF_SITE_NAME']}. +- content_for :breadcrumbs do + %li.breadcrumb-item= link_to 'Photos', photos_path .pagination = page_entries_info @photos = will_paginate @photos diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 8d06e2f73..ae11fe521 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -7,6 +7,10 @@ = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) +- content_for :breadcrumbs do + %li.breadcrumb-item= link_to 'Photos', photos_path + %li.breadcrumb-item.active= link_to @photo, @photo + .row .col-md-8 %h1.text-center=@photo.title diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index 002855cb7..4de268684 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -31,7 +31,6 @@ -# .col-md-12 -# %p= render 'seeds/actions', seed: seed - .card.seed-card = link_to seed do = image_tag(seed_image_path(seed, full_size: true), alt: seed, class: 'img-card') diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index ccd544c6c..38f7f44e5 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -1,4 +1,4 @@ -- content_for :title, title('seeds', @owner, @crop, @planting) +%h1= title('seeds', @owner, @crop, @planting) - if @owner = link_to "View #{@owner}'s profile >>", member_path(@owner) @@ -9,6 +9,13 @@ = render 'layouts/nav', model: Seed +- content_for :breadcrumbs do + - if @owner + %li.breadcrumb-item= link_to 'Seeds', seeds_path + %li.breadcrumb-item.active= link_to "#{@owner}'s seeds", seeds_path(owner: @owner) + - else + %li.breadcrumb-item.active= link_to 'Seeds', seeds_path + .pagination = page_entries_info @seeds = will_paginate @seeds diff --git a/app/views/seeds/show.html.haml b/app/views/seeds/show.html.haml index f47a59c69..135b0bba1 100644 --- a/app/views/seeds/show.html.haml +++ b/app/views/seeds/show.html.haml @@ -11,6 +11,10 @@ - content_for :buttonbar do = render 'seeds/actions', seed: @seed + +- content_for :breadcrumbs do + %li.breadcrumb-item= link_to 'Seeds', seeds_path + %li.breadcrumb-item.active= link_to @seed, @seed .row .col-md-6 From f94199676c099eaee37ee407b5d2c41d70b0a8ba Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 3 Jun 2019 22:23:49 +1200 Subject: [PATCH 174/549] fullsize garden images --- app/helpers/photos_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb index a21db9589..e78bc12da 100644 --- a/app/helpers/photos_helper.rb +++ b/app/helpers/photos_helper.rb @@ -8,9 +8,10 @@ module PhotosHelper end end - def garden_image_path(garden) + def garden_image_path(garden, full_size: false) if garden.default_photo.present? - garden.default_photo.thumbnail_url + photo = garden.default_photo + full_size ? photo.fullsize_url : photo.thumbnail_url else placeholder_image end From 09499499b78bdbcd974e0066ae4dd52c601f7460 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 3 Jun 2019 22:24:22 +1200 Subject: [PATCH 175/549] bugfix - label on signup link --- app/views/layouts/_nav.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_nav.haml b/app/views/layouts/_nav.haml index 86b4d1e4b..df6caba1c 100644 --- a/app/views/layouts/_nav.haml +++ b/app/views/layouts/_nav.haml @@ -11,4 +11,4 @@ Add a #{model.model_name.human} - unless current_member - = render 'shared/signin_signup', to: 'add a new seed' + = render 'shared/signin_signup', to: "add a new #{model.to_s.downcase}" From 14aa9a66dfeed2aea949fabfba7b6d7eb2639c63 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 3 Jun 2019 22:24:55 +1200 Subject: [PATCH 176/549] Move crop photos into row --- app/views/home/_crops.html.haml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/home/_crops.html.haml b/app/views/home/_crops.html.haml index bfcfa85b2..974abdb63 100644 --- a/app/views/home/_crops.html.haml +++ b/app/views/home/_crops.html.haml @@ -1,4 +1,6 @@ - cache cache_key_for(Crop, 'homepage'), expires_in: 1.day do - - Crop.interesting.includes(:scientific_names, :photos).shuffle.first(12).each do |crop| - .col-6.col-md-3= render 'crops/thumbnail', crop: crop + .row + - Crop.interesting.includes(:scientific_names, :photos).shuffle.first(12).each do |crop| + .col-6.col-md-3 + = render 'crops/thumbnail', crop: crop From 89f51c8a81a65806ef8ed7b0c21e1949aa5fd4d3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 3 Jun 2019 22:25:08 +1200 Subject: [PATCH 177/549] make the seed card wider --- app/assets/stylesheets/seeds.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/seeds.scss b/app/assets/stylesheets/seeds.scss index f9c02e8ef..f5a75bc6f 100644 --- a/app/assets/stylesheets/seeds.scss +++ b/app/assets/stylesheets/seeds.scss @@ -4,7 +4,7 @@ flex-wrap: wrap; .card { - max-width: 200px; + max-width: 250px; margin: 1em; } } From f944ce11d0e3de69198726b97117d89b9d6d9217 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 3 Jun 2019 22:31:11 +1200 Subject: [PATCH 178/549] margin on sect --- app/assets/stylesheets/homepage.scss | 6 +++++- app/assets/stylesheets/overrides.scss | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/homepage.scss b/app/assets/stylesheets/homepage.scss index 72672142f..67924d4ae 100644 --- a/app/assets/stylesheets/homepage.scss +++ b/app/assets/stylesheets/homepage.scss @@ -24,7 +24,7 @@ flex: none; flex-wrap: wrap; margin: 0.5em; - left: -0.5em; + // left: -0.5em; .card { min-height: 100px; @@ -44,6 +44,10 @@ .thumbnail { margin: 0.5em; } + .img-card { + height: 150px; + } + } @include media-breakpoint-down(sm) { diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index d3a79291f..0bfa4a978 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -72,7 +72,7 @@ h3 { .img-card { object-fit: cover; - height: 150px; + height: 200px; width: 100%; } @@ -141,6 +141,9 @@ h3 { p.stats { font-weight: bold; } +.card { + max-width: 400px; +} .card-row { display: grid; From cf69c135274621f2d4fdbdd14eff9fa9bb549f25 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 3 Jun 2019 22:47:19 +1200 Subject: [PATCH 179/549] fix up erros on planting form --- app/controllers/plantings_controller.rb | 4 +++- app/views/plantings/_form.html.haml | 14 +++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 22cf9fe68..cef095726 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -46,7 +46,9 @@ class PlantingsController < ApplicationController # using find_by_id here because it returns nil, unlike find @crop = Crop.approved.find_by(id: params[:crop_id]) || Crop.new - @garden = Garden.find_by(owner: current_member, id: params[:garden_id]) + @planting.garden = Garden.find_by( + owner: current_member, + id: params[:garden_id]) if params[:garden_id] respond_with @planting end diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml index 21448b179..0be7dd0dd 100644 --- a/app/views/plantings/_form.html.haml +++ b/app/views/plantings/_form.html.haml @@ -27,15 +27,11 @@ .row .col-md-8 - - if @garden.present? - %p Planted in #{link_to @garden, @garden} - = f.hidden_field :garden_id, value: @garden.id - - else - = f.collection_radio_buttons(:garden_id, - @planting.owner.gardens.active.order_by_name, - :id, :name, required: true, - label: 'Where did you plant it?') - = link_to "Add a garden.", new_garden_path + = f.collection_radio_buttons(:garden_id, + @planting.owner.gardens.active.order_by_name, + :id, :name, required: true, + label: 'Where did you plant it?') + = link_to "Add a garden.", new_garden_path .col-md-4 = f.text_field :planted_at, value: @planting.planted_at ? @planting.planted_at.to_s(:ymd) : '', From 2dd4e95e7c541d71fad5020db82b6a420959dad1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 3 Jun 2019 22:47:43 +1200 Subject: [PATCH 180/549] don't set max card --- app/assets/stylesheets/overrides.scss | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index 0bfa4a978..0743fd43a 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -141,9 +141,6 @@ h3 { p.stats { font-weight: bold; } -.card { - max-width: 400px; -} .card-row { display: grid; From 6c41b52cb16782e6d15433df099012bbe90c8c26 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 3 Jun 2019 23:01:57 +1200 Subject: [PATCH 181/549] Fix - planting.active scope to not show finished --- app/models/planting.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/planting.rb b/app/models/planting.rb index 5924ea2ef..b8422b310 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -33,7 +33,7 @@ class Planting < ApplicationRecord ## ## Scopes default_scope { joins(:owner) } # Ensures the owner still exists - scope :active, -> { where(finished_at: nil) } + scope :active, -> { where('finished_at IS NULL OR finished_at < ?', Time.zone.now).where(finished: false) } scope :interesting, -> { has_photos.one_per_owner.order(planted_at: :desc) } scope :recent, -> { order(created_at: :desc) } scope :one_per_owner, lambda { From c7d5915b4429206973641f6a542c9bfbf52b3ced Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 3 Jun 2019 23:16:28 +1200 Subject: [PATCH 182/549] Make seeds form nicer on mobile --- app/views/seeds/_form.html.haml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/views/seeds/_form.html.haml b/app/views/seeds/_form.html.haml index 7a97fda55..96173af5f 100644 --- a/app/views/seeds/_form.html.haml +++ b/app/views/seeds/_form.html.haml @@ -19,31 +19,31 @@ = f.hidden_field :parent_planting_id, value: @planting.id - else = auto_suggest @seed, :crop, class: 'form-control', default: @crop - %span.help-inline + %legend Can't find what you're looking for? = link_to "Request new crops.", new_crop_path .row - .col-4= f.number_field :quantity, label: 'Quantity' - .col-8 + .col-md-4.col-12= f.number_field :quantity, label: 'Quantity' + .col-md-8.col-12 = f.text_field :plant_before, class: 'add-datepicker', value: @seed.plant_before ? @seed.plant_before.to_s(:ymd) : '' .row - .col-4 + .col-md-4.col-12 = f.check_box :finished, label: 'Mark as finished' - = t('.finish_helper') - .col-8 + %small= t('.finish_helper') + .col-md-8.col-12 = f.text_field :finished_at, class: 'add-datepicker', value: @seed.finished_at ? @seed.finished_at.to_s(:ymd) : '' .row - .col-4= f.number_field :days_until_maturity_min, append: " days" - .col-4= f.number_field :days_until_maturity_max, append: " days" + .col-md-4.col-12= f.number_field :days_until_maturity_min, append: " days" + .col-md-4.col-12= f.number_field :days_until_maturity_max, append: " days" .row - .col-4= f.select(:organic, Seed::ORGANIC_VALUES, {}, default: 'unknown') - .col-4= f.select(:gmo, Seed::GMO_VALUES, {}, class: 'form-control', default: 'unknown') - .col-4= f.select(:heirloom, Seed::HEIRLOOM_VALUES, {}, class: 'form-control', default: 'unknown') + .col-md-4.col-12= f.select(:organic, Seed::ORGANIC_VALUES, {}, default: 'unknown') + .col-md-4.col-12= f.select(:gmo, Seed::GMO_VALUES, {}, class: 'form-control', default: 'unknown') + .col-md-4.col-12= f.select(:heirloom, Seed::HEIRLOOM_VALUES, {}, class: 'form-control', default: 'unknown') = f.text_area :description, rows: 6, class: 'form-control' %hr/ From ab4119c68d8e534d6f69132671d6d206baa05a02 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 3 Jun 2019 23:19:15 +1200 Subject: [PATCH 183/549] make gardens for nicer on mobile --- app/views/gardens/_form.html.haml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/views/gardens/_form.html.haml b/app/views/gardens/_form.html.haml index 1f40366d8..c3808a48c 100644 --- a/app/views/gardens/_form.html.haml +++ b/app/views/gardens/_form.html.haml @@ -21,7 +21,6 @@ = f.text_field :location, value: @garden.location || current_member.location, class: 'form-control', maxlength: 255 - = render partial: 'shared/form_optional' %span.help-block = t('.location_helper') - if current_member.location.blank? @@ -29,13 +28,15 @@ - else = link_to "Change your location.", edit_member_registration_path .row - .col-3= f.number_field :area, class: 'input-small' - .col-3= f.select(:area_unit, Garden::AREA_UNITS_VALUES, { include_blank: false }) - .col-6= f.select(:garden_type_id, GardenType.all.order(:name).pluck(:name, :id), + .col-md-3.col-12= f.number_field :area, class: 'input-small' + .col-md-3.col-12= f.select(:area_unit, Garden::AREA_UNITS_VALUES, { include_blank: false }) + .col-md-6.col-12= f.select(:garden_type_id, GardenType.all.order(:name).pluck(:name, :id), selected: @garden.garden_type_id) - - = f.check_box :active, label: 'Active?' - You can mark a garden as inactive if you no longer use it. Note: - this will mark all plantings in the garden as "finished". + .row + .col-12 + = f.check_box :active, label: 'Active?' + %p + You can mark a garden as inactive if you no longer use it. + Note: this will mark all plantings in the garden as "finished". .card-footer .text-right= f.submit 'Save Garden' From 357b70f0682948be10a63d49174ff1e8eb774690 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 4 Jun 2019 15:44:45 +1200 Subject: [PATCH 184/549] harvest form tidy for small screens --- app/views/harvests/_form.html.haml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/app/views/harvests/_form.html.haml b/app/views/harvests/_form.html.haml index 53d1b9702..36afa5629 100644 --- a/app/views/harvests/_form.html.haml +++ b/app/views/harvests/_form.html.haml @@ -16,7 +16,7 @@ %li= msg .row - .col-8 + .col-md-8 = f.label :crop, 'What did you harvest?' - if @planting = link_to @planting.crop.name, planting_path(@planting) @@ -30,24 +30,27 @@ Can't find what you're looking for? = link_to "Request new crops.", new_crop_path - .col-4 - = f.select :plant_part_id, PlantPart.all.collect {|p| [ p.name, p.id ] },include_blank: '', prompt: 'e.g. fruit', required: true, selected: @harvest.plant_part_id, required: true - - = f.text_field :harvested_at, value: @harvest.harvested_at ? @harvest.harvested_at.to_s(:ymd) : '', + .col-md-4 + = f.text_field :harvested_at, value: @harvest.harvested_at ? @harvest.harvested_at.to_s(:ymd) : '', class: 'add-datepicker', label: 'When?' + .col-12 + = f.form_group :plant_part_id, label: { text: "Harvested Plant Part" } do + .row + - PlantPart.all.order(:name).pluck(:id, :name).each do |id, name| + .col-4.col-md-3= f.radio_button :plant_part_id, id, label: name, checked: true -# Some browsers (eg Firefox for Android) assume "number" means -# "integer" unless you specify step="any": -# http://blog.isotoma.com/2012/03/html5-input-typenumber-and-decimalsfloats-in-chrome/ .row - .col-4 + .col-md-4 = f.number_field :quantity, class: 'input-small form-control', step: 'any', label: 'How many?' - .col-8 + .col-md-8 = f.select(:unit, Harvest::UNITS_VALUES, { include_blank: false }, class: 'input-medium form-control') .row - .col-4 + .col-md-4 = f.number_field :weight_quantity, class: 'input-small form-control', step: 'any' - .col-8 + .col-md-8 = f.select(:weight_unit, Harvest::WEIGHT_UNITS_VALUES, { include_blank: false }, class: 'form-control') = f.text_area :description, rows: 6, label: 'Notes' From b3bcce95831e3dfc05455edd3f51f5925e2a8780 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 4 Jun 2019 15:44:55 +1200 Subject: [PATCH 185/549] plantings form tidy for small screens --- app/views/plantings/_form.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml index 0be7dd0dd..3edf4a61c 100644 --- a/app/views/plantings/_form.html.haml +++ b/app/views/plantings/_form.html.haml @@ -29,7 +29,8 @@ .col-md-8 = f.collection_radio_buttons(:garden_id, @planting.owner.gardens.active.order_by_name, - :id, :name, required: true, + :id, :name, + required: true, label: 'Where did you plant it?') = link_to "Add a garden.", new_garden_path .col-md-4 From abfe1ace20ff3737487ccf01a3f469bfdeb4d358 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 4 Jun 2019 15:45:13 +1200 Subject: [PATCH 186/549] harvest -> planting assignment form tidy for small screens --- app/views/harvests/_planting.haml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/harvests/_planting.haml b/app/views/harvests/_planting.haml index 6e6ba03c2..ae2d94b9c 100644 --- a/app/views/harvests/_planting.haml +++ b/app/views/harvests/_planting.haml @@ -4,12 +4,12 @@ in = link_to @harvest.planting.garden, garden_path(@harvest.planting.garden) - elsif @matching_plantings && @matching_plantings.any? && @harvest.owner == current_member - Is this from one of these plantings? - = form_for(@harvest) do |f| - - @matching_plantings.each do |planting| - .field - = f.radio_button :planting_id, planting.id - = label_tag(:planting, planting) - = f.submit "save", class: 'btn btn-default btn-xs' + + .alert.alert-info{role: "alert"} + = bootstrap_form_for(@harvest) do |f| + Is this from one of these plantings? + - @matching_plantings.each do |planting| + = f.radio_button :planting_id, planting.id, label: planting + = f.submit "save", class: 'btn btn-sm' - else Unknown From 0235f233ab366484ca978e27460423733366e7d6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 4 Jun 2019 15:45:23 +1200 Subject: [PATCH 187/549] plantigns tidy for small screens --- app/views/plantings/show.html.haml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/plantings/show.html.haml b/app/views/plantings/show.html.haml index d191ac693..54a355875 100644 --- a/app/views/plantings/show.html.haml +++ b/app/views/plantings/show.html.haml @@ -13,11 +13,11 @@ .planting .row .col-md-8.col-xs-12 - %h2.h1 + %h2.h3 %strong= @planting = render 'plantings/actions', planting: @planting - = render 'facts', planting: @planting + %section= render 'facts', planting: @planting - if @planting.description.present? %hr/ .card @@ -27,7 +27,7 @@ :growstuff_markdown #{strip_tags(@planting.description)} %hr/ - = render 'plantings/photos', photos: @photos, planting: @planting + %section= render 'plantings/photos', photos: @photos, planting: @planting .col-md-4.col-xs-12.text-right .card .card-body= render 'plantings/owner', planting: @planting From 16f9f4c66e1a0ef221324e975ccaa02611be738d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 4 Jun 2019 20:02:02 +1200 Subject: [PATCH 188/549] plantings actions as dropdown menu --- app/helpers/buttons_helper.rb | 30 +++++++++++++------------- app/views/plantings/_actions.html.haml | 16 +++++++------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 06257c4d0..0e1ecc47e 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -61,15 +61,15 @@ module ButtonsHelper edit_button(edit_garden_path(garden)) end - def planting_edit_button(planting) - edit_button(edit_planting_path(planting)) + def planting_edit_button(planting, classes: "btn btn-raised btn-info") + edit_button(edit_planting_path(planting), classes: classes) end - def planting_finish_button(planting) + def planting_finish_button(planting, classes: 'btn btn-default btn-secondary') return unless can?(:edit, planting) || planting.finished link_to planting_path(planting, planting: { finished: 1 }), - method: :put, class: 'btn btn-default btn-secondary append-date' do + method: :put, class: "#{classes} append-date" do finished_icon + ' ' + t('buttons.mark_as_finished') end end @@ -82,41 +82,41 @@ module ButtonsHelper end end - def planting_harvest_button(planting) + def planting_harvest_button(planting, classes: 'btn btn-default') return unless planting.active? && can?(:create, Harvest) && can?(:edit, planting) - link_to new_planting_harvest_path(planting), class: "btn btn-default" do - harvest_icon + ' ' + t('buttons.harvest') + link_to new_planting_harvest_path(planting), class: classes do + harvest_icon + ' ' + t('buttons.record_harvest') end end - def planting_save_seeds_button(planting) + def planting_save_seeds_button(planting, classes: 'btn btn-default') return unless can?(:edit, planting) - link_to new_planting_seed_path(planting), class: "btn btn-default" do + link_to new_planting_seed_path(planting), class: classes do seed_icon + ' ' + t('buttons.save_seeds') end end - def add_photo_button(model) + def add_photo_button(model, classes: "btn btn-default") return unless can?(:edit, model) && can?(:create, Photo) link_to new_photo_path(id: model.id, type: model_type_for_photo(model)), - class: "btn btn-default" do + class: classes do photo_icon + ' ' + t('buttons.add_photo') end end - def edit_button(path) - link_to path, class: "btn btn-raised btn-info" do + def edit_button(path, classes: "btn btn-raised btn-info") + link_to path, class: classes do edit_icon + ' ' + t('buttons.edit') end end - def delete_button(model, message: 'are_you_sure') + def delete_button(model, message: 'are_you_sure', classes: 'btn btn-danger') return unless can? :destroy, model - link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-danger' do + link_to model, method: :delete, data: { confirm: t(message) }, class: classes do delete_icon + ' ' + t('buttons.delete') end end diff --git a/app/views/plantings/_actions.html.haml b/app/views/plantings/_actions.html.haml index 87486c194..da4bc133e 100644 --- a/app/views/plantings/_actions.html.haml +++ b/app/views/plantings/_actions.html.haml @@ -1,12 +1,12 @@ - if can?(:edit, planting) .dropdown.float-right.planting-actions - %a#planting-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} + %a#planting-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "planting-actions-button"} - .dropdown-item= planting_edit_button(planting) - .dropdown-item= add_photo_button(planting) + = planting_edit_button(planting, classes: 'dropdown-item') + = add_photo_button(planting, classes: 'dropdown-item') - if planting.active? - .dropdown-item= planting_finish_button(planting) - .dropdown-item= planting_harvest_button(planting) - .dropdown-item= planting_save_seeds_button(planting) - - if can? :destroy, planting - .dropdown-item= delete_button(planting) + = planting_finish_button(planting, classes: 'dropdown-item') + = planting_harvest_button(planting, classes: 'dropdown-item') + = planting_save_seeds_button(planting, classes: 'dropdown-item') + .dropdown-divider + = delete_button(planting, classes: 'dropdown-item') From 75b04ffe04faf057ee291b670697c5cfbad85b24 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 4 Jun 2019 20:02:28 +1200 Subject: [PATCH 189/549] attempting to make posts appear nice on mobile --- app/views/posts/show.html.haml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index dc20c7193..8c5858ce2 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -53,16 +53,14 @@ = render "comments", post: @post - .col-4.col-xs-12 - = render @post.author - - - unless @post.crops.empty? - %hr/ - .row - .col-md-12 - %h3 Crops mentioned in this post + .col-md-4.col-12 + .row + .col-12= render @post.author + - unless @post.crops.empty? + .col-12 + %h3.h3 Crops mentioned in this post - @post.crops.each do |c| - .col-md-6= render 'crops/thumbnail', crop: c + .col-6= render 'crops/thumbnail', crop: c From 70afa97b801eeaf66d50bd8b0e211ee49fe8588e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 5 Jun 2019 08:35:39 +1200 Subject: [PATCH 190/549] only shrink the member card on the homepage --- app/assets/stylesheets/homepage.scss | 20 +++++++++++--------- app/views/posts/show.html.haml | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/assets/stylesheets/homepage.scss b/app/assets/stylesheets/homepage.scss index 67924d4ae..a697ce6ca 100644 --- a/app/assets/stylesheets/homepage.scss +++ b/app/assets/stylesheets/homepage.scss @@ -51,15 +51,17 @@ } @include media-breakpoint-down(sm) { - .seed-card { - width: 100%; - min-height: 80px; - align: center; - } - .member-card { - width: 150px; - min-height: 80px; - align: center; + .homepage-cards { + .seed-card { + width: 100%; + min-height: 80px; + align: center; + } + .member-card { + width: 150px; + min-height: 80px; + align: center; + } } } diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index 8c5858ce2..aa7546935 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -54,8 +54,8 @@ = render "comments", post: @post .col-md-4.col-12 + = render @post.author .row - .col-12= render @post.author - unless @post.crops.empty? .col-12 %h3.h3 Crops mentioned in this post From 75cc2040b14bf8271c474431cd37051dd0fef7aa Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 5 Jun 2019 17:21:20 +1200 Subject: [PATCH 191/549] Expand maincontainer on small screens --- app/assets/stylesheets/overrides.scss | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index 0743fd43a..25b4b97c5 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -470,6 +470,9 @@ ul.thumbnail-buttons { // Overrides applying only to mobile view. This must be at the end of the overrides file. // Extra small devices (portrait phones, less than 576px) @include media-breakpoint-down(xs) { + #maincontainer { + width: 100%; + } .sidebar { margin-left: 0; border-left: none; From 9b0eb212b16186107d92f155892d760a8de5854d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 5 Jun 2019 17:21:30 +1200 Subject: [PATCH 192/549] Button back needs to wrap --- app/views/crops/_actions.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/crops/_actions.html.haml b/app/views/crops/_actions.html.haml index 2d5ed101f..dc155e7aa 100644 --- a/app/views/crops/_actions.html.haml +++ b/app/views/crops/_actions.html.haml @@ -1,6 +1,6 @@ - if @crop.approved? && signed_in? .crop-actions - .btn-group + .btn-toolbar{"data-toggle" => "buttons"} - if can? :create, Planting = link_to new_planting_path(crop_id: crop.id), class: 'btn btn-sm' do = planting_icon From 6af4bb9ecfc5e66536f8344534163040bc4cb535 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 5 Jun 2019 17:21:44 +1200 Subject: [PATCH 193/549] Fix tiny crop photos on small screens --- app/views/crops/_photos.html.haml | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index 6713d8f75..56073919d 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -1,15 +1,16 @@ -- if @crop.photos.size.positive? - %h2 - = photo_icon - Photos - - [Planting, Harvest, Seed].each do |model_name| - - if photos.by_model(model_name).size.positive? - .crop-photos - %h3.font-italic - #{@crop.name.capitalize} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} - .row - - photos.by_model(model_name).limit(6).each do |photo| - .col-2.col-xs-6= render 'photos/thumbnail', photo: photo +%section.photos + - if @crop.photos.size.positive? + %h2 + = photo_icon + Photos + - [Planting, Harvest, Seed].each do |model_name| + - if photos.by_model(model_name).size.positive? + .crop-photos + %h3 + #{@crop.name.capitalize} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} + .row + - photos.by_model(model_name).limit(6).each do |photo| + .col-6.col-md-2= render 'photos/thumbnail', photo: photo - %p.text-right= link_to 'more photos »', crop_photos_path(@crop), class: 'btn btn-info' - %hr/ + = link_to 'more photos »', crop_photos_path(@crop), class: 'btn' + %hr/ From eb1cb31f6a0ed1ec4b4d8f2c4806bf612b77d24b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 5 Jun 2019 17:22:09 +1200 Subject: [PATCH 194/549] fix alignment of header on members#show --- app/views/members/_stats.html.haml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/views/members/_stats.html.haml b/app/views/members/_stats.html.haml index b6eebc287..a3f4ab1e4 100644 --- a/app/views/members/_stats.html.haml +++ b/app/views/members/_stats.html.haml @@ -1,7 +1,5 @@ - - - -%h3 Activity +.card-body + %h3 Activity %ul.list-group.list-group-flush %li.list-group-item - if !member.plantings.empty? From 5a5e0c8f825fe971dc976b6d6227894728b46445 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 5 Jun 2019 22:18:46 +1200 Subject: [PATCH 195/549] Tidy up crops#index on small screens --- app/assets/stylesheets/crops.scss | 20 ++++++++++++++++++++ app/views/crops/index.html.haml | 7 ++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/crops.scss b/app/assets/stylesheets/crops.scss index 646f1e4d7..433ad0801 100644 --- a/app/assets/stylesheets/crops.scss +++ b/app/assets/stylesheets/crops.scss @@ -14,3 +14,23 @@ .crop-photos { margin-left: 3em; } + +.crops { + display: flex; + flex: none; + flex-wrap: wrap; + margin: 0.5em; + .card { + min-height: 100px; + margin: 0.5em; + padding: 0; + + %h3.crop-name { + font-size: 2em; + } + } + .crop-card { + width: 120px; + min-height: 80px; + } +} \ No newline at end of file diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml index f405e4645..e69b263e7 100644 --- a/app/views/crops/index.html.haml +++ b/app/views/crops/index.html.haml @@ -29,9 +29,10 @@ .pagination= render 'layouts/pagination', collection: @crops -.row - - @crops.each do |crop| - .col-md-2= render 'crops/thumbnail', crop: crop +.crops + .row + - @crops.each do |crop| + .col-6.col-md-3= render 'crops/thumbnail', crop: crop .pagination= render 'layouts/pagination', collection: @crops From 385ecac46f2854b1856fb9d13df28f31def9c136 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 5 Jun 2019 22:27:05 +1200 Subject: [PATCH 196/549] Revert "Tidy up crops#index on small screens" This reverts commit 5a5e0c8f825fe971dc976b6d6227894728b46445. --- app/assets/stylesheets/crops.scss | 20 -------------------- app/views/crops/index.html.haml | 7 +++---- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/app/assets/stylesheets/crops.scss b/app/assets/stylesheets/crops.scss index 433ad0801..646f1e4d7 100644 --- a/app/assets/stylesheets/crops.scss +++ b/app/assets/stylesheets/crops.scss @@ -14,23 +14,3 @@ .crop-photos { margin-left: 3em; } - -.crops { - display: flex; - flex: none; - flex-wrap: wrap; - margin: 0.5em; - .card { - min-height: 100px; - margin: 0.5em; - padding: 0; - - %h3.crop-name { - font-size: 2em; - } - } - .crop-card { - width: 120px; - min-height: 80px; - } -} \ No newline at end of file diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml index e69b263e7..f405e4645 100644 --- a/app/views/crops/index.html.haml +++ b/app/views/crops/index.html.haml @@ -29,10 +29,9 @@ .pagination= render 'layouts/pagination', collection: @crops -.crops - .row - - @crops.each do |crop| - .col-6.col-md-3= render 'crops/thumbnail', crop: crop +.row + - @crops.each do |crop| + .col-md-2= render 'crops/thumbnail', crop: crop .pagination= render 'layouts/pagination', collection: @crops From 04d941111b2768d0be1fcf7aa60708f857a70a5e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 5 Jun 2019 22:29:18 +1200 Subject: [PATCH 197/549] tidy up harvests#index on a small screen --- app/views/harvests/index.html.haml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index 7eafe377d..7cfa42fb9 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -22,7 +22,9 @@ - unless @harvests.empty? .harvest-cards - = render @harvests, full: true + .row + - @harvests.each do |harvest| + .col-6.col-md-3= render harvest, full: true .pagination = page_entries_info @harvests From d346ae8e4b352fdaee3bf3751afe86babc9f607a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 5 Jun 2019 22:29:29 +1200 Subject: [PATCH 198/549] tidy up crops#index on a small screen --- app/views/crops/index.html.haml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml index f405e4645..b29ab72c0 100644 --- a/app/views/crops/index.html.haml +++ b/app/views/crops/index.html.haml @@ -29,9 +29,11 @@ .pagination= render 'layouts/pagination', collection: @crops -.row - - @crops.each do |crop| - .col-md-2= render 'crops/thumbnail', crop: crop +.crops + .row + - @crops.each do |crop| + .col-6.col-md-3= render 'crops/thumbnail', crop: crop + .pagination= render 'layouts/pagination', collection: @crops From a7e83202fb0c0e584a6183985d28fd6c1078cbbd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 5 Jun 2019 22:31:39 +1200 Subject: [PATCH 199/549] a margin below every card --- app/assets/stylesheets/overrides.scss | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index 25b4b97c5..e9c7aaf6e 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -148,6 +148,9 @@ p.stats { grid-gap: 25px; grid-row-gap: 5px; } +.card { + margin-bottom: 1em +} .progress { border-radius: 0; From 9cc97e10cd438ad95d93c781c63c8be66b9aae5f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 5 Jun 2019 22:37:13 +1200 Subject: [PATCH 200/549] tidy up crops sort form --- app/views/crops/index.html.haml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml index b29ab72c0..f26a7801b 100644 --- a/app/views/crops/index.html.haml +++ b/app/views/crops/index.html.haml @@ -16,16 +16,13 @@ information on how to grow it yourself. -.well - = form_tag(crops_path, method: :get, class: 'form-inline', role: 'form') do - .form-group - = label_tag :sort, "Sort by:", class: 'sr-only' - = select_tag "sort", - options_for_select({ "Sort by popularity": 'popular', - "Sort alphabetically": 'alpha' }, - @sort || 'popular'), - class: 'form-control' - = submit_tag "Show", class: 'btn btn-success' += bootstrap_form_tag(url: crops_path, method: :get, layout: :inline) do |f| + = f.select "sort", + options_for_select({ "popularity": 'popular', + "alphabetically": 'alpha' }, + @sort || 'popular'), + label: 'Sort by' + = f.submit "Show" .pagination= render 'layouts/pagination', collection: @crops From fad43f18c8ae187a85dabfe83c9e808cb72c6f69 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 5 Jun 2019 22:46:41 +1200 Subject: [PATCH 201/549] missing titles, icons, and breadcrumps --- app/views/gardens/index.html.haml | 3 +++ app/views/harvests/index.html.haml | 4 +++- app/views/harvests/show.html.haml | 8 ++++++-- app/views/members/index.html.haml | 15 ++++++++------- app/views/plantings/show.html.haml | 3 ++- app/views/posts/index.html.haml | 10 +++------- app/views/posts/show.html.haml | 10 +++------- 7 files changed, 28 insertions(+), 25 deletions(-) diff --git a/app/views/gardens/index.html.haml b/app/views/gardens/index.html.haml index 17248030b..a85d577f2 100644 --- a/app/views/gardens/index.html.haml +++ b/app/views/gardens/index.html.haml @@ -1,5 +1,8 @@ - content_for :title, @owner ? "#{@owner}'s gardens" : "Everyone's gardens" + +%h1 + = @owner ? "#{@owner}'s gardens" : "Everyone's gardens" = render 'layouts/nav', model: Garden = link_to gardens_active_tickbox_path(@owner, @show_all) do diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index 7cfa42fb9..e00ffb151 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -1,4 +1,6 @@ -%h1=title('harvests', @owner, @crop, @planting) +%h1 + = harvest_icon + = title('harvests', @owner, @crop, @planting) - if @owner = link_to "View #{@owner}'s profile >>", member_path(@owner) diff --git a/app/views/harvests/show.html.haml b/app/views/harvests/show.html.haml index 28e60243f..002e256eb 100644 --- a/app/views/harvests/show.html.haml +++ b/app/views/harvests/show.html.haml @@ -11,8 +11,12 @@ -content_for(:buttonbar) do = render 'harvests/actions', harvest: @harvest + .row - .col-md-6 + .col-md-8 + %h1 + = harvest_icon + #{@harvest.crop} harvested by #{@harvest.owner} %p %b Owner: = link_to @harvest.owner, @harvest.owner @@ -36,7 +40,7 @@ = display_quantity(@harvest) - .col-md-6= render @harvest.crop + .col-md-4= render @harvest.crop - if @harvest.description.present? %h2 Notes diff --git a/app/views/members/index.html.haml b/app/views/members/index.html.haml index fcf0611ce..ad9af58af 100644 --- a/app/views/members/index.html.haml +++ b/app/views/members/index.html.haml @@ -1,13 +1,14 @@ = content_for :title, t(".title", site_name: ENV['GROWSTUFF_SITE_NAME']) -= form_tag(members_path, method: :get, class: 'form-inline', role: 'form') do - .form-group - = label_tag :sort, "Sort by:", class: 'sr-only' - = select_tag "sort", - options_for_select({ "Sort alphabetically": 'alpha', "Sort by recently joined": "recently_joined" }, +%h1 + = member_icon + = t(".title", site_name: ENV['GROWSTUFF_SITE_NAME']) += bootstrap_form_tag(url: members_path, method: :get, layout: :inline) do |f| + = f.select "sort", + options_for_select({ "alphabetically": 'alpha', "recently joined": "recently_joined" }, @sort || 'alpha'), - class: 'form-control' - = submit_tag "Show", class: 'btn btn-primary' + label: 'Sort by' + = f.submit "Show" .pagination = page_entries_info @members diff --git a/app/views/plantings/show.html.haml b/app/views/plantings/show.html.haml index 54a355875..2554a9421 100644 --- a/app/views/plantings/show.html.haml +++ b/app/views/plantings/show.html.haml @@ -13,7 +13,8 @@ .planting .row .col-md-8.col-xs-12 - %h2.h3 + %h1 + = planting_icon %strong= @planting = render 'plantings/actions', planting: @planting diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index e12d99b9a..5d3cc777a 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -1,13 +1,9 @@ - content_for :title, @author ? t('.title.author_posts', author: @author) : t('.title.default') - content_for :breadcrumbs do - %nav{"aria-label" => "breadcrumb"} - %ol.breadcrumb - %li.breadcrumb-item - = link_to 'Home', root_path - - if @author.present? - %li.breadcrumb-item= link_to @author, @author - %li.breadcrumb-item.active= link_to 'posts', posts_path(author: @author.slug) + - if @author.present? + %li.breadcrumb-item= link_to @author, @author + %li.breadcrumb-item.active= link_to 'posts', posts_path(author: @author.slug) %h1= @author ? t('.title.author_posts', author: @author) : t('.title.default') .pagination= render 'layouts/pagination', collection: @posts diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index aa7546935..604107128 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -26,13 +26,9 @@ = link_to 'Comment', new_comment_path(post_id: @post.id), class: 'btn' - content_for :breadcrumbs do - %nav{"aria-label" => "breadcrumb"} - %ol.breadcrumb - %li.breadcrumb-item - = link_to 'Home', root_path - %li.breadcrumb-item= link_to @post.author, @post.author - %li.breadcrumb-item= link_to 'posts', posts_path(member_slug: @post.author.slug) - %li.breadcrumb-item.active{"aria-current" => "page"}= @post.subject + %li.breadcrumb-item= link_to @post.author, @post.author + %li.breadcrumb-item= link_to 'posts', posts_path(member_slug: @post.author.slug) + %li.breadcrumb-item.active{"aria-current" => "page"}= @post.subject .row .col-md-8.col-12 From 84ca2154f4c5190c4f4920772b44eb6f13e900cf Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 5 Jun 2019 22:58:12 +1200 Subject: [PATCH 202/549] fix up footer --- app/views/layouts/_footer.html.haml | 23 +++++++++++------------ app/views/layouts/application.html.haml | 9 ++++----- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/app/views/layouts/_footer.html.haml b/app/views/layouts/_footer.html.haml index e004bf69a..c2a34b496 100644 --- a/app/views/layouts/_footer.html.haml +++ b/app/views/layouts/_footer.html.haml @@ -1,12 +1,11 @@ -.navbar.navbar-default.navbar-bottom - .container - .row - .col-md-4#footer1 - != cms_snippet_content(:footer1) - .col-md-4#footer2 - != cms_snippet_content(:footer2) - .col-md-4#footer3 - != cms_snippet_content(:footer3) - %div{ style: "float: right;" } - %a{ href: "http://opendefinition.org/ossd/" } - %img{ src: "http://assets.okfn.org/images/ok_buttons/os_80x15_blue.png", alt: "" } +.container-fluid.text-center.text-md-left + .row + .col-md-4#footer1 + != cms_snippet_content(:footer1) + .col-md-4#footer2 + != cms_snippet_content(:footer2) + .col-md-4#footer3 + != cms_snippet_content(:footer3) + %div{ style: "float: right;" } + %a{ href: "http://opendefinition.org/ossd/" } + %img{ src: "http://assets.okfn.org/images/ok_buttons/os_80x15_blue.png", alt: "" } diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 802f7255d..e7b911db8 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,10 +1,10 @@ !!! 5 %html{ lang: "en", prefix: "og: http://ogp.me/ns#" } = yield :scripts - = render partial: "layouts/meta" + = render "layouts/meta" %body .sr-only= link_to t(".skip"), "#skipnav" - = render partial: "layouts/header" + = render "layouts/header" -# anchor tag for accessibility link to skip the navigation menu %a{ name: 'skipnav' } #maincontainer.container @@ -24,11 +24,10 @@ - if content_for?(:subtitle) %small= yield(:subtitle) - = render partial: "shared/flash_messages", flash: flash + = render "shared/flash_messages", flash: flash = yield - %footer - = render "layouts/footer" + %footer.page-footer.font-small.bg-dark.pt-4= render "layouts/footer" / Javascripts \================================================== From 0715646688740dfa3cb4d3653f7408acd649aaa6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 5 Jun 2019 23:12:12 +1200 Subject: [PATCH 203/549] Change crop autosuggest styles --- app/assets/javascripts/auto_suggest.js.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/auto_suggest.js.coffee b/app/assets/javascripts/auto_suggest.js.coffee index 9923a1e62..60e9304c0 100644 --- a/app/assets/javascripts/auto_suggest.js.coffee +++ b/app/assets/javascripts/auto_suggest.js.coffee @@ -31,7 +31,7 @@ jQuery -> if el.data( 'uiAutocomplete' ) el.data( 'uiAutocomplete' )._renderItem = ( ul, item ) -> - $( '
          • ' ) + $( '
          • ' ) .data( 'item.autocomplete', item ) .append( "#{item.name}" ) .appendTo( ul ) From 6daca910abec4eeb29c99d7c5465e6c46cdc0677 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 5 Jun 2019 23:24:34 +1200 Subject: [PATCH 204/549] Fixed buttons on crops#show --- app/views/crops/_actions.html.haml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/app/views/crops/_actions.html.haml b/app/views/crops/_actions.html.haml index dc155e7aa..60d337c77 100644 --- a/app/views/crops/_actions.html.haml +++ b/app/views/crops/_actions.html.haml @@ -1,17 +1,16 @@ - if @crop.approved? && signed_in? .crop-actions - .btn-toolbar{"data-toggle" => "buttons"} - - if can? :create, Planting - = link_to new_planting_path(crop_id: crop.id), class: 'btn btn-sm' do - = planting_icon - = t('buttons.plant_crop', crop_name: crop.name) + - if can? :create, Planting + = link_to new_planting_path(crop_id: crop.id), class: 'btn btn-sm' do + = planting_icon + = t('buttons.plant_crop', crop_name: crop.name) - - if can? :create, Harvest - = link_to new_harvest_path(crop_id: crop.id), class: 'btn btn-sm' do - = harvest_icon - = t('buttons.harvest_crop', crop_name: crop.name) + - if can? :create, Harvest + = link_to new_harvest_path(crop_id: crop.id), class: 'btn btn-sm' do + = harvest_icon + = t('buttons.harvest_crop', crop_name: crop.name) - - if can? :create, Seed - = link_to new_seed_path(crop_id: crop.id), class: 'btn btn-sm' do - = seed_icon - = t('buttons.add_seed_to_stash', crop_name: crop.name) + - if can? :create, Seed + = link_to new_seed_path(crop_id: crop.id), class: 'btn btn-sm' do + = seed_icon + = t('buttons.add_seed_to_stash', crop_name: crop.name) From 2786476faab50a778198d44d8d33470911619e88 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 6 Jun 2019 08:37:27 +0000 Subject: [PATCH 205/549] [CodeFactor] Apply fixes --- app/controllers/plantings_controller.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index cef095726..06545c0e1 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -45,10 +45,11 @@ class PlantingsController < ApplicationController @seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id] # using find_by_id here because it returns nil, unlike find - @crop = Crop.approved.find_by(id: params[:crop_id]) || Crop.new - @planting.garden = Garden.find_by( - owner: current_member, - id: params[:garden_id]) if params[:garden_id] + @crop = Crop.approved.find_by(id: params[:crop_id]) || Crop.new + @planting.garden = Garden.find_by( + owner: current_member, + id: params[:garden_id] + ) if params[:garden_id] respond_with @planting end From 78ea7d6a53db8225eaca7a4ffbd14fb9fa2210ce Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 6 Jun 2019 22:27:05 +1200 Subject: [PATCH 206/549] Crop wrangling is now under the admin menu - update spec --- spec/features/crops/crop_wranglers_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/features/crops/crop_wranglers_spec.rb b/spec/features/crops/crop_wranglers_spec.rb index c623d16b6..d2ebb103b 100644 --- a/spec/features/crops/crop_wranglers_spec.rb +++ b/spec/features/crops/crop_wranglers_spec.rb @@ -12,7 +12,7 @@ describe "crop wranglers", js: true do it "sees crop wranglers listed on the crop wrangler page" do visit root_path - click_link wrangler.login_name + click_link 'Admin' click_link 'Crop Wrangling' within '.crop_wranglers' do @@ -25,7 +25,7 @@ describe "crop wranglers", js: true do it "can see list of crops with extra detail of who created a crop" do visit root_path - click_link wrangler.login_name + click_link 'Admin' click_link 'Crop Wrangling' within '#recently-added-crops' do expect(page).to have_content crops.first.creator.login_name.to_s @@ -42,7 +42,7 @@ describe "crop wranglers", js: true do it "can create a new crop" do visit root_path - click_link wrangler.login_name + click_link 'Admin' click_link 'Crop Wrangling' click_link 'Add Crop' fill_in 'Name', with: "aubergine" From 4ab140a15e911ecca6f8d78594807d199a3ee7ab Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 6 Jun 2019 22:30:28 +1200 Subject: [PATCH 207/549] actions are now in the actoins menu. update spec --- spec/features/crops/crop_wranglers_spec.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/features/crops/crop_wranglers_spec.rb b/spec/features/crops/crop_wranglers_spec.rb index d2ebb103b..da83f2f0f 100644 --- a/spec/features/crops/crop_wranglers_spec.rb +++ b/spec/features/crops/crop_wranglers_spec.rb @@ -33,7 +33,10 @@ describe "crop wranglers", js: true do end describe "visiting a crop can see wrangler links" do - before { visit crop_path(crops.first) } + before do + visit crop_path(crops.first) + click_button 'Actions' + end it { expect(page).to have_content 'You are a CROP WRANGLER' } it { expect(page).to have_link 'Edit' } From c708608e9bf14aca31b33449c3fd2bc61cc208d5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 7 Jun 2019 13:09:29 +1200 Subject: [PATCH 208/549] Tidy up members#show photo display --- app/views/members/show.html.haml | 53 ++-- spec/features/percy/percy_new_spec.rb | 388 ++++++++++++++++++++++++++ 2 files changed, 412 insertions(+), 29 deletions(-) create mode 100644 spec/features/percy/percy_new_spec.rb diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index df696b343..ec83709ea 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -66,39 +66,34 @@ = link_to post, post - elsif event.event_type == 'photo' - photo = Photo.find(event.id) - %p - = photo_icon - took a photo - = link_to photo, photo.title - %p - .float-left= image_tag photo.fullsize_url, width: 75, class: 'rounded shadow' - %p - %ul.associations - - photo.plantings.each do |planting| - %li - = planting_icon - = link_to t('photos.show.planting', planting: planting.to_s, owner: planting.owner.to_s), planting_path(planting) + = photo_icon + took a photo + = link_to photo, photo.title + .media + = link_to(image_tag(photo.fullsize_url, width: 150, class: 'rounded'), photo) + .media-body + %p + %ul.associations + - photo.plantings.each do |planting| + %li + = planting_icon + = link_to t('photos.show.planting', planting: planting.to_s, owner: planting.owner.to_s), planting_path(planting) - - photo.harvests.each do |harvest| - %li - = harvest_icon - = link_to t('photos.show.harvest', crop: harvest.crop.name, owner: harvest.owner.to_s), harvest_path(harvest) + - photo.harvests.each do |harvest| + %li + = harvest_icon + = link_to t('photos.show.harvest', crop: harvest.crop.name, owner: harvest.owner.to_s), harvest_path(harvest) - - photo.gardens.each do |garden| - %li - = garden_icon - = link_to t('photos.show.garden', garden: garden.to_s, owner: garden.owner.to_s), garden_path(garden) + - photo.gardens.each do |garden| + %li + = garden_icon + = link_to t('photos.show.garden', garden: garden.to_s, owner: garden.owner.to_s), garden_path(garden) - - photo.seeds.each do |seed| - %li - = seed_icon - = link_to t('photos.show.seed', seed: seed.to_s, owner: seed.owner.to_s), seed_path(seed) + - photo.seeds.each do |seed| + %li + = seed_icon + = link_to t('photos.show.seed', seed: seed.to_s, owner: seed.owner.to_s), seed_path(seed) - else = link_to event.event_type, event %small #{time_ago_in_words(event.event_at)} ago - -# %p.mb-2 - -# Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius - -# blandit. - -# %small Donec id elit non mi porta. - diff --git a/spec/features/percy/percy_new_spec.rb b/spec/features/percy/percy_new_spec.rb new file mode 100644 index 000000000..6357546ab --- /dev/null +++ b/spec/features/percy/percy_new_spec.rb @@ -0,0 +1,388 @@ +require 'rails_helper' + +describe 'Test with visual testing', type: :feature, js: true do + # Use the same random seed every time so our random data is the same + # on every run, so doesn't trigger percy to see changes + before { Faker::Config.random = Random.new(42) } + let!(:member) { FactoryBot.create :member, login_name: 'percy', preferred_avatar_uri: gravatar } + let!(:crop_wrangler) { FactoryBot.create :crop_wrangling_member, login_name: 'croppy', preferred_avatar_uri: gravatar2 } + let!(:admin_user) { FactoryBot.create :admin_member, login_name: 'janitor', preferred_avatar_uri: gravatar3 } + let!(:someone_else) { FactoryBot.create :edinburgh_member, login_name: 'ruby', preferred_avatar_uri: gravatar4 } + + let(:gravatar) { 'http://www.gravatar.com/avatar/d021434aac03a7f7c7c0de60d07dad1c?size=150&default=identicon' } + let(:gravatar2) { 'http://www.gravatar.com/avatar/353d83d3677b142520987e1936fd093c?size=150&default=identicon' } + let(:gravatar3) { 'http://www.gravatar.com/avatar/622db62c7beab8d5d8b7a80aa6385b2f?size=150&default=identicon' } + let(:gravatar4) { 'http://www.gravatar.com/avatar/7fd767571ff5ceefc7a687a543b2c402?size=150&default=identicon' } + + let!(:tomato) { FactoryBot.create :tomato, creator: someone_else } + let(:plant_part) { FactoryBot.create :plant_part, name: 'fruit' } + + let(:tomato_photo) do + FactoryBot.create :photo, + title: 'look at my tomatoes', + owner: member, + fullsize_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_z.jpg', + thumbnail_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_q.jpg' + end + let(:post_body) do + "So, um, watering's important. Yep. Very important. + +Well, what with moving into the house and all THAT entails...my plants are looking the worse for wear. They haven't gotten enough water. The oregano is dead. The basil and chives are just hanging on. The [tomato](crop) have sort of purple leaves. Seeing that the roots were all growing out of the bottom of the pots, I finally went and got soil to fill the basins I have for the tomatoes and spent the money on proper (much larger) pots for the herbs. + +At Home Depot, it turned out that 7.5\" pots that are glazed inside and out (to prevent wicking & evaporation of water -- the problem my tomatoes were hitting with the teensy clay pots) were $10 for the pot and $5 for the saucer. Or there are 7.25\" self-watering pots for $15. So my herbs are now in self-watering pots where they should be able to survive Pennsic without me. I got a new oregano plant too. + +[ ![self-watering herbs](http://farm4.staticflickr.com/3735/9337893326_62a036bf56.jpg) ](http://www.flickr.com/photos/maco_nix/9337893326/) + +The tomatoes are now in large plastic bins full of dirt/compost, where their roots can spread out. Turns out clay pots in weather that is always over 80, usually over 90, and hitting over 100 (celsius people, read those as 26, 32, 38) means you need to water at least daily, probably a couple of times a day, to keep the plants happy. + +[ ![tomatoes in plastic cement mixing tubs](http://farm4.staticflickr.com/3745/9337878942_9602530c31.jpg)](http://www.flickr.com/photos/maco_nix/9337878942/) + +After taking that photo, I put some egg shells (since I hardboiled some eggs today for pickling) in the dirt around them and added stakes. + +I noticed a couple of days ago on the way to work that there's a place near home called Country Boy Market. Fresh locally grown produce (cheap berries, nom nom), mulch, top soil, compost, and straw bales are all available. Also they deliver mulch & soil. Well then. I know what's happening next spring when I try to build up the rest of the garden. +[apple](crop) + " + end + let(:post) { FactoryBot.create :post, author: member, subject: "Watering", body: post_body } + before do + # Freeze time, so we don't have variations in timestamps on the page + Timecop.freeze(Time.zone.local(2019, 1, 1)) + + { + chard: 'https://farm9.staticflickr.com/8516/8519911893_1759c28965_q.jpg', + apple: 'https://farm5.staticflickr.com/4748/38932178855_6fe9bcdb48_q.jpg', + pear: 'https://farm1.staticflickr.com/113/250984726_0fc31fea6d_q.jpg', + popcorn: 'https://farm8.staticflickr.com/7893/33150160528_24a689c6bc_q.jpg', + eggplant: 'https://farm8.staticflickr.com/7856/47068736892_1af9b8a4ba_q.jpg', + maize: 'https://farm66.staticflickr.com/65535/46739264475_7cb55b2cbb_q.jpg' + }.each do |crop_type, photo_url| + crop = FactoryBot.create crop_type, creator: someone_else + owner = FactoryBot.create :member, login_name: crop_type.to_s.reverse, email: "#{crop.name}@example.com" + planting = FactoryBot.create :planting, crop: crop, owner: owner, garden: owner.gardens.first + photo = FactoryBot.create(:photo, owner: owner, + thumbnail_url: "#{photo_url}_q.jpg", fullsize_url: "#{photo_url}_z.jpg") + planting.photos << photo + + harvest = FactoryBot.create :harvest, crop: crop, owner: owner, plant_part: plant_part + harvest.photos << photo + FactoryBot.create :planting, crop: tomato, + planted_at: 1.year.ago, finished_at: 2.months.ago, + sunniness: 'sun', planted_from: 'seed' + end + + FactoryBot.create_list :post, 7 + FactoryBot.create :seed, owner: member, tradable_to: 'nationally' + FactoryBot.create :seed, owner: someone_else, tradable_to: 'nationally' + end + after { Timecop.return } + + shared_examples 'visit pages' do + describe 'home' do + it 'loads homepage' do + visit root_path + Percy.snapshot(page, name: "#{prefix}/homepage") + end + end + + describe 'crops' do + it 'loads crops#show' do + FactoryBot.create :planting, planted_at: 2.months.ago, sunniness: 'shade', planted_from: 'seedling' + + planting = FactoryBot.create :planting, planted_at: 1.year.ago, sunniness: 'sun', planted_from: 'seed', crop: tomato + FactoryBot.create(:harvest, + crop: tomato, + plant_part: FactoryBot.create(:plant_part, name: 'berry'), + planting: planting, + harvested_at: 1.day.ago) + + tomato.posts << FactoryBot.create(:post, subject: 'tomatoes are delicious') + + visit crop_path(tomato) + expect(page).to have_text 'tomato' + Percy.snapshot(page, name: "#{prefix}/crops#show") + end + it 'loads crops#index' do + visit crops_path + Percy.snapshot(page, name: "#{prefix}/crops#index") + end + end + + describe 'plantings' do + it 'loads plantings#index' do + visit plantings_path + Percy.snapshot(page, name: "#{prefix}/plantings#index") + end + + it 'load another member plantings#show' do + planting = FactoryBot.create :planting, crop: tomato, owner: someone_else, garden: someone_else.gardens.first + visit planting_path(planting) + Percy.snapshot(page, name: "#{prefix}/plantings#show") + end + end + + describe 'gardens' do + let(:first_garden) { Garden.first } + let(:second_garden) { Garden.second } + let(:third_garden) { Garden.all.offset(3)[0] } + it 'loads gardens#index' do + FactoryBot.create_list :planting, 3, garden: first_garden, owner: first_garden.owner + FactoryBot.create_list :planting, 7, garden: second_garden, owner: second_garden.owner + FactoryBot.create_list :planting, 26, garden: third_garden, owner: third_garden.owner + visit gardens_path + Percy.snapshot(page, name: "#{prefix}/gardens#index") + end + + it 'gardens#show' do + # a garden + garden = FactoryBot.create :garden, name: 'paradise', owner: member + # with some lettuce (finished) + FactoryBot.create :planting, crop: FactoryBot.create(:crop, name: 'lettuce'), garden: garden, owner: member, finished_at: 2.weeks.ago + # tomato still growing + tomato_planting = FactoryBot.create :planting, garden: garden, owner: member, crop: tomato + tomato_photo.plantings << tomato_planting + visit garden_path(garden) + Percy.snapshot(page, name: "#{prefix}/gardens#show") + end + end + + describe 'members' do + it 'loads members#index' do + visit members_path + Percy.snapshot(page, name: "#{prefix}/members#index") + end + + it 'loads another members#show' do + FactoryBot.create :planting, owner: someone_else, created_at: 30.days.ago, crop: tomato + FactoryBot.create :planting, owner: someone_else, created_at: 24.days.ago, crop: tomato + FactoryBot.create :post, author: someone_else, created_at: 4.days.ago, subject: 'waiting for my tomatoes' + FactoryBot.create :harvest, owner: someone_else, created_at: 1.day.ago, crop: tomato + + visit member_path(someone_else) + Percy.snapshot(page, name: "#{prefix}/members#show") + end + end + + describe 'posts' do + it 'loads posts#show' do + FactoryBot.create :comment, post: post + FactoryBot.create :comment, post: post + visit post_path(post) + Percy.snapshot(page, name: "#{prefix}/posts#show") + end + it 'loads posts#index' do + Member.all.limit(5).each do |member| + FactoryBot.create_list :post, 12, author: member + end + Post.all.order(id: :desc).limit(4) do |post| + FactoryBot.create_list :comment, rand(1..5), post: post + end + visit posts_path + Percy.snapshot(page, name: "#{prefix}/posts#index") + end + end + + describe 'photos' do + it 'loads photos#show' do + tomato_photo.plantings << FactoryBot.create(:planting, owner: member, crop: tomato) + visit photo_path(tomato_photo) + Percy.snapshot(page, name: "#{prefix}/photos#show") + end + end + end + + context "when signed out" do + let(:prefix) { 'signed-out' } + include_examples 'visit pages' + + it 'loads sign in page' do + visit crops_path # some random page + click_link 'Sign in' + Percy.snapshot(page, name: "sign-in") + end + + it 'loads sign up page' do + visit crops_path # some random page + click_link 'Sign up' + Percy.snapshot(page, name: "sign-up") + end + + it 'loads forgot password' do + visit new_member_password_path + Percy.snapshot(page, name: "forgot-password") + end + it 'loads new confirmation' do + visit new_member_confirmation_path + Percy.snapshot(page, name: "new-confimation") + end + end + + context 'when signed in' do + let(:prefix) { 'signed-in' } + before { login_as member } + include_examples 'visit pages' + + it 'load my plantings#show' do + planting = FactoryBot.create :planting, crop: tomato, owner: member, garden: member.gardens.first + visit planting_path(planting) + Percy.snapshot(page, name: "#{prefix}/self/plantings#show") + end + + it 'load my members#show' do + visit member_path(member) + Percy.snapshot(page, name: "#{prefix}/self/members#show") + end + + let(:my_first_garden) { Garden.first } + let(:my_second_garden) { Garden.second } + let(:my_third_garden) { Garden.all.offset(3)[0] } + + it 'loads gardens#index' do + FactoryBot.create_list :planting, 3, garden: my_first_garden, owner: my_first_garden.owner + FactoryBot.create_list :planting, 7, garden: my_second_garden, owner: my_second_garden.owner + FactoryBot.create_list :planting, 26, garden: my_third_garden, owner: my_third_garden.owner + visit gardens_path + Percy.snapshot(page, name: "#{prefix}/gardens#index") + end + + it 'load my gardens#show' do + garden = FactoryBot.create :garden, name: 'paradise', owner: member + visit garden_path(garden) + Percy.snapshot(page, name: "#{prefix}/self/gardens#show") + end + + describe '#new' do + it 'plantings#new' do + visit new_planting_path + Percy.snapshot(page, name: "#{prefix}/plantings#new") + fill_in 'crop', with: 'cap' + Percy.snapshot(page, name: "#{prefix}/crops-autocomplete") + end + + it 'crops#new' do + visit new_crop_path + Percy.snapshot(page, name: "#{prefix}/crops#new") + end + + it 'gardens#new' do + visit new_garden_path + Percy.snapshot(page, name: "#{prefix}/gardens#new") + end + + it 'harvests#new' do + visit new_harvest_path + Percy.snapshot(page, name: "#{prefix}/harvests#new") + fill_in(id: 'crop', with: 'tom') + Percy.snapshot(page, name: "#{prefix}/harvests#new-autosuggest") + end + + it 'plantings#new' do + visit new_planting_path + Percy.snapshot(page, name: "#{prefix}/plantings#new") + fill_in(id: 'crop', with: 'tom') + Percy.snapshot(page, name: "#{prefix}/plantings#new-autosuggest") + end + + it 'seeds#new' do + visit new_seed_path + Percy.snapshot(page, name: "#{prefix}/seeds#new") + fill_in(id: 'crop', with: 'tom') + Percy.snapshot(page, name: "#{prefix}/seeds#new-autosuggest") + end + + it 'posts#new' do + visit new_post_path + Percy.snapshot(page, name: "#{prefix}/posts#new") + end + end + + describe '#edit' do + it 'loads gardens#edit' do + garden = FactoryBot.create :garden, owner: member + visit edit_garden_path(garden) + Percy.snapshot(page, name: "#{prefix}/gardens#edit") + end + + it 'loads harvests#edit' do + harvest = FactoryBot.create :harvest, owner: member + visit edit_harvest_path(harvest) + Percy.snapshot(page, name: "#{prefix}/harvests#edit") + end + + it 'loads planting#edit' do + planting = FactoryBot.create :planting, owner: member + visit edit_planting_path(planting) + Percy.snapshot(page, name: "#{prefix}/plantings#edit") + end + + it 'loads posts#edit' do + visit edit_post_path(post) + Percy.snapshot(page, name: "#{prefix}/posts#edit") + end + + it 'comments#new' do + visit new_comment_path(post_id: post.id) + Percy.snapshot(page, name: "comments#new") + end + end + + describe 'expand menus' do + it 'expands crop menu' do + visit root_path + click_on 'Crops' + Percy.snapshot(page, name: "#{prefix}/crops-menu") + click_on 'Community' + Percy.snapshot(page, name: "#{prefix}/community-menu") + click_on 'percy' + Percy.snapshot(page, name: "#{prefix}/member-menu") + end + end + end + + context 'wrangling crops' do + let(:prefix) { 'crop-wrangler' } + before { login_as crop_wrangler } + let!(:candy) { FactoryBot.create :crop_request, name: 'candy' } + + it 'crop wrangling page' do + visit wrangle_crops_path + Percy.snapshot(page, name: 'crops wrangle') + click_link 'Pending approval' + Percy.snapshot(page, name: 'crops pending approval') + click_link 'candy' + Percy.snapshot(page, name: 'editing pending crop') + end + end + context 'admin' do + before do + login_as admin_user + visit admin_path + end + it 'admin page' do + Percy.snapshot(page, name: 'Admin') + end + it 'Roles' do + click_link 'Roles' + Percy.snapshot(page, name: 'Admin Roles') + end + it 'CMS' do + click_link 'CMS' + Percy.snapshot(page, name: 'CMS') + end + it 'Garden Types' do + click_link 'Garden Types' + Percy.snapshot(page, name: 'Admin Garden type') + end + it 'Alternate names' do + click_link 'Alternate names' + Percy.snapshot(page, name: 'Admin Alternate names') + end + it 'Scientific names' do + click_link 'Scientific names' + Percy.snapshot(page, name: 'Admin Scientific names') + end + it 'Members' do + click_link 'Members' + Percy.snapshot(page, name: 'Admin Members') + end + end +end From a93aecdb3b4d2b9a978cafbffa40446134f426e3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 7 Jun 2019 14:01:21 +1200 Subject: [PATCH 209/549] Alternate names specs --- app/views/crops/_alternate_names.html.haml | 8 +++++--- spec/features/crops/alternate_name_spec.rb | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/views/crops/_alternate_names.html.haml b/app/views/crops/_alternate_names.html.haml index 54623730d..5d75b81f3 100644 --- a/app/views/crops/_alternate_names.html.haml +++ b/app/views/crops/_alternate_names.html.haml @@ -6,11 +6,11 @@ %ul.list-group.list-group-flush - crop.alternate_names.each do |an| %li.list-group-item.d-flex.justify-content-between.align-items-center - = an.name - if can? :edit, an .dropdown.planting-actions - %a#planting-actions-scinames.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} - .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "planting-actions-button"} + %a#crop-actions-altnames.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button", :href => '#'} + = an.name + .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "crop-actions-altnames"} - if can? :edit, an = link_to edit_alternate_name_path(an), class: 'dropdown-item' do = edit_icon @@ -19,6 +19,8 @@ = link_to an, method: :delete, data: { confirm: 'Are you sure?' }, class: 'dropdown-item' do = delete_icon = t('.delete') + - else + = an.name %p.text-right - if can? :edit, crop diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb index 522ee8e30..d9b48094b 100644 --- a/spec/features/crops/alternate_name_spec.rb +++ b/spec/features/crops/alternate_name_spec.rb @@ -28,6 +28,7 @@ describe "Alternate names", js: true do expect(page.status_code).to equal 200 expect(page).to have_content "CROP WRANGLER" expect(page).to have_content alternate_eggplant.name + click_link 'aubergine' expect(page).to have_link "Edit", href: edit_alternate_name_path(alternate_eggplant) within('.alternate_names') { click_on "Edit" } expect(page.status_code).to equal 200 @@ -41,6 +42,7 @@ describe "Alternate names", js: true do it "Crop wranglers can delete alternate names" do visit crop_path(alternate_eggplant.crop) + click_link 'aubergine' expect(page).to have_link "Delete", href: alternate_name_path(alternate_eggplant) within('.alternate_names') { click_on "Delete" } From b608a0e3ac00631236772d951935cc4655259c4e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 7 Jun 2019 14:04:51 +1200 Subject: [PATCH 210/549] Scientific name matching alt names --- app/views/crops/_scientific_names.html.haml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/crops/_scientific_names.html.haml b/app/views/crops/_scientific_names.html.haml index 7a566d689..b5e97414a 100644 --- a/app/views/crops/_scientific_names.html.haml +++ b/app/views/crops/_scientific_names.html.haml @@ -6,10 +6,9 @@ %ul.list-group.list-group-flush - crop.scientific_names.each do |sn| %li.list-group-item.d-flex.justify-content-between.align-items-center - = sn.name - if can? :edit, sn .dropdown.planting-actions - %a#planting-actions-scinames.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} + %a#planting-actions-scinames.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button", :href => '#'}= sn.name .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "planting-actions-button"} = link_to edit_scientific_name_path(sn), class: 'dropdown-item' do = edit_icon @@ -17,6 +16,8 @@ = link_to sn, method: :delete, data: { confirm: 'Are you sure?' }, class: 'dropdown-item' do = delete_icon = t('.delete') + - else + = sn.name %p.text-right - if can? :edit, crop From 74bae315579557443919215999f44958e1125813 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 7 Jun 2019 20:33:23 +1200 Subject: [PATCH 211/549] Max size for hero photo --- app/assets/stylesheets/photos.scss | 4 ++++ app/views/photos/_gallery.haml | 2 +- app/views/plantings/_photos.haml | 10 ++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/photos.scss b/app/assets/stylesheets/photos.scss index c6f2d896a..4756f1656 100644 --- a/app/assets/stylesheets/photos.scss +++ b/app/assets/stylesheets/photos.scss @@ -30,3 +30,7 @@ display: block; max-width: 100%; } + +.hero-photo { + max-height: 500px; +} \ No newline at end of file diff --git a/app/views/photos/_gallery.haml b/app/views/photos/_gallery.haml index 31c0fb32c..b2d72fac7 100644 --- a/app/views/photos/_gallery.haml +++ b/app/views/photos/_gallery.haml @@ -1,5 +1,5 @@ .photos-grid - .photo-grid-item= link_to image_tag(photos.first.fullsize_url, class: 'rounded mx-auto'), photos.first + .photo-grid-item= link_to image_tag(photos.first.fullsize_url, class: 'rounded mx-auto hero-photo'), photos.first - photos.offset(1).each do |photo| .photo-grid-item = link_to photo do diff --git a/app/views/plantings/_photos.haml b/app/views/plantings/_photos.haml index 00141c76f..ef94a9e35 100644 --- a/app/views/plantings/_photos.haml +++ b/app/views/plantings/_photos.haml @@ -1,9 +1,11 @@ %h2 Photos - if planting.photos.size.positive? - = render 'photos/gallery', photos: photos - - if can?(:edit, planting) && can?(:create, Photo) - %p.text-right= add_photo_button(planting) - %p.text-right= link_to 'more photos', planting_photos_path(@planting), class: 'btn' + .row + = render 'photos/gallery', photos: photos + .row + - if can?(:edit, planting) && can?(:create, Photo) + %p.text-right= add_photo_button(planting) + %p.text-right= link_to 'more photos', planting_photos_path(@planting), class: 'btn' - else %p No photos. - if can?(:edit, planting) && can?(:create, Photo) From 81f1a55aca92a15d2ebea6a75098710ce76d9eac Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 7 Jun 2019 20:34:37 +1200 Subject: [PATCH 212/549] actions menu for seeds --- app/views/seeds/_actions.html.haml | 28 ++++++++++++++-------------- app/views/seeds/show.html.haml | 7 ++++--- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/app/views/seeds/_actions.html.haml b/app/views/seeds/_actions.html.haml index 719c12de9..e2200a743 100644 --- a/app/views/seeds/_actions.html.haml +++ b/app/views/seeds/_actions.html.haml @@ -1,14 +1,14 @@ -.seed-actions - - if can? :edit, seed - .btn-group - = seed_edit_button(seed) - = add_photo_button(seed) - - - if can?(:create, Planting) && seed.active? - = link_to new_planting_path(seed_id: seed), class: 'btn btn-default' do - %span.glyphicon.glyphicon-grain{ title: "Plant seeds" } - Plant seeds - - = seed_finish_button(seed) - - = delete_button(seed) if can? :destroy, seed +- if can?(:create, Planting) && can?(:update, seed) && seed.active? + = link_to new_planting_path(seed_id: seed), class: 'btn btn-info' do + %span.glyphicon.glyphicon-grain{ title: "Plant seeds" } + Plant seeds +- if can?(:edit, seed) + .dropdown.float-right.seed-actions + %a#seed-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions + .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "seed-actions-button"} + = seed_edit_button(seed, classes: 'dropdown-item') + = add_photo_button(seed, classes: 'dropdown-item') + - if seed.active? + = seed_finish_button(seed, classes: 'dropdown-item') + .dropdown-divider + = delete_button(seed, classes: 'dropdown-item text-danger') diff --git a/app/views/seeds/show.html.haml b/app/views/seeds/show.html.haml index 135b0bba1..4e833f02b 100644 --- a/app/views/seeds/show.html.haml +++ b/app/views/seeds/show.html.haml @@ -9,15 +9,16 @@ = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) -- content_for :buttonbar do - = render 'seeds/actions', seed: @seed - + - content_for :breadcrumbs do %li.breadcrumb-item= link_to 'Seeds', seeds_path %li.breadcrumb-item.active= link_to @seed, @seed .row .col-md-6 + %h1 + #{@seed.owner}'s #{@seed.crop} seeds + = render 'seeds/actions', seed: @seed %dl.dl-horizontal %dt Owner %dd From b1b24f5e0a99c49d81c9f605616ffd0f1c38dba8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 7 Jun 2019 20:34:51 +1200 Subject: [PATCH 213/549] mark delete link as danger --- app/views/crops/_wrangle.html.haml | 2 +- app/views/plantings/_actions.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/crops/_wrangle.html.haml b/app/views/crops/_wrangle.html.haml index 2add6dbe0..243332574 100644 --- a/app/views/crops/_wrangle.html.haml +++ b/app/views/crops/_wrangle.html.haml @@ -13,6 +13,6 @@ - if can? :destroy, crop .dropdown-divider - = link_to crop, method: :delete, class: 'dropdown-item bg-danger' do + = link_to crop, method: :delete, class: 'dropdown-item text-danger' do = delete_icon Delete diff --git a/app/views/plantings/_actions.html.haml b/app/views/plantings/_actions.html.haml index da4bc133e..e24b982b0 100644 --- a/app/views/plantings/_actions.html.haml +++ b/app/views/plantings/_actions.html.haml @@ -9,4 +9,4 @@ = planting_harvest_button(planting, classes: 'dropdown-item') = planting_save_seeds_button(planting, classes: 'dropdown-item') .dropdown-divider - = delete_button(planting, classes: 'dropdown-item') + = delete_button(planting, classes: 'dropdown-item text-danger') From ffeaa08ff7c72ba8d6ba49f1aa5a5d762cba2db7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 7 Jun 2019 20:35:24 +1200 Subject: [PATCH 214/549] restore crops sidebar to match specs --- app/views/crops/_harvests.html.haml | 8 ++++---- app/views/crops/_plantings.html.haml | 29 +++++++++------------------- app/views/crops/show.html.haml | 20 +++++-------------- 3 files changed, 18 insertions(+), 39 deletions(-) diff --git a/app/views/crops/_harvests.html.haml b/app/views/crops/_harvests.html.haml index 8bb70032d..6e19723ef 100644 --- a/app/views/crops/_harvests.html.haml +++ b/app/views/crops/_harvests.html.haml @@ -1,11 +1,11 @@ -%h4 #{crop.name.capitalize} harvests +%h3 #{crop.name.capitalize} harvests - if crop.harvests.empty? %p Nobody has harvested this crop yet. - else - %ul + %ul.list-group.list-group-flush - crop.harvests.order(harvested_at: :desc).limit(3).each do |harvest| - %li + %li.list-group-item = link_to "#{harvest.owner} harvested #{display_quantity(harvest)}.", harvest_path(harvest) = render 'members/location', member: harvest.owner %small @@ -15,6 +15,6 @@ = link_to "View all #{crop.name} harvests", crop_harvests_path(crop) - if crop.approved? - if current_member - %p= link_to "Harvest #{crop.name}", new_harvest_path(crop_id: crop.id) + %p= link_to "Harvest #{crop.name}", new_harvest_path(crop_id: crop.id), class: 'btn' - else = render partial: 'shared/signin_signup', locals: { to: "track your #{crop.name} harvests" } diff --git a/app/views/crops/_plantings.html.haml b/app/views/crops/_plantings.html.haml index 1da5c3644..d0359ec89 100644 --- a/app/views/crops/_plantings.html.haml +++ b/app/views/crops/_plantings.html.haml @@ -1,20 +1,9 @@ -%h4 See who's planted #{crop.name.pluralize} -- if crop.plantings.empty? - %p - Nobody has planted this crop yet. -- else - %ul - - crop.plantings.order(planted_at: :desc).limit(3).each do |planting| - %li - = link_to planting, planting_path(planting) - = render partial: 'members/location', locals: { member: planting.owner } - %small - = distance_of_time_in_words(planting.created_at, Time.zone.now) - ago. - %p - = link_to "View all #{crop.name} plantings", crop_plantings_path(crop) -- if crop.approved? - - if current_member - %p= link_to "Plant #{crop.name}", new_planting_path(crop_id: crop.id) - - else - = render partial: 'shared/signin_signup', locals: { to: "track your #{crop.name} plantings" } +%h3 See who's planted #{crop.name.pluralize} +%ul.list-group.list-group-flush + - crop.plantings.order(planted_at: :desc).limit(5).each do |planting| + %li.list-group-item + = planting_icon + = link_to planting do + = planting + - if planting.owner.location.present? + %small=planting.owner.location \ No newline at end of file diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 2abffc22b..72d9b8abc 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -103,26 +103,16 @@ = link_to member_seeds_path(current_member, crop_slug: @crop.slug) do = display_seed_availability(@current_member, @crop) - .card-body - = render 'scientific_names', crop: @crop - = render 'alternate_names', crop: @crop - .card-body - %h3 See who's planted #{@crop.name.pluralize} - %ul.list-group.list-group-flush - - @crop.plantings.order(planted_at: :desc).limit(5).each do |planting| - %li.list-group-item - = link_to planting do - = planting_icon - = planting - - if planting.owner.location.present? - %small=planting.owner.location + .card-body + = render 'scientific_names', crop: @crop + = render 'alternate_names', crop: @crop + = render 'plantings', crop: @crop + = render 'harvests', crop: @crop - %hr/ = render 'find_seeds', crop: @crop - %hr/ .card .card-body %h5.card-title Learn more about #{@crop.name.pluralize} From 3bcb34d3363f3eafc70dad21822236c29befadec Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 7 Jun 2019 20:35:42 +1200 Subject: [PATCH 215/549] Member cards with only the active data counted --- app/views/members/_member.haml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/members/_member.haml b/app/views/members/_member.haml index 2782c1106..c8e595cfb 100644 --- a/app/views/members/_member.haml +++ b/app/views/members/_member.haml @@ -15,10 +15,10 @@ %ul.nav.nav-justified.small %li.nav-item.border-right = link_to member_plantings_path(member) do - = localize_plural(member.plantings, Planting) + = localize_plural(member.plantings.active.size, Planting) %li.nav-item.border-right = link_to member_harvests_path(member) do - = localize_plural(member.harvests, Harvest) + = localize_plural(member.harvests.size, Harvest) %li.nav-item = link_to member_seeds_path(member) do - = localize_plural(member.seeds, Seed) + = localize_plural(member.seeds.active.size, Seed) From 06650a790d86a413fcd590672aecf62cc27ffee0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 7 Jun 2019 20:36:02 +1200 Subject: [PATCH 216/549] active scopes on plantings and seeds --- app/models/planting.rb | 2 +- app/models/seed.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/planting.rb b/app/models/planting.rb index b8422b310..fc5ab3b36 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -33,7 +33,7 @@ class Planting < ApplicationRecord ## ## Scopes default_scope { joins(:owner) } # Ensures the owner still exists - scope :active, -> { where('finished_at IS NULL OR finished_at < ?', Time.zone.now).where(finished: false) } + scope :active, -> { where('finished <> true OR finished_at < ?', Time.zone.now) } scope :interesting, -> { has_photos.one_per_owner.order(planted_at: :desc) } scope :recent, -> { order(created_at: :desc) } scope :one_per_owner, lambda { diff --git a/app/models/seed.rb b/app/models/seed.rb index 51da83e48..8025f66e2 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -53,6 +53,7 @@ class Seed < ApplicationRecord scope :interesting, -> { tradable.has_location } scope :has_location, -> { joins(:owner).where.not("members.location": nil) } scope :recent, -> { order(created_at: :desc) } + scope :active, -> { where('finished_at < ?', Time.zone.now) } def default_photo photos.order(created_at: :desc).first From 49069f4c4af5a4aeb4d9df45d49037c6963ac0cb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 7 Jun 2019 20:36:14 +1200 Subject: [PATCH 217/549] seeds button helper, for actions links --- app/helpers/buttons_helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 0e1ecc47e..08be6a654 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -49,8 +49,8 @@ module ButtonsHelper edit_button(edit_crop_path(crop)) end - def seed_edit_button(seed) - edit_button(edit_seed_path(seed)) + def seed_edit_button(seed, classes: "btn btn-raised btn-info") + edit_button(edit_seed_path(seed), classes: classes) end def harvest_edit_button(harvest) @@ -74,10 +74,10 @@ module ButtonsHelper end end - def seed_finish_button(seed) + def seed_finish_button(seed, classes: 'btn btn-default') return unless can?(:create, Planting) && seed.active? - link_to seed_path(seed, seed: { finished: 1 }), method: :put, class: 'btn btn-default append-date' do + link_to seed_path(seed, seed: { finished: 1 }), method: :put, class: "#{classes} append-date" do finished_icon + ' ' + t('buttons.mark_as_finished') end end From 4fc460b2a23225b69e46f0f3e013410d54600608 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 7 Jun 2019 20:42:57 +1200 Subject: [PATCH 218/549] Match to crops specs --- app/views/crops/show.html.haml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 72d9b8abc..8ad280206 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -31,9 +31,9 @@ - else Nobody is growing this yet. You could be the first! - if @crop.perennial? - #{@crop.name.titleize} is a perennial crop (living more than two years) - - else - #{@crop.name.titleize} is an annual crop (living and reproducing in a single year or less) + #{@crop.name.capitalize} is a perennial crop (living more than two years) + - elsif @crop.annual? + #{@crop.name.capitalize} is an annual crop (living and reproducing in a single year or less) %hr/ = render 'predictions', crop: @crop @@ -109,8 +109,6 @@ = render 'plantings', crop: @crop = render 'harvests', crop: @crop - - = render 'find_seeds', crop: @crop .card From 9e1d531de9356a724e9631c8eb94c48b24b6388b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 7 Jun 2019 20:44:30 +1200 Subject: [PATCH 219/549] nil for perennial doesn't mean annual --- app/models/crop.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/crop.rb b/app/models/crop.rb index fa82bd50d..96605bd23 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -117,7 +117,7 @@ class Crop < ApplicationRecord end def annual? - !perennial + perennial == false end def interesting? From ee7ea523e1d33c2488d2cc20950959d022dcdef1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 7 Jun 2019 20:44:44 +1200 Subject: [PATCH 220/549] capitalise name in spec to match new view --- spec/features/crops/crop_detail_page_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index 2c263999b..6d4321d7a 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -148,7 +148,7 @@ describe "crop detail page", js: true do it "describes annual crops" do expect(subject).to have_text( - "#{crop.name} is an annual crop (living and reproducing in a single year or less)" + "#{crop.name.capitalize} is an annual crop (living and reproducing in a single year or less)" ) end end @@ -164,7 +164,7 @@ describe "crop detail page", js: true do end it "describes perennial crops" do - expect(subject).to have_text("#{crop.name} is a perennial crop (living more than two years)") + expect(subject).to have_text("#{crop.name.capitalize} is a perennial crop (living more than two years)") end end From b62f64804247a23f1b94b39b1519fa915cdd6e93 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Fri, 7 Jun 2019 10:38:58 +0000 Subject: [PATCH 221/549] [CodeFactor] Apply fixes --- spec/features/crops/alternate_name_spec.rb | 4 ++-- spec/features/crops/crop_detail_page_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb index d9b48094b..e6cc3057a 100644 --- a/spec/features/crops/alternate_name_spec.rb +++ b/spec/features/crops/alternate_name_spec.rb @@ -44,7 +44,7 @@ describe "Alternate names", js: true do visit crop_path(alternate_eggplant.crop) click_link 'aubergine' expect(page).to have_link "Delete", - href: alternate_name_path(alternate_eggplant) + href: alternate_name_path(alternate_eggplant) within('.alternate_names') { click_on "Delete" } expect(page.status_code).to equal 200 expect(page).not_to have_content alternate_eggplant.name @@ -54,7 +54,7 @@ describe "Alternate names", js: true do it "Crop wranglers can add alternate names" do visit crop_path(crop) expect(page).to have_link "Add", - href: new_alternate_name_path(crop_id: crop.id) + href: new_alternate_name_path(crop_id: crop.id) within('.alternate_names') { click_on "Add" } expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index 6d4321d7a..15b5dfed5 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -70,12 +70,12 @@ describe "crop detail page", js: true do it "has a link to OpenFarm" do expect(page).to have_link "OpenFarm - Growing guide", - href: "https://openfarm.cc/en/crops/#{CGI.escape crop.name}" + href: "https://openfarm.cc/en/crops/#{CGI.escape crop.name}" end it "has a link to gardenate" do expect(page).to have_link "Gardenate - Planting reminders", - href: "http://www.gardenate.com/plant/#{CGI.escape crop.name}" + href: "http://www.gardenate.com/plant/#{CGI.escape crop.name}" end end end From 96eaba2a79c1dbfacadcda77622138c955457bee Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 08:23:56 +1200 Subject: [PATCH 222/549] Needs bonsai to deploy on heroku --- app.json | 1 + 1 file changed, 1 insertion(+) diff --git a/app.json b/app.json index b7dadd784..7a56323a9 100644 --- a/app.json +++ b/app.json @@ -37,6 +37,7 @@ } }, "addons": [ + "bonsai", "heroku-postgresql", "memcachier", "newrelic", From 5a2f9f84d8913665b49e06e21c95f5627e994e5d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 08:34:50 +1200 Subject: [PATCH 223/549] Comment for post deploy script in heroku config --- app.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app.json b/app.json index 7a56323a9..7a1659be1 100644 --- a/app.json +++ b/app.json @@ -3,7 +3,9 @@ "stack": "heroku-18", "description": "Open data project for small-scale food growers", "scripts": { - "postdeploy": "bundle exec rails db:migrate db:seed" + // The postdeploy script is run once, after the app is created + // and not on subsequent deploys to the app + "postdeploy": "bundle exec rails db:seed" }, "env": { "GROWSTUFF_ELASTICSEARCH": { From 8cc3bada0a226bcda22a341254b855886c6e65c4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 09:23:27 +1200 Subject: [PATCH 224/549] update spec to find elements on the new forms --- spec/features/gardens/adding_gardens_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/features/gardens/adding_gardens_spec.rb b/spec/features/gardens/adding_gardens_spec.rb index 437d2812f..bb161e4fd 100644 --- a/spec/features/gardens/adding_gardens_spec.rb +++ b/spec/features/gardens/adding_gardens_spec.rb @@ -14,10 +14,10 @@ describe "Gardens", :js do end it "displays required and optional fields properly" do - expect(page).to have_selector ".form-group.required", text: "Name" - expect(page).to have_optional 'textarea#garden_description' - expect(page).to have_optional 'input#garden_location' - expect(page).to have_optional 'input#garden_area' + expect(page).to have_selector ".required", text: "Name" + expect(page).to have_selector 'textarea#garden_description' + expect(page).to have_selector 'input#garden_location' + expect(page).to have_selector 'input#garden_area' end it "Create new garden" do From 7965845ab28c8ee387dfeab09cf03cc254a78ca7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 09:24:18 +1200 Subject: [PATCH 225/549] crops show sidebar tidy up harvests and plantings --- app/views/crops/_harvests.html.haml | 41 ++++++++++++++------------- app/views/crops/_plantings.html.haml | 25 ++++++++++------ app/views/crops/_wrangle.html.haml | 33 ++++++++++----------- app/views/crops/show.html.haml | 4 +-- app/views/harvests/show.html.haml | 1 - app/views/members/_location.html.haml | 2 +- app/views/members/_tiny.haml | 2 ++ app/views/seeds/_card.html.haml | 4 +-- 8 files changed, 60 insertions(+), 52 deletions(-) create mode 100644 app/views/members/_tiny.haml diff --git a/app/views/crops/_harvests.html.haml b/app/views/crops/_harvests.html.haml index 6e19723ef..23b071e69 100644 --- a/app/views/crops/_harvests.html.haml +++ b/app/views/crops/_harvests.html.haml @@ -1,20 +1,21 @@ -%h3 #{crop.name.capitalize} harvests -- if crop.harvests.empty? - %p - Nobody has harvested this crop yet. -- else - %ul.list-group.list-group-flush - - crop.harvests.order(harvested_at: :desc).limit(3).each do |harvest| - %li.list-group-item - = link_to "#{harvest.owner} harvested #{display_quantity(harvest)}.", harvest_path(harvest) - = render 'members/location', member: harvest.owner - %small - = distance_of_time_in_words(harvest.harvested_at, Time.zone.now) - ago. - %p - = link_to "View all #{crop.name} harvests", crop_harvests_path(crop) -- if crop.approved? - - if current_member - %p= link_to "Harvest #{crop.name}", new_harvest_path(crop_id: crop.id), class: 'btn' - - else - = render partial: 'shared/signin_signup', locals: { to: "track your #{crop.name} harvests" } +.card + .card-body + %h3 #{crop.name.capitalize} harvests + - if crop.harvests.empty? + %p Nobody has harvested this crop yet. + - unless crop.harvests.empty? + %ul.list-group.list-group-flush + - crop.harvests.order(harvested_at: :desc).limit(3).each do |harvest| + %li.list-group-item + = harvest_icon + = link_to "#{harvest.owner} harvested #{display_quantity(harvest)}.", harvest_path(harvest) + .float-right= render 'members/location', member: harvest.owner + .harvest-timeago + %small #{distance_of_time_in_words(harvest.harvested_at, Time.zone.now)} ago. + .card-footer + %p= link_to "View all #{crop.name} harvests", crop_harvests_path(crop) + - if crop.approved? + - if current_member + %p= link_to "Harvest #{crop.name}", new_harvest_path(crop_id: crop.id), class: 'btn' + - else + = render partial: 'shared/signin_signup', locals: { to: "track your #{crop.name} harvests" } diff --git a/app/views/crops/_plantings.html.haml b/app/views/crops/_plantings.html.haml index d0359ec89..611f2d081 100644 --- a/app/views/crops/_plantings.html.haml +++ b/app/views/crops/_plantings.html.haml @@ -1,9 +1,16 @@ -%h3 See who's planted #{crop.name.pluralize} -%ul.list-group.list-group-flush - - crop.plantings.order(planted_at: :desc).limit(5).each do |planting| - %li.list-group-item - = planting_icon - = link_to planting do - = planting - - if planting.owner.location.present? - %small=planting.owner.location \ No newline at end of file +.card + .card-body + %h3 See who's planted #{crop.name.pluralize} + - unless crop.plantings.empty? + %ul.list-group.list-group-flush + - crop.plantings.order(planted_at: :desc).limit(5).each do |planting| + %li.list-group-item + = planting_icon + = link_to planting, planting + .float-right= render 'members/location', member: planting.owner + .card-footer + - if crop.approved? + - if current_member + %p= link_to "Plant #{crop.name}", new_planting_path(crop_id: crop.id), class: 'btn' + - else + = render partial: 'shared/signin_signup', locals: { to: "track your #{crop.name} plantings" } diff --git a/app/views/crops/_wrangle.html.haml b/app/views/crops/_wrangle.html.haml index 243332574..c56a7b8c8 100644 --- a/app/views/crops/_wrangle.html.haml +++ b/app/views/crops/_wrangle.html.haml @@ -1,18 +1,19 @@ - if can?(:edit, crop) || can?(:destroy, crop) - %h4 Crop wrangling - %p - You are a - = succeed "." do - %strong CROP WRANGLER - .dropdown.crop-actions - %button#crop-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions - .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "crop-actions-button"} - = link_to edit_crop_path(crop), class: 'dropdown-item' do - = edit_icon - = t('.edit') + .alert.alert-success{role: "alert"} + %h4 Crop wrangling + %p + You are a + = succeed "." do + %strong CROP WRANGLER + .dropdown.crop-actions + %button#crop-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions + .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "crop-actions-button"} + = link_to edit_crop_path(crop), class: 'dropdown-item' do + = edit_icon + = t('.edit') - - if can? :destroy, crop - .dropdown-divider - = link_to crop, method: :delete, class: 'dropdown-item text-danger' do - = delete_icon - Delete + - if can? :destroy, crop + .dropdown-divider + = link_to crop, method: :delete, class: 'dropdown-item text-danger' do + = delete_icon + Delete diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 8ad280206..0d134d86c 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -106,9 +106,9 @@ .card-body = render 'scientific_names', crop: @crop = render 'alternate_names', crop: @crop - = render 'plantings', crop: @crop - = render 'harvests', crop: @crop + = render 'plantings', crop: @crop + = render 'harvests', crop: @crop = render 'find_seeds', crop: @crop .card diff --git a/app/views/harvests/show.html.haml b/app/views/harvests/show.html.haml index 002e256eb..82411246f 100644 --- a/app/views/harvests/show.html.haml +++ b/app/views/harvests/show.html.haml @@ -11,7 +11,6 @@ -content_for(:buttonbar) do = render 'harvests/actions', harvest: @harvest - .row .col-md-8 %h1 diff --git a/app/views/members/_location.html.haml b/app/views/members/_location.html.haml index eff2aa6d9..46dec9fac 100644 --- a/app/views/members/_location.html.haml +++ b/app/views/members/_location.html.haml @@ -1,4 +1,4 @@ -.member-location +%span.badge.badge-light.member-location - if member.location.blank? unknown location - else diff --git a/app/views/members/_tiny.haml b/app/views/members/_tiny.haml new file mode 100644 index 000000000..dd7d78fda --- /dev/null +++ b/app/views/members/_tiny.haml @@ -0,0 +1,2 @@ += link_to member do + = image_tag(avatar_uri(member, 50), alt: '', class: 'img img-responsive avatar rounded') \ No newline at end of file diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index 4de268684..97376e1ca 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -40,6 +40,4 @@ %span.badge.badge-pill.badge-secondary Will trade #{seed.tradable_to} .card-footer %span.badge.badge-pill.badge-secondary=seed.owner.location - %p.float-right - = link_to seed.owner do - = image_tag(avatar_uri(seed.owner, 50), alt: '', class: 'img img-responsive avatar rounded') \ No newline at end of file + %p.float-right= render 'members/tiny', member: seed.owner \ No newline at end of file From 5f705c47c530fe7961307e8a1d41bcec005355f5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 09:24:29 +1200 Subject: [PATCH 226/549] garden form name is required --- app/views/gardens/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/gardens/_form.html.haml b/app/views/gardens/_form.html.haml index c3808a48c..e3ec6cf4c 100644 --- a/app/views/gardens/_form.html.haml +++ b/app/views/gardens/_form.html.haml @@ -15,7 +15,7 @@ - @garden.errors.full_messages.each do |msg| %li= msg - = f.text_field :name, maxlength: 255, required: "required" + = f.text_field :name, maxlength: 255, required: true = f.text_area :description, rows: 6 = f.text_field :location, From e9103f500d26b9dd44030ca5a3d287dc52ea517c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 09:24:41 +1200 Subject: [PATCH 227/549] put autosuggest at tooltip level --- app/assets/stylesheets/overrides.scss | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index e9c7aaf6e..7ea4e8f3f 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -349,8 +349,7 @@ html, body { // Autosuggest .ui-autocomplete { background: white; - - //z-index: $zindex-tooltip + z-index: $zindex-tooltip } .alert { From 47fbfa815ae48cae643958aa783273923bf43df8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 09:31:53 +1200 Subject: [PATCH 228/549] More room on gardens form --- app/views/gardens/_form.html.haml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/views/gardens/_form.html.haml b/app/views/gardens/_form.html.haml index e3ec6cf4c..0413078c9 100644 --- a/app/views/gardens/_form.html.haml +++ b/app/views/gardens/_form.html.haml @@ -28,11 +28,10 @@ - else = link_to "Change your location.", edit_member_registration_path .row - .col-md-3.col-12= f.number_field :area, class: 'input-small' - .col-md-3.col-12= f.select(:area_unit, Garden::AREA_UNITS_VALUES, { include_blank: false }) - .col-md-6.col-12= f.select(:garden_type_id, GardenType.all.order(:name).pluck(:name, :id), + .col-md-5.col-12= f.number_field :area, class: 'input-small' + .col-md-7.col-12= f.select(:area_unit, Garden::AREA_UNITS_VALUES, { include_blank: false }) + .col-12= f.select(:garden_type_id, GardenType.all.order(:name).pluck(:name, :id), selected: @garden.garden_type_id) - .row .col-12 = f.check_box :active, label: 'Active?' %p From e3ddf61c4d31fad11c52b566bfb53304f111ea49 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 09:47:28 +1200 Subject: [PATCH 229/549] asterisk for required fields --- app/assets/stylesheets/overrides.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index 7ea4e8f3f..fbd6aab35 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -387,9 +387,9 @@ $state-success-bg: lighten($green, 50%); } } -.form-group.required .control-label:before { - content: "* "; +label.required:after { color: red; + content:" *"; } .margin-bottom { From 9b62d4609bb2bff85bb163b987cb5e514761585d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 10:29:17 +1200 Subject: [PATCH 230/549] added back the plantings quick actions menu --- app/assets/stylesheets/plantings.scss | 21 +++++++-------- app/helpers/buttons_helper.rb | 4 +-- app/views/plantings/_card.html.haml | 38 ++++++++++++++------------- 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/app/assets/stylesheets/plantings.scss b/app/assets/stylesheets/plantings.scss index 7cfe505c2..84d87eaea 100755 --- a/app/assets/stylesheets/plantings.scss +++ b/app/assets/stylesheets/plantings.scss @@ -1,8 +1,8 @@ .planting { - padding: 0.5em; + // padding: 0.5em; .planting-badges { - font-size: 100%; + font-size: 1.5em; position: absolute; top: 3em; @@ -24,8 +24,8 @@ .planting-thumbnail { width: 150px; padding: 0; - margin-bottom: 0.5em; - margin-top: 0.5em; + // margin-bottom: 0.5em; + // margin-top: 0.5em; .badge { font-size: 100%; @@ -37,6 +37,9 @@ font-size: 200%; } } + .progress { + min-height: 25px; + } .planting-name { position: relative; @@ -46,15 +49,9 @@ .planting-quick-actions { position: absolute; - - //Mine top: 0; - left: 130px; - - //Upstream - //left: 142px - //top: 6px - + right: 0; + background-color: $white; } .planting-thumbnail-photo { diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 08be6a654..b94dfbf06 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,9 +1,9 @@ module ButtonsHelper include IconsHelper - def garden_plant_something_button(garden) + def garden_plant_something_button(garden, classes: "btn btn-default") return unless can? :edit, garden - link_to new_planting_path(garden_id: garden.id), class: "btn btn-default" do + link_to new_planting_path(garden_id: garden.id), class: classes do planting_icon + ' ' + t('buttons.plant_something_here') end end diff --git a/app/views/plantings/_card.html.haml b/app/views/plantings/_card.html.haml index b192ffbc7..d3cf7ca9b 100644 --- a/app/views/plantings/_card.html.haml +++ b/app/views/plantings/_card.html.haml @@ -1,23 +1,25 @@ -.card +.card.planting = link_to planting do = image_tag planting_image_path(planting, full_size: true), class: 'img-card', alt: planting + - if can? :edit, planting + .planting-quick-actions + .dropdown + %a.planting-menu.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button"} + .dropdown-menu{"aria-labelledby" => "planting-menu"} + = planting_edit_button(planting, classes: 'dropdown-item') + = add_photo_button(planting, classes: 'dropdown-item') + + - if planting.active? + = planting_finish_button(planting, classes: 'dropdown-item') + = planting_harvest_button(planting, classes: 'dropdown-item') + = planting_save_seeds_button(planting, classes: 'dropdown-item') + + - if can? :destroy, planting + = delete_button(planting, classes: 'dropdown-item') + .card-body.text-center - %h5= link_to planting.crop, planting + %h4= link_to planting.crop, planting .text-center= render 'plantings/badges', planting: planting - if planting.percentage_grown.present? - .card-footer= render 'plantings/progress', planting: planting - -# - if can? :edit, planting - -# .card-footer - -# .dropup - -# %button#dropdownMenuButton.btn.btn-sm.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} - -# .dropdown-menu{"aria-labelledby" => "dropdownMenuButton"} - -# = planting_edit_button(planting) - -# = add_photo_button(planting) - - -# - if planting.active? - -# = planting_finish_button(planting) - -# = planting_harvest_button(planting) - -# = planting_save_seeds_button(planting) - - -# - if can? :destroy, planting - -# = delete_button(planting) \ No newline at end of file + .card-footer + = render 'plantings/progress', planting: planting \ No newline at end of file From 51133359fb39ba5bd36e888115adc84177392822 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 10:29:52 +1200 Subject: [PATCH 231/549] tidy --- app/views/gardens/_form.html.haml | 7 +++---- app/views/gardens/index.html.haml | 7 +++++-- app/views/harvests/_card.html.haml | 3 ++- app/views/harvests/_form.html.haml | 4 ++-- app/views/plantings/_form.html.haml | 3 +-- app/views/plantings/_progress.html.haml | 2 +- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/views/gardens/_form.html.haml b/app/views/gardens/_form.html.haml index 0413078c9..9a7a29564 100644 --- a/app/views/gardens/_form.html.haml +++ b/app/views/gardens/_form.html.haml @@ -7,17 +7,16 @@ .card-body = required_field_help_text - if @garden.errors.any? - #error_explanation - %h2 + #error_explanation.alert.alert-warning{:role => "alert"} + %h4.alert-heading = pluralize(@garden.errors.size, "error") - prohibited this garden from being saved: + prohibited this garden from being saved %ul - @garden.errors.full_messages.each do |msg| %li= msg = f.text_field :name, maxlength: 255, required: true = f.text_area :description, rows: 6 - = f.text_field :location, value: @garden.location || current_member.location, class: 'form-control', maxlength: 255 diff --git a/app/views/gardens/index.html.haml b/app/views/gardens/index.html.haml index a85d577f2..97d140a65 100644 --- a/app/views/gardens/index.html.haml +++ b/app/views/gardens/index.html.haml @@ -28,8 +28,11 @@ = pluralize(garden.plantings.active.size, "planting") .col-md-10 .row - - garden.plantings.active.each do |planting| - .col-6.col-md-2= render 'plantings/card', planting: planting + - if garden.plantings.empty? + = garden_plant_something_button(garden, classes: 'btn btn-success') + - else + - garden.plantings.active.each do |planting| + .col-6.col-md-4.col-lg-3= render 'plantings/card', planting: planting .pagination diff --git a/app/views/harvests/_card.html.haml b/app/views/harvests/_card.html.haml index 7ab8e7b10..3aab4170f 100644 --- a/app/views/harvests/_card.html.haml +++ b/app/views/harvests/_card.html.haml @@ -10,4 +10,5 @@ %p.card-text %small.text-muted Harvested from - = link_to harvest.planting, harvest.planting \ No newline at end of file + = link_to harvest.planting, harvest.planting + .float-right=render 'members/tiny', member: harvest.owner \ No newline at end of file diff --git a/app/views/harvests/_form.html.haml b/app/views/harvests/_form.html.haml index 36afa5629..4051c7460 100644 --- a/app/views/harvests/_form.html.haml +++ b/app/views/harvests/_form.html.haml @@ -16,8 +16,8 @@ %li= msg .row - .col-md-8 - = f.label :crop, 'What did you harvest?' + .col-12 + = f.label :crop, 'What did you harvest?', class: 'required' - if @planting = link_to @planting.crop.name, planting_path(@planting) from diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml index 3edf4a61c..f0651ec29 100644 --- a/app/views/plantings/_form.html.haml +++ b/app/views/plantings/_form.html.haml @@ -5,7 +5,6 @@ %strong=yield :title = bootstrap_form_for(@planting) do |f| .card-body - - if @planting.errors.any? #error_explanation %h2 @@ -15,7 +14,7 @@ - @planting.errors.full_messages.each do |msg| %li= msg - = f.label :crop, 'What did you plant?' + = f.label :crop, 'What did you plant?', class: 'required' - if @seed.present? = link_to @seed, seed_path(@seed) = f.hidden_field :parent_seed_id, value: @seed.id diff --git a/app/views/plantings/_progress.html.haml b/app/views/plantings/_progress.html.haml index 76146c6a6..acb1804a2 100644 --- a/app/views/plantings/_progress.html.haml +++ b/app/views/plantings/_progress.html.haml @@ -1,6 +1,6 @@ - if planting.percentage_grown.present? .progress - .progress-bar.bg-success{"aria-valuemax" => "100", "aria-valuemin" => "0", "aria-valuenow" => planting.percentage_grown, :role => "progressbar", :style => "width: #{planting.percentage_grown}%"} + .progress-bar.bg-success{"aria-valuemax" => "100", "aria-valuemin" => "0", "aria-valuenow" => planting.percentage_grown, :role => "progressbar", :style => "width: #{planting.percentage_grown}%; height: 25px"} .float-left #{sprintf '%.0f', planting.percentage_grown}% From fae315523770667e435be374fdf2ac8382f00ba6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 14:57:11 +1200 Subject: [PATCH 232/549] match to spec --- app/views/layouts/application.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index e7b911db8..857ddeacc 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -19,7 +19,7 @@ = yield(:breadcrumbs) - if content_for?(:buttonbar) - .float-right= yield(:buttonbar) + .layout-actions.float-right= yield(:buttonbar) - if content_for?(:subtitle) %small= yield(:subtitle) From d2c062a3f1dd6133fdd542e93c5d504e9e27c8ef Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 14:57:29 +1200 Subject: [PATCH 233/549] garden actions --- app/views/gardens/_actions.html.haml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index 0d28c1092..cb702e961 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -1,16 +1,16 @@ - if can?(:edit, garden) - .dropdown.float-right.garden-actions - %a#garden-actions-button.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} + .dropdown.garden-actions + %button#garden-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "garden-actions-button"} - if can?(:edit, garden) - .dropdown-item= garden_plant_something_button(garden) if garden.active + .dropdown-item= garden_plant_something_button(garden, classes: 'dropdown-item') if garden.active - if garden.active - .dropdown-item= garden_mark_inactive_button(garden) + .dropdown-item= garden_mark_inactive_button(garden, classes: 'dropdown-item') - else - .dropdown-item= garden_mark_active_button(garden) + .dropdown-item= garden_mark_active_button(garden, classes: 'dropdown-item') - .dropdown-item= garden_edit_button(garden) - .dropdown-item= add_photo_button(garden) + .dropdown-item= garden_edit_button(garden, classes: 'dropdown-item') + .dropdown-item= add_photo_button(garden, classes: 'dropdown-item') - if can?(:destroy, garden) .dropdown-item= delete_button(garden, message: 'All plantings associated with this garden will also be deleted. Are you sure?') From 532699a1ec0f4f0b5517bd0c68db72a055ab7f5d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 15:38:18 +1200 Subject: [PATCH 234/549] menu on the left, works better on mobile --- app/assets/stylesheets/plantings.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/plantings.scss b/app/assets/stylesheets/plantings.scss index 84d87eaea..3688a8130 100755 --- a/app/assets/stylesheets/plantings.scss +++ b/app/assets/stylesheets/plantings.scss @@ -50,7 +50,7 @@ .planting-quick-actions { position: absolute; top: 0; - right: 0; + left: 0; background-color: $white; } From 9b8638a3b6bf4c8c74894deb252c8ed59bf84443 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 15:38:27 +1200 Subject: [PATCH 235/549] tests for plantings.active scope --- spec/models/planting_spec.rb | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb index c128c0e6e..8401d4cc7 100644 --- a/spec/models/planting_spec.rb +++ b/spec/models/planting_spec.rb @@ -488,13 +488,15 @@ describe Planting do end end - # it 'predicts harvest times' do - # crop = FactoryBot.create :crop - # 10.times do - # planting = FactoryBot.create :planting, crop: crop, planted_at: Time.zone.local(2013, 1, 1) - # FactoryBot.create :harvest, crop: crop, planting: planting, harvested_at: Time.zone.local(2013, 2, 1) - # end - # planting = FactoryBot.create :planting, planted_at: Time.zone.local(2017, 1, 1), crop: crop - # expect(planting.harvest_predicted_at).to eq Time.zone.local(2017, 2, 1) - # end + describe 'active scope' do + let(:member) { FactoryBot.create :member } + let!(:planting) do + FactoryBot.create :planting, owner: member, garden: member.gardens.first + end + let!(:finished_planting) do + FactoryBot.create :finished_planting, owner: member, garden: member.gardens.first + end + it { expect(member.plantings.active).to include(planting) } + it { expect(member.plantings.active).not_to include(finished_planting) } + end end From 8d3e080afbd78d8c576d50d7c17e522947d4bad8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 15:38:39 +1200 Subject: [PATCH 236/549] classes for gardens button --- app/helpers/buttons_helper.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index b94dfbf06..bc6da29f9 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -16,16 +16,16 @@ module ButtonsHelper end end - def garden_mark_active_button(garden) + def garden_mark_active_button(garden, classes: 'btn') link_to t('buttons.mark_as_active'), garden_path(garden, garden: { active: 1 }), - method: :put, class: 'btn' + method: :put, class: classes end - def garden_mark_inactive_button(garden) + def garden_mark_inactive_button(garden, classes: 'btn') link_to t('buttons.mark_as_inactive'), garden_path(garden, garden: { active: 0 }), - method: :put, class: 'btn', + method: :put, class: classes, data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } end @@ -57,8 +57,8 @@ module ButtonsHelper edit_button(edit_harvest_path(harvest)) end - def garden_edit_button(garden) - edit_button(edit_garden_path(garden)) + def garden_edit_button(garden, classes: "btn btn-raised btn-info") + edit_button(edit_garden_path(garden), classes: classes) end def planting_edit_button(planting, classes: "btn btn-raised btn-info") From eb628635e2bcc0008683b4546e7141327721a9c2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 15:39:14 +1200 Subject: [PATCH 237/549] fix logic on planting.active --- app/models/planting.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/planting.rb b/app/models/planting.rb index fc5ab3b36..e57bf6fb0 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -33,7 +33,7 @@ class Planting < ApplicationRecord ## ## Scopes default_scope { joins(:owner) } # Ensures the owner still exists - scope :active, -> { where('finished <> true OR finished_at < ?', Time.zone.now) } + scope :active, -> { where('finished <> true').where('finished_at IS NULL OR finished_at < ?', Time.zone.now) } scope :interesting, -> { has_photos.one_per_owner.order(planted_at: :desc) } scope :recent, -> { order(created_at: :desc) } scope :one_per_owner, lambda { From f4457f877fe041e502e59d0a78e447383efc42ee Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 16:02:06 +1200 Subject: [PATCH 238/549] fixing planting specs --- spec/features/plantings/planting_a_crop_spec.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index c53671521..4508d5b8d 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -21,14 +21,14 @@ describe "Planting a crop", :js, :elasticsearch do end describe "displays required and optional fields properly" do - it { expect(page).to have_selector ".form-group.required", text: "What did you plant?" } - it { expect(page).to have_selector ".form-group.required", text: "Where did you plant it?" } - it { expect(page).to have_optional 'input#planting_planted_at' } - it { expect(page).to have_optional 'input#planting_quantity' } - it { expect(page).to have_optional 'select#planting_planted_from' } - it { expect(page).to have_optional 'select#planting_sunniness' } - it { expect(page).to have_optional 'textarea#planting_description' } - it { expect(page).to have_optional 'input#planting_finished_at' } + it { expect(page).to have_selector ".required", text: "What did you plant?" } + it { expect(page).to have_selector ".required", text: "Where did you plant it?" } + it { expect(page).to have_selector 'input#planting_planted_at' } + it { expect(page).to have_selector 'input#planting_quantity' } + it { expect(page).to have_selector 'select#planting_planted_from' } + it { expect(page).to have_selector 'select#planting_sunniness' } + it { expect(page).to have_selector 'textarea#planting_description' } + it { expect(page).to have_selector 'input#planting_finished_at' } end describe "Creating a new planting" do From 1526cea92ae63c140ae43dd9336f2fbac3a07c7b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 16:02:19 +1200 Subject: [PATCH 239/549] required explanation test on plantings form --- app/views/plantings/_form.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml index f0651ec29..cf84ed719 100644 --- a/app/views/plantings/_form.html.haml +++ b/app/views/plantings/_form.html.haml @@ -5,6 +5,7 @@ %strong=yield :title = bootstrap_form_for(@planting) do |f| .card-body + = required_field_help_text - if @planting.errors.any? #error_explanation %h2 From 628a7e3ae1413c5f44e3e6837a6c6be65b73d8b5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 17:02:59 +1200 Subject: [PATCH 240/549] Fix planting specs --- app/views/plantings/_actions.html.haml | 2 +- app/views/plantings/_form.html.haml | 9 ++++-- .../plantings/planting_a_crop_spec.rb | 32 +++++++++++++------ spec/features/shared_examples/append_date.rb | 2 ++ spec/features/shared_examples/crop_suggest.rb | 1 + 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/app/views/plantings/_actions.html.haml b/app/views/plantings/_actions.html.haml index e24b982b0..f69b900b9 100644 --- a/app/views/plantings/_actions.html.haml +++ b/app/views/plantings/_actions.html.haml @@ -1,6 +1,6 @@ - if can?(:edit, planting) .dropdown.float-right.planting-actions - %a#planting-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions + %a#planting-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button", href: '#'} Actions .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "planting-actions-button"} = planting_edit_button(planting, classes: 'dropdown-item') = add_photo_button(planting, classes: 'dropdown-item') diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml index cf84ed719..bfbbf3dd2 100644 --- a/app/views/plantings/_form.html.haml +++ b/app/views/plantings/_form.html.haml @@ -39,9 +39,12 @@ class: 'add-datepicker', label: 'When?' .row - .col-md-4= f.select(:planted_from, Planting::PLANTED_FROM_VALUES, { include_blank: '' }, label: 'Planted from') - .col-md-4= f.select(:sunniness, Planting::SUNNINESS_VALUES, { include_blank: '' }, label: 'Sun or shade?') - .col-md-4= f.number_field :quantity, label: 'How many?' + .col-md-4 + = f.select(:planted_from, Planting::PLANTED_FROM_VALUES, { include_blank: '', label: 'Planted from' } ) + .col-md-4 + = f.select(:sunniness, Planting::SUNNINESS_VALUES, { include_blank: '', label: 'Sun or shade?' } ) + .col-md-4 + = f.number_field :quantity, label: 'How many?' = f.text_area :description, rows: 6, label: 'Tell us more about it' .row diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 4508d5b8d..28a6be9cc 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -36,11 +36,12 @@ describe "Planting a crop", :js, :elasticsearch do fill_autocomplete "crop", with: "mai" select_from_autocomplete "maize" within "form#new_planting" do - fill_in "When", with: "2014-06-15" fill_in "How many?", with: 42 - select "cutting", from: "Planted from:" + select "cutting", from: "Planted from" select "semi-shade", from: "Sun or shade?" fill_in "Tell us more about it", with: "It's rad." + choose 'Garden' + fill_in "When", with: "2014-06-15" click_button "Save" end end @@ -70,9 +71,10 @@ describe "Planting a crop", :js, :elasticsearch do fill_autocomplete "crop", with: "mai" select_from_autocomplete "maize" within "form#new_planting" do + choose 'Garden' fill_in "When", with: @a_future_date fill_in "How many?", with: 42 - select "cutting", from: "Planted from:" + select "cutting", from: "Planted from" select "semi-shade", from: "Sun or shade?" fill_in "Tell us more about it", with: "It's rad." click_button "Save" @@ -86,9 +88,10 @@ describe "Planting a crop", :js, :elasticsearch do fill_autocomplete "crop", with: "mai" select_from_autocomplete "maize" within "form#new_planting" do + choose 'Garden' fill_in "When", with: @a_past_date fill_in "How many?", with: 42 - select "cutting", from: "Planted from:" + select "cutting", from: "Planted from" select "semi-shade", from: "Sun or shade?" fill_in "Tell us more about it", with: "It's rad." click_button "Save" @@ -103,9 +106,10 @@ describe "Planting a crop", :js, :elasticsearch do fill_autocomplete "crop", with: "mai" select_from_autocomplete "maize" within "form#new_planting" do + choose 'Garden' fill_in "When", with: @right_now fill_in "How many?", with: 42 - select "cutting", from: "Planted from:" + select "cutting", from: "Planted from" select "semi-shade", from: "Sun or shade?" fill_in "When?", with: '2013-03-10' fill_in "Tell us more about it", with: "It's rad." @@ -123,9 +127,10 @@ describe "Planting a crop", :js, :elasticsearch do fill_autocomplete "crop", with: "mai" select_from_autocomplete "maize" within "form#new_planting" do + choose 'Garden' fill_in "When", with: @right_now fill_in "How many?", with: 42 - select "cutting", from: "Planted from:" + select "cutting", from: "Planted from" select "semi-shade", from: "Sun or shade?" fill_in "Tell us more about it", with: "It's rad." check "Mark as finished" @@ -140,10 +145,12 @@ describe "Planting a crop", :js, :elasticsearch do fill_autocomplete "crop", with: "mai" select_from_autocomplete "maize" within "form#new_planting" do + choose 'Garden' fill_in "When", with: @a_past_date fill_in "How many?", with: 42 - select "cutting", from: "Planted from:" + select "cutting", from: "Planted from" select "semi-shade", from: "Sun or shade?" + choose 'Garden' fill_in "Tell us more about it", with: "It's rad." fill_in "Finished date", with: @right_now click_button "Save" @@ -161,15 +168,18 @@ describe "Planting a crop", :js, :elasticsearch do end within "form#new_planting" do expect(page).to have_selector "input[value='maize']" - click_button "Save" end + choose(member.gardens.first.name) + click_button "Save" + expect(page).to have_content "planting was successfully created" expect(page).to have_content "maize" end it "Editing a planting to add details" do visit planting_path(planting) + click_link 'Actions' click_link "Edit" fill_in "Tell us more about it", with: "Some extra notes" click_button "Save" @@ -179,6 +189,8 @@ describe "Planting a crop", :js, :elasticsearch do it "Editing a planting to fill in the finished date" do visit planting_path(planting) expect(page).not_to have_content "Finishes" + # click_link(id: 'planting-actions-button') + click_link 'Actions' click_link "Edit" check "finished" fill_in "Finished date", with: "2015-06-25" @@ -190,6 +202,7 @@ describe "Planting a crop", :js, :elasticsearch do it "Marking a planting as finished" do fill_autocomplete "crop", with: "mai" select_from_autocomplete "maize" + choose(member.gardens.first.name) within "form#new_planting" do fill_in "When?", with: "2014-07-01" check "Mark as finished" @@ -234,6 +247,7 @@ describe "Planting a crop", :js, :elasticsearch do fill_autocomplete "crop", with: "mai" select_from_autocomplete "maize" within "form#new_planting" do + choose member.gardens.first.name check "Mark as finished" click_button "Save" end @@ -250,7 +264,7 @@ describe "Planting a crop", :js, :elasticsearch do within "form#new_planting" do fill_in "When", with: "2015-10-15" fill_in "How many?", with: 42 - select "cutting", from: "Planted from:" + select "cutting", from: "Planted from" select "sun", from: "Sun or shade?" fill_in "Tell us more about it", with: "It's rad." check "Mark as finished" diff --git a/spec/features/shared_examples/append_date.rb b/spec/features/shared_examples/append_date.rb index d1580816e..6f6247736 100644 --- a/spec/features/shared_examples/append_date.rb +++ b/spec/features/shared_examples/append_date.rb @@ -6,6 +6,7 @@ shared_examples "append date" do describe "Selecting a date with datepicker" do before do + click_link 'Actions' click_link link_text within "div.datepicker" do expect(page).to have_content this_month.to_s @@ -18,6 +19,7 @@ shared_examples "append date" do describe "Confirming without selecting date" do before do + click_link 'Actions' click_link link_text click_link "Confirm without date" end diff --git a/spec/features/shared_examples/crop_suggest.rb b/spec/features/shared_examples/crop_suggest.rb index b7e49dbd8..2cbcf076e 100644 --- a/spec/features/shared_examples/crop_suggest.rb +++ b/spec/features/shared_examples/crop_suggest.rb @@ -63,6 +63,7 @@ shared_examples "crop suggest" do |resource| scenario "Submitting a crop that doesn't exist in the database produces a meaningful error" do within "form#new_#{resource}" do fill_autocomplete "crop", with: "Ryan Gosling" + choose('Garden') click_button "Save" end From 977ff7d174078f49696e5c50e48177360e29d79e Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Sat, 8 Jun 2019 05:20:29 +0000 Subject: [PATCH 241/549] [CodeFactor] Apply fixes --- spec/models/planting_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb index 8401d4cc7..32d3da008 100644 --- a/spec/models/planting_spec.rb +++ b/spec/models/planting_spec.rb @@ -180,9 +180,9 @@ describe Planting do before do FactoryBot.create(:harvest, - planting: planting, - crop: planting.crop, - harvested_at: 10.days.ago) + planting: planting, + crop: planting.crop, + harvested_at: 10.days.ago) planting.update_harvest_days! planting.crop.update_harvest_medians end @@ -402,9 +402,9 @@ describe Planting do # this one is newer, and has the same owner, through the garden @planting2 = FactoryBot.create(:planting, - created_at: 1.minute.ago, - garden: @planting1.garden, - owner: @planting1.owner) + created_at: 1.minute.ago, + garden: @planting1.garden, + owner: @planting1.owner) @planting2.photos << FactoryBot.create(:photo, owner: @planting2.owner) @planting2.save From 3d11dac718e402f28403ab0708ce93144b5d6e7f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 18:21:15 +1200 Subject: [PATCH 242/549] Fixing harvest specs --- app/controllers/plantings_controller.rb | 5 ++- app/views/harvests/_form.html.haml | 2 +- .../features/harvests/browse_harvests_spec.rb | 4 --- .../harvests/harvesting_a_crop_spec.rb | 34 ++++++------------- spec/features/shared_examples/crop_suggest.rb | 1 - 5 files changed, 15 insertions(+), 31 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 06545c0e1..aa5ff9f45 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -41,7 +41,10 @@ class PlantingsController < ApplicationController end def new - @planting = Planting.new(planted_at: Time.zone.today, owner: current_member) + @planting = Planting.new( + planted_at: Time.zone.today, + owner: current_member, + garden: current_member.gardens.first) @seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id] # using find_by_id here because it returns nil, unlike find diff --git a/app/views/harvests/_form.html.haml b/app/views/harvests/_form.html.haml index 4051c7460..aa6b56e09 100644 --- a/app/views/harvests/_form.html.haml +++ b/app/views/harvests/_form.html.haml @@ -49,7 +49,7 @@ = f.select(:unit, Harvest::UNITS_VALUES, { include_blank: false }, class: 'input-medium form-control') .row .col-md-4 - = f.number_field :weight_quantity, class: 'input-small form-control', step: 'any' + = f.number_field :weight_quantity, class: 'input-small form-control', step: 'any', label: 'Weighing (in total)' .col-md-8 = f.select(:weight_unit, Harvest::WEIGHT_UNITS_VALUES, { include_blank: false }, class: 'form-control') = f.text_area :description, rows: 6, label: 'Notes' diff --git a/spec/features/harvests/browse_harvests_spec.rb b/spec/features/harvests/browse_harvests_spec.rb index 1f05c5a34..67dc75e55 100644 --- a/spec/features/harvests/browse_harvests_spec.rb +++ b/spec/features/harvests/browse_harvests_spec.rb @@ -25,10 +25,6 @@ describe "browse harvests" do visit harvests_path end - it 'read more' do - expect(subject).to have_link "Read more" - end - it 'links to #show' do expect(subject).to have_link harvest.crop.name, href: harvest_path(harvest) end diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index 171d54e0b..1a9fa0c24 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -19,10 +19,10 @@ describe "Harvesting a crop", :js, :elasticsearch do end describe "displays required and optional fields properly" do - it { expect(page).to have_selector ".form-group.required", text: "What did you harvest?" } - it { expect(page).to have_optional 'input#harvest_quantity' } - it { expect(page).to have_optional 'input#harvest_weight_quantity' } - it { expect(page).to have_optional 'textarea#harvest_description' } + it { expect(page).to have_selector ".required", text: "What did you harvest?" } + it { expect(page).to have_selector 'input#harvest_quantity' } + it { expect(page).to have_selector 'input#harvest_weight_quantity' } + it { expect(page).to have_selector 'textarea#harvest_description' } end it "Creating a new harvest", :js do @@ -30,10 +30,10 @@ describe "Harvesting a crop", :js, :elasticsearch do select_from_autocomplete "maize" within "form#new_harvest" do - select plant_part.name, from: 'harvest[plant_part_id]' + choose plant_part.name fill_in "When?", with: "2014-06-15" fill_in "How many?", with: 42 - fill_in "Weighing (in total):", with: 42 + fill_in "Weighing (in total)", with: 42 fill_in "Notes", with: "It's killer." click_button "Save" end @@ -41,20 +41,6 @@ describe "Harvesting a crop", :js, :elasticsearch do expect(page).to have_content "harvest was successfully created." end - context "Clicking edit from the index page" do - let!(:harvest) { create :harvest, crop: maize, owner: member } - - before do - visit harvests_path - end - - it "button on index to edit harvest" do - click_link "edit_harvest_glyphicon" - expect(current_path).to eq edit_harvest_path(harvest) - expect(page).to have_content 'Editing harvest' - end - end - it "Clicking link to owner's profile" do visit member_harvests_path(member) click_link "View #{member}'s profile >>" @@ -68,7 +54,7 @@ describe "Harvesting a crop", :js, :elasticsearch do click_link "Harvest #{maize.name}" end within "form#new_harvest" do - select plant_part.name, from: 'harvest[plant_part_id]' + choose plant_part.name expect(page).to have_selector "input[value='maize']" click_button "Save" end @@ -83,10 +69,10 @@ describe "Harvesting a crop", :js, :elasticsearch do before do visit planting_path(planting) within ".planting-actions" do - click_link "Harvest" + click_button "Record Harvest" end - select plant_part.name, from: 'harvest[plant_part_id]' + choose plant_part.name click_button "Save" end @@ -113,7 +99,7 @@ describe "Harvesting a crop", :js, :elasticsearch do end it "change plant part" do - select other_plant_part.name, from: 'harvest[plant_part_id]' + choose other_plant_part.name click_button "Save" expect(page).to have_content "harvest was successfully updated." expect(page).to have_content other_plant_part.name diff --git a/spec/features/shared_examples/crop_suggest.rb b/spec/features/shared_examples/crop_suggest.rb index 2cbcf076e..b7e49dbd8 100644 --- a/spec/features/shared_examples/crop_suggest.rb +++ b/spec/features/shared_examples/crop_suggest.rb @@ -63,7 +63,6 @@ shared_examples "crop suggest" do |resource| scenario "Submitting a crop that doesn't exist in the database produces a meaningful error" do within "form#new_#{resource}" do fill_autocomplete "crop", with: "Ryan Gosling" - choose('Garden') click_button "Save" end From 0c4b9a800e79af9ae02e1a8ad0d8b404b77fc3a0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 9 Jun 2019 09:53:31 +1200 Subject: [PATCH 243/549] Use our own index-cards class for card layout instead of bootstrap grid --- app/assets/stylesheets/harvests.scss | 10 ---------- app/assets/stylesheets/members.scss | 11 ----------- app/assets/stylesheets/overrides.scss | 13 ++++++++++++- app/assets/stylesheets/plantings.scss | 6 ------ app/assets/stylesheets/seeds.scss | 10 ---------- app/views/harvests/index.html.haml | 5 +---- app/views/members/index.html.haml | 2 +- app/views/plantings/index.html.haml | 4 +--- app/views/seeds/index.html.haml | 2 +- 9 files changed, 16 insertions(+), 47 deletions(-) diff --git a/app/assets/stylesheets/harvests.scss b/app/assets/stylesheets/harvests.scss index 5ce20fa07..e69de29bb 100644 --- a/app/assets/stylesheets/harvests.scss +++ b/app/assets/stylesheets/harvests.scss @@ -1,10 +0,0 @@ -.harvest-cards { - display: flex; - flex: none; - flex-wrap: wrap; - - .card { - width: 200px; - margin: 1em; - } -} diff --git a/app/assets/stylesheets/members.scss b/app/assets/stylesheets/members.scss index 5e8d3b09d..9cb92bee8 100644 --- a/app/assets/stylesheets/members.scss +++ b/app/assets/stylesheets/members.scss @@ -1,14 +1,3 @@ -.member-cards { - display: flex; - flex: none; - flex-wrap: wrap; - - .card { - width: 150px; - margin: 1em; - } -} - .member-thumbnail { padding: 0.25em; margin: 1em; diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index fbd6aab35..a5339c4a8 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -64,6 +64,17 @@ h3 { // -webkit-box-shadow: none // box-shadow: none +.index-cards { + display: flex; + flex: none; + flex-wrap: wrap; + + .card { + width: 200px; + margin: 1em; + } +} + .img-square { object-fit: cover; height: 150px; @@ -72,7 +83,7 @@ h3 { .img-card { object-fit: cover; - height: 200px; + height: 180px; width: 100%; } diff --git a/app/assets/stylesheets/plantings.scss b/app/assets/stylesheets/plantings.scss index 3688a8130..e5cdf2885 100755 --- a/app/assets/stylesheets/plantings.scss +++ b/app/assets/stylesheets/plantings.scss @@ -13,12 +13,6 @@ .badge-harvest { background-color: $blue; } - - .planting-super-late {} - - .planting-late { - background-color: $beige; - } } .planting-thumbnail { diff --git a/app/assets/stylesheets/seeds.scss b/app/assets/stylesheets/seeds.scss index f5a75bc6f..e69de29bb 100644 --- a/app/assets/stylesheets/seeds.scss +++ b/app/assets/stylesheets/seeds.scss @@ -1,10 +0,0 @@ -.seed-cards { - display: flex; - flex: none; - flex-wrap: wrap; - - .card { - max-width: 250px; - margin: 1em; - } -} diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index e00ffb151..1b2fb4645 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -23,10 +23,7 @@ = will_paginate @harvests - unless @harvests.empty? - .harvest-cards - .row - - @harvests.each do |harvest| - .col-6.col-md-3= render harvest, full: true + .index-cards=render @harvests, full: true .pagination = page_entries_info @harvests diff --git a/app/views/members/index.html.haml b/app/views/members/index.html.haml index ad9af58af..64d85cfb7 100644 --- a/app/views/members/index.html.haml +++ b/app/views/members/index.html.haml @@ -14,7 +14,7 @@ = page_entries_info @members = will_paginate @members -.member-cards= render @members +.index-cards= render @members .pagination = page_entries_info @members diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index 6787f86a3..a16ff6c2e 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -20,9 +20,7 @@ = page_entries_info @plantings = render 'layouts/pagination', collection: @plantings -.row - - @plantings.each do |planting| - .col-6.col-md-2= render 'plantings/card', planting: planting +.index-cards= render @plantings, full: true .pagination = page_entries_info @plantings diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index 38f7f44e5..5daf7f89d 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -21,7 +21,7 @@ = will_paginate @seeds - unless @seeds.empty? - .seed-cards= render @seeds, full: true + .index-cards= render @seeds, full: true .pagination = page_entries_info @seeds From 5c5abcde30f9302384acf2782b0f152577facb1c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 9 Jun 2019 09:53:46 +1200 Subject: [PATCH 244/549] fix up titles --- app/views/plantings/index.html.haml | 5 ++++- app/views/seeds/index.html.haml | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index a16ff6c2e..fda4224db 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -1,4 +1,7 @@ -%h1=title('plantings', @owner, @crop, @planting) +- content_for :title, title('plantings', @owner, @crop, @planting) +%h1 + = planting_icon + =title('plantings', @owner, @crop, @planting) = render 'layouts/nav', model: Planting diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index 5daf7f89d..44f1b9b9c 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -1,4 +1,7 @@ -%h1= title('seeds', @owner, @crop, @planting) +- content_for :title, title('seeds', @owner, @crop, @planting) +%h1 + = seed_icon + = title('seeds', @owner, @crop, @planting) - if @owner = link_to "View #{@owner}'s profile >>", member_path(@owner) From 0cbc224298b897293579ecf14a6040f4831f64d0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 9 Jun 2019 09:53:56 +1200 Subject: [PATCH 245/549] remove commented out code --- app/views/seeds/_card.html.haml | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index 97376e1ca..d77f9e816 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -1,36 +1,3 @@ --# .panel.panel-success --# .panel-heading --# %h3.panel-title --# = link_to seed, seed --# - if can? :edit, seed --# %a.text-right{ href: edit_seed_path(seed), role: "button", id: "edit_seed_glyphicon" } --# %span.glyphicon.glyphicon-pencil{ title: "Edit" } --# .panel-body --# .row --# .col-md-4 --# = link_to image_tag(seed_image_path(seed), --# alt: seed.crop.name, class: 'img'), --# seed.crop --# .col-md-8 --# %dl.dl-horizontal --# %dt Crop : --# %dd= link_to seed.crop.name, seed.crop --# - if seed.parent_planting.present? --# %dt Saved from --# %dd= link_to seed.parent_planting, planting_path(seed.parent_planting) --# %dt Plant before : --# %dd= seed.plant_before --# %dt Quantity : --# %dd= seed.quantity --# %dt Will trade to : --# %dd= seed.tradable_to --# %dt From location : --# %dd= seed.owner.location --# %dt Owner : --# %dd= link_to seed.owner.login_name, seed.owner --# .col-md-12 --# %p= render 'seeds/actions', seed: seed - .card.seed-card = link_to seed do = image_tag(seed_image_path(seed, full_size: true), alt: seed, class: 'img-card') From 4fd24e61d9e005e3ad35c988d7639f9082c61708 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 9 Jun 2019 09:54:09 +1200 Subject: [PATCH 246/549] harvest own on card --- app/views/harvests/_card.html.haml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/harvests/_card.html.haml b/app/views/harvests/_card.html.haml index 3aab4170f..2cb4ff07b 100644 --- a/app/views/harvests/_card.html.haml +++ b/app/views/harvests/_card.html.haml @@ -11,4 +11,7 @@ %small.text-muted Harvested from = link_to harvest.planting, harvest.planting + .card-footer + %p + .float-left= link_to harvest.owner, harvest.owner .float-right=render 'members/tiny', member: harvest.owner \ No newline at end of file From c7ae520d66ec6d88ffc68970e17a6ebb34dd7c05 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 9 Jun 2019 09:54:28 +1200 Subject: [PATCH 247/549] add missing translation for "Record Harvest" --- config/locales/en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 5c3514fe7..9c030450a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -87,6 +87,7 @@ en: plant: Plant plant_crop: Plant %{crop_name} plant_something_here: Plant something here + record_harvest: Record Harvest save_seeds: Save seeds write_blog_post: Write blog post crops: From cf3068dc0818389dd6d28623d2eb6d52a074bb8c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 9 Jun 2019 10:05:31 +1200 Subject: [PATCH 248/549] card display on small screens --- app/assets/stylesheets/overrides.scss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index a5339c4a8..8721378ec 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -518,4 +518,10 @@ ul.thumbnail-buttons { width: 50px; } } + .index-cards { + .card { + width: 100%; + margin: 0.5em; + } + } } From 5957309dea07329ac2e28cfd1f072ad2b593c033 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 9 Jun 2019 10:16:34 +1200 Subject: [PATCH 249/549] Update harvest spec --- spec/features/harvests/harvesting_a_crop_spec.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index 1a9fa0c24..e91f84c81 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -68,9 +68,7 @@ describe "Harvesting a crop", :js, :elasticsearch do let!(:planting) { create :planting, crop: maize, owner: member, garden: member.gardens.first } before do visit planting_path(planting) - within ".planting-actions" do - click_button "Record Harvest" - end + click_link "Record Harvest" choose plant_part.name click_button "Save" From 4255cde5ff4240d3ab73bb86134fa509233155f6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 9 Jun 2019 13:24:05 +1200 Subject: [PATCH 250/549] member cards on home page fix up --- app/assets/stylesheets/homepage.scss | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/homepage.scss b/app/assets/stylesheets/homepage.scss index a697ce6ca..1c2af5b5a 100644 --- a/app/assets/stylesheets/homepage.scss +++ b/app/assets/stylesheets/homepage.scss @@ -19,7 +19,7 @@ text-align: center; } -.homepage-cards, .homepage-thumbnails { +.homepage-cards { display: flex; flex: none; flex-wrap: wrap; @@ -50,6 +50,18 @@ } +.member-cards { + display: flex; + flex: none; + flex-wrap: wrap; + + .card { + width: 150px; + margin: 1em; + } +} + + @include media-breakpoint-down(sm) { .homepage-cards { .seed-card { From 2fa4590315707fa2cc7eadca9505264d2e9a1ec0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 9 Jun 2019 14:02:05 +1200 Subject: [PATCH 251/549] gardens breadcrumbs --- app/views/gardens/index.html.haml | 10 ++++++++++ app/views/gardens/show.html.haml | 21 ++++++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/app/views/gardens/index.html.haml b/app/views/gardens/index.html.haml index 97d140a65..19d3210e6 100644 --- a/app/views/gardens/index.html.haml +++ b/app/views/gardens/index.html.haml @@ -3,8 +3,18 @@ %h1 = @owner ? "#{@owner}'s gardens" : "Everyone's gardens" + = render 'layouts/nav', model: Garden +- content_for :breadcrumbs do + - if @owner + %li.breadcrumb-item= link_to 'Gardens', gardens_path + %li.breadcrumb-item.active= link_to "#{@owner}'s gardens", gardens_path(owner: @owner) + - else + %li.breadcrumb-item.active= link_to 'Gardens', gardens_path + + + = link_to gardens_active_tickbox_path(@owner, @show_all) do = check_box_tag 'active', 'all', @show_all include in-active diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index 009c8490d..cc97c141f 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -14,6 +14,11 @@ = javascript_include_tag "charts" = javascript_include_tag "https://www.gstatic.com/charts/loader.js" + +- content_for :breadcrumbs do + %li.breadcrumb-item= link_to 'Gardens', gardens_path + %li.breadcrumb-item.active= link_to @garden.name, gardens_path(@garden) + .row .col-md-9.col-sm-12 %h2.h1 @@ -43,27 +48,25 @@ .row .col-md-12 - %section.card - .card-header - %h3 Garden timeline - .card-body= timeline garden_timeline_path(@garden), adapter: "google" + %section + %h3 Garden timeline + = timeline garden_timeline_path(@garden), adapter: "google" %section %h3.h3 Current plantings in garden - .row + .index-cards - if @current_plantings.size.positive? - @current_plantings.each do |planting| - .col-xs-12.col-3= render "plantings/card", planting: planting + = render "plantings/card", planting: planting - else .col-md-12 %p Nothing is currently planted here. %section %h3.h3 Previously planted in this garden - .row + .index-cards - if @finished_plantings.size.positive? - @finished_plantings.each do |planting| - .col-xs-6.col-md-2 - = render "plantings/thumbnail", planting: planting + = render "plantings/thumbnail", planting: planting - else %p Nothing has been planted here. .col-md-3 From 80e8364de05f7347b993b06ee3a63b4472fe015a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 9 Jun 2019 14:02:30 +1200 Subject: [PATCH 252/549] title on planting thumbnails --- app/views/plantings/_thumbnail.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/plantings/_thumbnail.html.haml b/app/views/plantings/_thumbnail.html.haml index d8cd07c24..c8513fd7e 100644 --- a/app/views/plantings/_thumbnail.html.haml +++ b/app/views/plantings/_thumbnail.html.haml @@ -5,5 +5,6 @@ alt: planting.crop, class: 'img-card'), planting .card-body - = link_to planting.crop, planting + %h5.card-title= link_to planting.crop, planting + %h6.card-subtitle.text-muted=planting.finished_at = render 'plantings/badges', planting: planting From 7bc641fb5509aeac557b05fb2a08f7a0ba733e37 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 9 Jun 2019 14:02:41 +1200 Subject: [PATCH 253/549] fix gardens action menu --- app/views/gardens/_actions.html.haml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index cb702e961..99fbd6972 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -1,16 +1,18 @@ - if can?(:edit, garden) - .dropdown.garden-actions + .dropdown.float-right.garden-actions %button#garden-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "garden-actions-button"} - if can?(:edit, garden) - .dropdown-item= garden_plant_something_button(garden, classes: 'dropdown-item') if garden.active + = garden_plant_something_button(garden, classes: 'dropdown-item') if garden.active - if garden.active - .dropdown-item= garden_mark_inactive_button(garden, classes: 'dropdown-item') + = garden_mark_inactive_button(garden, classes: 'dropdown-item') - else - .dropdown-item= garden_mark_active_button(garden, classes: 'dropdown-item') + = garden_mark_active_button(garden, classes: 'dropdown-item') - .dropdown-item= garden_edit_button(garden, classes: 'dropdown-item') - .dropdown-item= add_photo_button(garden, classes: 'dropdown-item') + = garden_edit_button(garden, classes: 'dropdown-item') + = add_photo_button(garden, classes: 'dropdown-item') - if can?(:destroy, garden) - .dropdown-item= delete_button(garden, message: 'All plantings associated with this garden will also be deleted. Are you sure?') + .dropdown-divider + = delete_button(garden, classes: 'dropdown-item text-danger', + message: 'All plantings associated with this garden will also be deleted. Are you sure?') From 8762b11555d29d7a0ca78b032f47513235cc7395 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 9 Jun 2019 14:02:55 +1200 Subject: [PATCH 254/549] tidy plantings action menu --- app/views/plantings/_card.html.haml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/plantings/_card.html.haml b/app/views/plantings/_card.html.haml index d3cf7ca9b..a539ff14f 100644 --- a/app/views/plantings/_card.html.haml +++ b/app/views/plantings/_card.html.haml @@ -15,10 +15,11 @@ = planting_save_seeds_button(planting, classes: 'dropdown-item') - if can? :destroy, planting - = delete_button(planting, classes: 'dropdown-item') + .dropdown-divider + = delete_button(planting, classes: 'dropdown-item text-danger') .card-body.text-center - %h4= link_to planting.crop, planting + %h4.card-title= link_to planting.crop, planting .text-center= render 'plantings/badges', planting: planting - if planting.percentage_grown.present? .card-footer From b617468e266f48cb717d9fbe95d43d3e2fbb0eb3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 9 Jun 2019 14:03:20 +1200 Subject: [PATCH 255/549] remove commented out code --- app/assets/stylesheets/overrides.scss | 59 --------------------------- app/assets/stylesheets/plantings.scss | 3 -- 2 files changed, 62 deletions(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index 8721378ec..2987ffa9b 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -234,60 +234,6 @@ p.stats { } } -// .thumbnail -// // border: 1px solid lighten($green, 20%) -// text-align: center -// margin-bottom: 1.5em -// max-width: 160px -// //max-height: 220px -// //height: 180px - -// .seed-thumbnail -// height: 220px -// .seedinfo -// .seed-name -// font-size: 120% -// overflow: hidden - -// .member-thumbnail -// text-align: left -// img -// height: 85px -// width: 85px -// max-width: 85px - -// .crop-thumbnail -// .cropinfo -// margin-top: 0.5em -// display: inline-block -// max-width: 100% -// white-space: nowrap -// line-height: 1em -// padding-bottom: 2px - -// .cropname -// overflow: hidden -// text-overflow: ellipsis -// font-size: 120% - -// .scientificname -// font-size: small -// font-style: italic -// overflow: hidden -// text-overflow: ellipsis -// font-size: 70% - -// .plantingcount -// font-size: small -// .planting-lifespan -// font-size: 70% - -// .crop-name a -// padding-top: 2px - -// .scientific-name small -// margin-bottom: -2px - li.crop-hierarchy { list-style-type: disc; } @@ -332,17 +278,12 @@ footer { color: $navbar-default-link-active-color; } } - - //.navbar-bottom.navbar - // border-radius: 0 } // ensure footer is pushed to bottom of browser window #maincontainer { min-height: 80%; - - //padding: 50px } #global-actions { diff --git a/app/assets/stylesheets/plantings.scss b/app/assets/stylesheets/plantings.scss index e5cdf2885..46caa8569 100755 --- a/app/assets/stylesheets/plantings.scss +++ b/app/assets/stylesheets/plantings.scss @@ -1,5 +1,4 @@ .planting { - // padding: 0.5em; .planting-badges { font-size: 1.5em; @@ -18,8 +17,6 @@ .planting-thumbnail { width: 150px; padding: 0; - // margin-bottom: 0.5em; - // margin-top: 0.5em; .badge { font-size: 100%; From 0d02f5758b8233a4b6ba3ecb2ba3babb75bb182a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 9 Jun 2019 15:53:01 +1200 Subject: [PATCH 256/549] actions menu for harvests --- app/helpers/buttons_helper.rb | 4 ++-- app/views/harvests/_actions.html.haml | 13 ++++++++----- app/views/harvests/show.html.haml | 4 +--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index bc6da29f9..685cb2438 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -53,8 +53,8 @@ module ButtonsHelper edit_button(edit_seed_path(seed), classes: classes) end - def harvest_edit_button(harvest) - edit_button(edit_harvest_path(harvest)) + def harvest_edit_button(harvest, classes: "btn btn-raised btn-info") + edit_button(edit_harvest_path(harvest), classes: classes) end def garden_edit_button(garden, classes: "btn btn-raised btn-info") diff --git a/app/views/harvests/_actions.html.haml b/app/views/harvests/_actions.html.haml index 28a9aee77..1b42b8524 100644 --- a/app/views/harvests/_actions.html.haml +++ b/app/views/harvests/_actions.html.haml @@ -1,5 +1,8 @@ -.harvest-actions - .btn-group - = harvest_edit_button(harvest) if can? :edit, harvest - = add_photo_button(harvest) - = delete_button(harvest) +- if can?(:edit, harvest) + .dropdown.float-right.harvest-actions + %a#harvest-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions + .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "harvest-actions-button"} + = harvest_edit_button(harvest, classes: 'dropdown-item') + = add_photo_button(harvest, classes: 'dropdown-item') + .dropdown-divider + = delete_button(harvest, classes: 'dropdown-item text-danger') diff --git a/app/views/harvests/show.html.haml b/app/views/harvests/show.html.haml index 82411246f..2e8ec3260 100644 --- a/app/views/harvests/show.html.haml +++ b/app/views/harvests/show.html.haml @@ -8,14 +8,12 @@ = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) --content_for(:buttonbar) do - = render 'harvests/actions', harvest: @harvest - .row .col-md-8 %h1 = harvest_icon #{@harvest.crop} harvested by #{@harvest.owner} + = render 'harvests/actions', harvest: @harvest %p %b Owner: = link_to @harvest.owner, @harvest.owner From b92cef4c0297627733cee3777ef9daa2b8d51e56 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 09:10:07 +1200 Subject: [PATCH 257/549] view all buttons on home page --- app/views/home/index.html.haml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 75c96dbda..d9ed78fd7 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -21,8 +21,12 @@ != Crop.recent.limit(30).map { |c| link_to(c, c) }.join(", ") .col-xl-4 .row - .col-md-6.col-sm-12=render 'plantings' - .col-md-6.col-sm-12= render 'harvests' + .col-md-6 + =render 'plantings' + %p.text-right= link_to "#{t('home.plantings.view_all')} »", seeds_path, class: 'btn' + .col-md-6 + = render 'harvests' + %p.text-right= link_to "#{t('home.harvests.view_all')} »", seeds_path, class: 'btn' %section.seeds.mx-auto %h2.text-center= t('.seeds_available_to_trade') From c80cbf203c7d91d41e4d15b368181370a2a0c24f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 09:10:25 +1200 Subject: [PATCH 258/549] follow, edit, and message buttons on members#show --- app/views/members/show.html.haml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index ec83709ea..bb33f9cab 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -29,6 +29,21 @@ %p %strong Last Login = @member.last_sign_in_at + + - if can? :update, @member + = link_to edit_member_registration_path, class: 'btn btn-default' do + = edit_icon + = t('members.edit_profile') + + - if can?(:create, Notification) && current_member != @member + = link_to 'Send message', new_notification_path(recipient_id: @member.id), class: 'btn btn-default' + + - if current_member && current_member != @member # must be logged in, can't follow yourself + - follow = current_member.get_follow(@member) + - if !follow && can?(:create, Follow) # not already following + = link_to 'Follow', follows_path(followed: @member), method: :post, class: 'btn btn-default' + - if follow && can?(:destroy, follow) # already following + = link_to 'Unfollow', follow_path(follow), method: :delete, class: 'btn btn-default' = render "stats", member: @member .card-footer = render "contact", member: @member, twitter_auth: @twitter_auth, From 7e3d43c47c2583dab2b5c9d09569db40421d6d7c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 09:10:37 +1200 Subject: [PATCH 259/549] add missing translations for buttons --- config/locales/en.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 9c030450a..71dec1331 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -151,6 +151,8 @@ en: post: Post recently_added: Recently Added welcome: Welcome to %{site_name}, %{member_name} + harvests: + view_all: View all harvests members: title: Some of our members view_all: View all members @@ -174,6 +176,7 @@ en: community and the world. We believe that openness, sustainability, and social good go hand in hand. You can read more about %{why} or check out our code on %{github}. open_source_title: Open Source + support_body_html: Growstuff is independent, %{ad_free} and we have no outside investment. You can support our work by %{buy_account}. support_title: Support Growstuff talk_linktext: Growstuff Talk @@ -181,6 +184,7 @@ en: wiki_linktext: Growstuff Wiki plantings: recently_planted: Recently Planted + view_all: View all plantings seeds: crop: Crop description: Description From 78f3badcd75c7e5feeb984abf5af800db8a029d5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 09:11:22 +1200 Subject: [PATCH 260/549] upgrade rubocop --- .codeclimate.yml | 2 +- Gemfile | 2 +- Gemfile.lock | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.codeclimate.yml b/.codeclimate.yml index 65de6c429..85d0a48d1 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -1,7 +1,7 @@ engines: rubocop: enabled: true - channel: rubocop-0-60 + channel: "rubocop-0-70" scss-lint: enabled: true shellcheck: diff --git a/Gemfile b/Gemfile index a6373f97b..3ec60e5be 100644 --- a/Gemfile +++ b/Gemfile @@ -145,7 +145,7 @@ group :development, :test do gem 'poltergeist' # for headless JS testing gem 'rspec-activemodel-mocks' gem 'rspec-rails' # unit testing framework - gem 'rubocop', '~> 0.60' + gem 'rubocop', '~> 0.70' gem 'rubocop-rspec' gem 'selenium-webdriver' gem 'webrat' # provides HTML matchers for view tests diff --git a/Gemfile.lock b/Gemfile.lock index d9eeb015b..54119d2bb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -604,7 +604,7 @@ DEPENDENCIES responders rspec-activemodel-mocks rspec-rails - rubocop (~> 0.60) + rubocop (~> 0.70) rubocop-rspec ruby-units sass-rails From ee152b3ba3c31b179b950fd612da529df1531ffc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 09:20:09 +1200 Subject: [PATCH 261/549] Match sign in for to the older labels, so tests pass without changes --- app/views/devise/sessions/new.html.haml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index f9f7afed1..76bb744e9 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -2,19 +2,17 @@ .form-page %section.card.form-card %h1 Sign in - = form_for(resource, as: resource_name, + = bootstrap_form_for(resource, as: resource_name, url: session_path(resource_name), html: { class: "text-center border border-light p-5" }) do |f| = devise_error_messages! - = f.text_field :login, class: "form-control mb-4", placeholder: "E-mail", type: "email" - = f.password_field :password, class: 'form-control mb-4', placeholder: "Password", type: "password" + = f.text_field :login, type: "email", label: 'Login', required: true + = f.password_field :password, type: "password" - if devise_mapping.rememberable? %p = f.check_box :remember_me - Remember me - if devise_mapping.recoverable? && controller_name != 'passwords' - %p - = link_to "Forgot password?", new_password_path(resource_name) - = f.submit "Sign in", class: 'btn btn-block my-4 btn-success' + %p= link_to "Forgot password?", new_password_path(resource_name) + = f.submit "Sign in", class: 'btn btn-block btn-success' = render "devise/shared/links" From 4b7705fcade22b67f26206d5efd9f064502665c6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 09:20:32 +1200 Subject: [PATCH 262/549] wrap a context link in before in specs --- spec/features/members/deletion_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb index 6cf074f1a..64ceda9ad 100644 --- a/spec/features/members/deletion_spec.rb +++ b/spec/features/members/deletion_spec.rb @@ -142,7 +142,7 @@ describe "member deletion" do let(:member) { FactoryBot.create(:crop_wrangling_member) } let(:otherwrangler) { FactoryBot.create(:crop_wrangling_member) } let(:crop) { FactoryBot.create(:crop, creator: member) } - FactoryBot.create(:cropbot) + before { FactoryBot.create(:cropbot) } let!(:ex_wrangler) { FactoryBot.create(:crop_wrangling_member, login_name: "ex_wrangler") } it "leaves crops behind" do From 4086e6dd004d6e1c84a64745696493b225467d2c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 09:22:33 +1200 Subject: [PATCH 263/549] remove comments from json --- app.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/app.json b/app.json index 7a1659be1..8cd9f771e 100644 --- a/app.json +++ b/app.json @@ -3,8 +3,6 @@ "stack": "heroku-18", "description": "Open data project for small-scale food growers", "scripts": { - // The postdeploy script is run once, after the app is created - // and not on subsequent deploys to the app "postdeploy": "bundle exec rails db:seed" }, "env": { From 571f4298bb4a166d03c412a585ed0e435ee1e188 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Tue, 11 Jun 2019 21:22:53 +0000 Subject: [PATCH 264/549] [CodeFactor] Apply fixes --- app/controllers/plantings_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index aa5ff9f45..70ad87b72 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -43,8 +43,9 @@ class PlantingsController < ApplicationController def new @planting = Planting.new( planted_at: Time.zone.today, - owner: current_member, - garden: current_member.gardens.first) + owner: current_member, + garden: current_member.gardens.first + ) @seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id] # using find_by_id here because it returns nil, unlike find From 040c4148272c00c849dfd60da40bd7410f278b70 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 09:27:40 +1200 Subject: [PATCH 265/549] find translation of some_of_our_crops --- app/views/home/index.html.haml | 8 ++++---- config/locales/en.yml | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index d9ed78fd7..cda32980e 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -12,7 +12,7 @@ .row .col-xl-8.col-md-12 %section.crops - %h2= t('.some_of_our_crops') + %h2= t('home.blurb.some_of_our_crops') .homepage-cards= render 'crops' .align-bottom %p.text-right= link_to "#{t('home.crops.view_all')} »", crops_path, class: 'btn' @@ -23,16 +23,16 @@ .row .col-md-6 =render 'plantings' - %p.text-right= link_to "#{t('home.plantings.view_all')} »", seeds_path, class: 'btn' + %p.text-right= link_to "#{t('home.plantings.view_all')} »", seeds_path, class: 'btn btn-block' .col-md-6 = render 'harvests' - %p.text-right= link_to "#{t('home.harvests.view_all')} »", seeds_path, class: 'btn' + %p.text-right= link_to "#{t('home.harvests.view_all')} »", seeds_path, class: 'btn btn-block' %section.seeds.mx-auto %h2.text-center= t('.seeds_available_to_trade') = render 'seeds' .align-bottom - %p.text-right= link_to "#{t('home.seeds.view_all')} »", seeds_path, class: 'btn' + %p.text-right= link_to "#{t('home.seeds.view_all')} »", seeds_path, class: 'btn btn-block' %section.members.mx-auto= render 'members' %section.discussion.mx-auto= render 'discuss' \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 71dec1331..8ebecbd2a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -134,6 +134,7 @@ en: perks: Join now for your free garden journal, seed sharing, forums, and more. sign_in_linktext: sign in sign_up: Sign up + some_of_our_crops: Some of our crops crops: our_crops: Some of our crops recently_added: Recently added crops From 2386fe7afeb5c91e8efaa12623c8d02bad9a3d02 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 09:27:49 +1200 Subject: [PATCH 266/549] new hash syntax --- app/views/harvests/_actions.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/harvests/_actions.html.haml b/app/views/harvests/_actions.html.haml index 1b42b8524..a40b20c9d 100644 --- a/app/views/harvests/_actions.html.haml +++ b/app/views/harvests/_actions.html.haml @@ -1,6 +1,6 @@ - if can?(:edit, harvest) .dropdown.float-right.harvest-actions - %a#harvest-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions + %a#harvest-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button"} Actions .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "harvest-actions-button"} = harvest_edit_button(harvest, classes: 'dropdown-item') = add_photo_button(harvest, classes: 'dropdown-item') From 4f1eddd631a3027e0980fcc753d3d0c31069f33a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 09:35:51 +1200 Subject: [PATCH 267/549] specs want 30 on a page - so telling the controller --- app/controllers/notifications_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index d87518c07..0b145b04b 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -6,7 +6,7 @@ class NotificationsController < ApplicationController # GET /notifications def index - @notifications = Notification.by_recipient(current_member).order(:created_at).page(params[:page]) + @notifications = Notification.by_recipient(current_member).order(:created_at).paginate(page: params[:page], per_page: 30) end # GET /notifications/1 From 7cb4bf23144387798f0fe30300e5d0353050eca3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 09:39:29 +1200 Subject: [PATCH 268/549] LArge buttons on home page --- app/views/home/_members.html.haml | 2 +- app/views/home/index.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/home/_members.html.haml b/app/views/home/_members.html.haml index c18ccfc93..5bc8b27b4 100644 --- a/app/views/home/_members.html.haml +++ b/app/views/home/_members.html.haml @@ -7,4 +7,4 @@ = render members %p.text-right - = link_to "#{t('.view_all')} »", members_path, class: 'btn' + = link_to "#{t('.view_all')} »", members_path, class: 'btn btn-block' diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index cda32980e..701636ec7 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -15,7 +15,7 @@ %h2= t('home.blurb.some_of_our_crops') .homepage-cards= render 'crops' .align-bottom - %p.text-right= link_to "#{t('home.crops.view_all')} »", crops_path, class: 'btn' + %p.text-right= link_to "#{t('home.crops.view_all')} »", crops_path, class: 'btn btn-block' - cache cache_key_for(Crop, 'recent') do %h3= t('.recently_added') != Crop.recent.limit(30).map { |c| link_to(c, c) }.join(", ") From 690afc1747ee8d045583a1c811d02b99c55bc187 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 09:39:57 +1200 Subject: [PATCH 269/549] One more button from homepage --- app/views/home/_discuss.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/home/_discuss.html.haml b/app/views/home/_discuss.html.haml index c8ceb404e..e94445f30 100644 --- a/app/views/home/_discuss.html.haml +++ b/app/views/home/_discuss.html.haml @@ -14,4 +14,4 @@ = post.comments.size comments %p.text-right - = link_to "#{t('.view_all')} »", posts_path, class: 'btn' + = link_to "#{t('.view_all')} »", posts_path, class: 'btn btn-block' From cb84579e78b71c8d25f2dcd564c156e0a3996e5f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 11:17:38 +1200 Subject: [PATCH 270/549] Delete .mention-bot --- .mention-bot | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .mention-bot diff --git a/.mention-bot b/.mention-bot deleted file mode 100644 index 130e8b80d..000000000 --- a/.mention-bot +++ /dev/null @@ -1,3 +0,0 @@ -{ - "userBlacklist": ["tygriffin","oshiho3"] -} \ No newline at end of file From a53e9e59a92f2c757bd3df18b6131378ceb2486f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 11:17:54 +1200 Subject: [PATCH 271/549] Delete .hound.yml --- .hound.yml | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 .hound.yml diff --git a/.hound.yml b/.hound.yml deleted file mode 100644 index 6fc0f560d..000000000 --- a/.hound.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -fail_on_violations: true -ruby: - config_file: .rubocop.yml -haml: - config_file: .haml-lint.yml -scss: - config_file: .scss-lint.yml -eslint: - config_file: .eslintrc - ignore_file: .esignore -jshint: - enabled: false From accf549e58ad3db39a9a732167b6aa5b25a99f69 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 11:18:24 +1200 Subject: [PATCH 272/549] Delete percy-new.sh --- script/percy-new.sh | 4 ---- 1 file changed, 4 deletions(-) delete mode 100755 script/percy-new.sh diff --git a/script/percy-new.sh b/script/percy-new.sh deleted file mode 100755 index e5db82272..000000000 --- a/script/percy-new.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -bundle exec rails assets:precompile -export PERCY_TOKEN=047f5b0ecf3ca0a2bc94a6cfc837e625ace93ef0d81cc8ac82e3fb3aebd5c17f -PERCY_TARGET_BRANCH=dev npx percy exec -- bundle exec rspec spec/features/percy/ From 2d9d8c45a29f1da936b2e34f1c914b348a44215e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 11:21:07 +1200 Subject: [PATCH 273/549] Update index.html.haml --- app/views/notifications/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/notifications/index.html.haml b/app/views/notifications/index.html.haml index d8d9b25c5..119d385e4 100644 --- a/app/views/notifications/index.html.haml +++ b/app/views/notifications/index.html.haml @@ -1,7 +1,7 @@ - content_for :title, "Inbox" - if @notifications.empty? - You have no messages. + .alert You have no messages. - else = paginate @notifications, theme: 'twitter-bootstrap-3' %table.table.table-striped From b52dc34381d6889f9d4873f043ad221b0c525529 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 11:22:25 +1200 Subject: [PATCH 274/549] Header on notifications --- app/views/notifications/index.html.haml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/views/notifications/index.html.haml b/app/views/notifications/index.html.haml index 119d385e4..e4f36fc1b 100644 --- a/app/views/notifications/index.html.haml +++ b/app/views/notifications/index.html.haml @@ -5,11 +5,12 @@ - else = paginate @notifications, theme: 'twitter-bootstrap-3' %table.table.table-striped - %tr - %th From - %th Subject - %th Date - %th + %thead + %tr + %th From + %th Subject + %th Date + %th - @notifications.each do |n| - if can? :read, n From 64dcb62c039a59c65f899fb1310f23fc1a6bc0cd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 11:24:16 +1200 Subject: [PATCH 275/549] Fix tabulated --- app/views/notifications/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/notifications/index.html.haml b/app/views/notifications/index.html.haml index e4f36fc1b..8891b62cf 100644 --- a/app/views/notifications/index.html.haml +++ b/app/views/notifications/index.html.haml @@ -1,7 +1,7 @@ - content_for :title, "Inbox" - if @notifications.empty? - .alert You have no messages. + .alert You have no messages. - else = paginate @notifications, theme: 'twitter-bootstrap-3' %table.table.table-striped From e56133a9443d21dc8a0fd7927820485fcbf3e08e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 12:10:02 +1200 Subject: [PATCH 276/549] Delete percy_new_spec.rb --- spec/features/percy/percy_new_spec.rb | 388 -------------------------- 1 file changed, 388 deletions(-) delete mode 100644 spec/features/percy/percy_new_spec.rb diff --git a/spec/features/percy/percy_new_spec.rb b/spec/features/percy/percy_new_spec.rb deleted file mode 100644 index 6357546ab..000000000 --- a/spec/features/percy/percy_new_spec.rb +++ /dev/null @@ -1,388 +0,0 @@ -require 'rails_helper' - -describe 'Test with visual testing', type: :feature, js: true do - # Use the same random seed every time so our random data is the same - # on every run, so doesn't trigger percy to see changes - before { Faker::Config.random = Random.new(42) } - let!(:member) { FactoryBot.create :member, login_name: 'percy', preferred_avatar_uri: gravatar } - let!(:crop_wrangler) { FactoryBot.create :crop_wrangling_member, login_name: 'croppy', preferred_avatar_uri: gravatar2 } - let!(:admin_user) { FactoryBot.create :admin_member, login_name: 'janitor', preferred_avatar_uri: gravatar3 } - let!(:someone_else) { FactoryBot.create :edinburgh_member, login_name: 'ruby', preferred_avatar_uri: gravatar4 } - - let(:gravatar) { 'http://www.gravatar.com/avatar/d021434aac03a7f7c7c0de60d07dad1c?size=150&default=identicon' } - let(:gravatar2) { 'http://www.gravatar.com/avatar/353d83d3677b142520987e1936fd093c?size=150&default=identicon' } - let(:gravatar3) { 'http://www.gravatar.com/avatar/622db62c7beab8d5d8b7a80aa6385b2f?size=150&default=identicon' } - let(:gravatar4) { 'http://www.gravatar.com/avatar/7fd767571ff5ceefc7a687a543b2c402?size=150&default=identicon' } - - let!(:tomato) { FactoryBot.create :tomato, creator: someone_else } - let(:plant_part) { FactoryBot.create :plant_part, name: 'fruit' } - - let(:tomato_photo) do - FactoryBot.create :photo, - title: 'look at my tomatoes', - owner: member, - fullsize_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_z.jpg', - thumbnail_url: 'https://farm1.staticflickr.com/177/432250619_2fe19d067d_q.jpg' - end - let(:post_body) do - "So, um, watering's important. Yep. Very important. - -Well, what with moving into the house and all THAT entails...my plants are looking the worse for wear. They haven't gotten enough water. The oregano is dead. The basil and chives are just hanging on. The [tomato](crop) have sort of purple leaves. Seeing that the roots were all growing out of the bottom of the pots, I finally went and got soil to fill the basins I have for the tomatoes and spent the money on proper (much larger) pots for the herbs. - -At Home Depot, it turned out that 7.5\" pots that are glazed inside and out (to prevent wicking & evaporation of water -- the problem my tomatoes were hitting with the teensy clay pots) were $10 for the pot and $5 for the saucer. Or there are 7.25\" self-watering pots for $15. So my herbs are now in self-watering pots where they should be able to survive Pennsic without me. I got a new oregano plant too. - -[ ![self-watering herbs](http://farm4.staticflickr.com/3735/9337893326_62a036bf56.jpg) ](http://www.flickr.com/photos/maco_nix/9337893326/) - -The tomatoes are now in large plastic bins full of dirt/compost, where their roots can spread out. Turns out clay pots in weather that is always over 80, usually over 90, and hitting over 100 (celsius people, read those as 26, 32, 38) means you need to water at least daily, probably a couple of times a day, to keep the plants happy. - -[ ![tomatoes in plastic cement mixing tubs](http://farm4.staticflickr.com/3745/9337878942_9602530c31.jpg)](http://www.flickr.com/photos/maco_nix/9337878942/) - -After taking that photo, I put some egg shells (since I hardboiled some eggs today for pickling) in the dirt around them and added stakes. - -I noticed a couple of days ago on the way to work that there's a place near home called Country Boy Market. Fresh locally grown produce (cheap berries, nom nom), mulch, top soil, compost, and straw bales are all available. Also they deliver mulch & soil. Well then. I know what's happening next spring when I try to build up the rest of the garden. -[apple](crop) - " - end - let(:post) { FactoryBot.create :post, author: member, subject: "Watering", body: post_body } - before do - # Freeze time, so we don't have variations in timestamps on the page - Timecop.freeze(Time.zone.local(2019, 1, 1)) - - { - chard: 'https://farm9.staticflickr.com/8516/8519911893_1759c28965_q.jpg', - apple: 'https://farm5.staticflickr.com/4748/38932178855_6fe9bcdb48_q.jpg', - pear: 'https://farm1.staticflickr.com/113/250984726_0fc31fea6d_q.jpg', - popcorn: 'https://farm8.staticflickr.com/7893/33150160528_24a689c6bc_q.jpg', - eggplant: 'https://farm8.staticflickr.com/7856/47068736892_1af9b8a4ba_q.jpg', - maize: 'https://farm66.staticflickr.com/65535/46739264475_7cb55b2cbb_q.jpg' - }.each do |crop_type, photo_url| - crop = FactoryBot.create crop_type, creator: someone_else - owner = FactoryBot.create :member, login_name: crop_type.to_s.reverse, email: "#{crop.name}@example.com" - planting = FactoryBot.create :planting, crop: crop, owner: owner, garden: owner.gardens.first - photo = FactoryBot.create(:photo, owner: owner, - thumbnail_url: "#{photo_url}_q.jpg", fullsize_url: "#{photo_url}_z.jpg") - planting.photos << photo - - harvest = FactoryBot.create :harvest, crop: crop, owner: owner, plant_part: plant_part - harvest.photos << photo - FactoryBot.create :planting, crop: tomato, - planted_at: 1.year.ago, finished_at: 2.months.ago, - sunniness: 'sun', planted_from: 'seed' - end - - FactoryBot.create_list :post, 7 - FactoryBot.create :seed, owner: member, tradable_to: 'nationally' - FactoryBot.create :seed, owner: someone_else, tradable_to: 'nationally' - end - after { Timecop.return } - - shared_examples 'visit pages' do - describe 'home' do - it 'loads homepage' do - visit root_path - Percy.snapshot(page, name: "#{prefix}/homepage") - end - end - - describe 'crops' do - it 'loads crops#show' do - FactoryBot.create :planting, planted_at: 2.months.ago, sunniness: 'shade', planted_from: 'seedling' - - planting = FactoryBot.create :planting, planted_at: 1.year.ago, sunniness: 'sun', planted_from: 'seed', crop: tomato - FactoryBot.create(:harvest, - crop: tomato, - plant_part: FactoryBot.create(:plant_part, name: 'berry'), - planting: planting, - harvested_at: 1.day.ago) - - tomato.posts << FactoryBot.create(:post, subject: 'tomatoes are delicious') - - visit crop_path(tomato) - expect(page).to have_text 'tomato' - Percy.snapshot(page, name: "#{prefix}/crops#show") - end - it 'loads crops#index' do - visit crops_path - Percy.snapshot(page, name: "#{prefix}/crops#index") - end - end - - describe 'plantings' do - it 'loads plantings#index' do - visit plantings_path - Percy.snapshot(page, name: "#{prefix}/plantings#index") - end - - it 'load another member plantings#show' do - planting = FactoryBot.create :planting, crop: tomato, owner: someone_else, garden: someone_else.gardens.first - visit planting_path(planting) - Percy.snapshot(page, name: "#{prefix}/plantings#show") - end - end - - describe 'gardens' do - let(:first_garden) { Garden.first } - let(:second_garden) { Garden.second } - let(:third_garden) { Garden.all.offset(3)[0] } - it 'loads gardens#index' do - FactoryBot.create_list :planting, 3, garden: first_garden, owner: first_garden.owner - FactoryBot.create_list :planting, 7, garden: second_garden, owner: second_garden.owner - FactoryBot.create_list :planting, 26, garden: third_garden, owner: third_garden.owner - visit gardens_path - Percy.snapshot(page, name: "#{prefix}/gardens#index") - end - - it 'gardens#show' do - # a garden - garden = FactoryBot.create :garden, name: 'paradise', owner: member - # with some lettuce (finished) - FactoryBot.create :planting, crop: FactoryBot.create(:crop, name: 'lettuce'), garden: garden, owner: member, finished_at: 2.weeks.ago - # tomato still growing - tomato_planting = FactoryBot.create :planting, garden: garden, owner: member, crop: tomato - tomato_photo.plantings << tomato_planting - visit garden_path(garden) - Percy.snapshot(page, name: "#{prefix}/gardens#show") - end - end - - describe 'members' do - it 'loads members#index' do - visit members_path - Percy.snapshot(page, name: "#{prefix}/members#index") - end - - it 'loads another members#show' do - FactoryBot.create :planting, owner: someone_else, created_at: 30.days.ago, crop: tomato - FactoryBot.create :planting, owner: someone_else, created_at: 24.days.ago, crop: tomato - FactoryBot.create :post, author: someone_else, created_at: 4.days.ago, subject: 'waiting for my tomatoes' - FactoryBot.create :harvest, owner: someone_else, created_at: 1.day.ago, crop: tomato - - visit member_path(someone_else) - Percy.snapshot(page, name: "#{prefix}/members#show") - end - end - - describe 'posts' do - it 'loads posts#show' do - FactoryBot.create :comment, post: post - FactoryBot.create :comment, post: post - visit post_path(post) - Percy.snapshot(page, name: "#{prefix}/posts#show") - end - it 'loads posts#index' do - Member.all.limit(5).each do |member| - FactoryBot.create_list :post, 12, author: member - end - Post.all.order(id: :desc).limit(4) do |post| - FactoryBot.create_list :comment, rand(1..5), post: post - end - visit posts_path - Percy.snapshot(page, name: "#{prefix}/posts#index") - end - end - - describe 'photos' do - it 'loads photos#show' do - tomato_photo.plantings << FactoryBot.create(:planting, owner: member, crop: tomato) - visit photo_path(tomato_photo) - Percy.snapshot(page, name: "#{prefix}/photos#show") - end - end - end - - context "when signed out" do - let(:prefix) { 'signed-out' } - include_examples 'visit pages' - - it 'loads sign in page' do - visit crops_path # some random page - click_link 'Sign in' - Percy.snapshot(page, name: "sign-in") - end - - it 'loads sign up page' do - visit crops_path # some random page - click_link 'Sign up' - Percy.snapshot(page, name: "sign-up") - end - - it 'loads forgot password' do - visit new_member_password_path - Percy.snapshot(page, name: "forgot-password") - end - it 'loads new confirmation' do - visit new_member_confirmation_path - Percy.snapshot(page, name: "new-confimation") - end - end - - context 'when signed in' do - let(:prefix) { 'signed-in' } - before { login_as member } - include_examples 'visit pages' - - it 'load my plantings#show' do - planting = FactoryBot.create :planting, crop: tomato, owner: member, garden: member.gardens.first - visit planting_path(planting) - Percy.snapshot(page, name: "#{prefix}/self/plantings#show") - end - - it 'load my members#show' do - visit member_path(member) - Percy.snapshot(page, name: "#{prefix}/self/members#show") - end - - let(:my_first_garden) { Garden.first } - let(:my_second_garden) { Garden.second } - let(:my_third_garden) { Garden.all.offset(3)[0] } - - it 'loads gardens#index' do - FactoryBot.create_list :planting, 3, garden: my_first_garden, owner: my_first_garden.owner - FactoryBot.create_list :planting, 7, garden: my_second_garden, owner: my_second_garden.owner - FactoryBot.create_list :planting, 26, garden: my_third_garden, owner: my_third_garden.owner - visit gardens_path - Percy.snapshot(page, name: "#{prefix}/gardens#index") - end - - it 'load my gardens#show' do - garden = FactoryBot.create :garden, name: 'paradise', owner: member - visit garden_path(garden) - Percy.snapshot(page, name: "#{prefix}/self/gardens#show") - end - - describe '#new' do - it 'plantings#new' do - visit new_planting_path - Percy.snapshot(page, name: "#{prefix}/plantings#new") - fill_in 'crop', with: 'cap' - Percy.snapshot(page, name: "#{prefix}/crops-autocomplete") - end - - it 'crops#new' do - visit new_crop_path - Percy.snapshot(page, name: "#{prefix}/crops#new") - end - - it 'gardens#new' do - visit new_garden_path - Percy.snapshot(page, name: "#{prefix}/gardens#new") - end - - it 'harvests#new' do - visit new_harvest_path - Percy.snapshot(page, name: "#{prefix}/harvests#new") - fill_in(id: 'crop', with: 'tom') - Percy.snapshot(page, name: "#{prefix}/harvests#new-autosuggest") - end - - it 'plantings#new' do - visit new_planting_path - Percy.snapshot(page, name: "#{prefix}/plantings#new") - fill_in(id: 'crop', with: 'tom') - Percy.snapshot(page, name: "#{prefix}/plantings#new-autosuggest") - end - - it 'seeds#new' do - visit new_seed_path - Percy.snapshot(page, name: "#{prefix}/seeds#new") - fill_in(id: 'crop', with: 'tom') - Percy.snapshot(page, name: "#{prefix}/seeds#new-autosuggest") - end - - it 'posts#new' do - visit new_post_path - Percy.snapshot(page, name: "#{prefix}/posts#new") - end - end - - describe '#edit' do - it 'loads gardens#edit' do - garden = FactoryBot.create :garden, owner: member - visit edit_garden_path(garden) - Percy.snapshot(page, name: "#{prefix}/gardens#edit") - end - - it 'loads harvests#edit' do - harvest = FactoryBot.create :harvest, owner: member - visit edit_harvest_path(harvest) - Percy.snapshot(page, name: "#{prefix}/harvests#edit") - end - - it 'loads planting#edit' do - planting = FactoryBot.create :planting, owner: member - visit edit_planting_path(planting) - Percy.snapshot(page, name: "#{prefix}/plantings#edit") - end - - it 'loads posts#edit' do - visit edit_post_path(post) - Percy.snapshot(page, name: "#{prefix}/posts#edit") - end - - it 'comments#new' do - visit new_comment_path(post_id: post.id) - Percy.snapshot(page, name: "comments#new") - end - end - - describe 'expand menus' do - it 'expands crop menu' do - visit root_path - click_on 'Crops' - Percy.snapshot(page, name: "#{prefix}/crops-menu") - click_on 'Community' - Percy.snapshot(page, name: "#{prefix}/community-menu") - click_on 'percy' - Percy.snapshot(page, name: "#{prefix}/member-menu") - end - end - end - - context 'wrangling crops' do - let(:prefix) { 'crop-wrangler' } - before { login_as crop_wrangler } - let!(:candy) { FactoryBot.create :crop_request, name: 'candy' } - - it 'crop wrangling page' do - visit wrangle_crops_path - Percy.snapshot(page, name: 'crops wrangle') - click_link 'Pending approval' - Percy.snapshot(page, name: 'crops pending approval') - click_link 'candy' - Percy.snapshot(page, name: 'editing pending crop') - end - end - context 'admin' do - before do - login_as admin_user - visit admin_path - end - it 'admin page' do - Percy.snapshot(page, name: 'Admin') - end - it 'Roles' do - click_link 'Roles' - Percy.snapshot(page, name: 'Admin Roles') - end - it 'CMS' do - click_link 'CMS' - Percy.snapshot(page, name: 'CMS') - end - it 'Garden Types' do - click_link 'Garden Types' - Percy.snapshot(page, name: 'Admin Garden type') - end - it 'Alternate names' do - click_link 'Alternate names' - Percy.snapshot(page, name: 'Admin Alternate names') - end - it 'Scientific names' do - click_link 'Scientific names' - Percy.snapshot(page, name: 'Admin Scientific names') - end - it 'Members' do - click_link 'Members' - Percy.snapshot(page, name: 'Admin Members') - end - end -end From e8865ba528b5db46924ea764defc573485348e77 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 12:36:56 +1200 Subject: [PATCH 277/549] More alerty message about no messages --- app/views/notifications/index.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/notifications/index.html.haml b/app/views/notifications/index.html.haml index 8891b62cf..8dc28b27b 100644 --- a/app/views/notifications/index.html.haml +++ b/app/views/notifications/index.html.haml @@ -1,7 +1,7 @@ - content_for :title, "Inbox" - if @notifications.empty? - .alert You have no messages. + .alert.alert-success{role: "alert"} You have no messages. - else = paginate @notifications, theme: 'twitter-bootstrap-3' %table.table.table-striped @@ -34,5 +34,5 @@ - else %strong= n.created_at %td - = link_to 'Delete', n, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs' + = link_to 'Delete', n, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default background-danger btn-xs' = paginate @notifications, theme: 'twitter-bootstrap-3' From 9982e94af7394d0bd3dfb2c85aec75fe5099736c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 14:29:28 +1200 Subject: [PATCH 278/549] Run all feature specs to find percy snapshots --- script/percy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/percy.sh b/script/percy.sh index 8df5ba590..f2a6563b0 100755 --- a/script/percy.sh +++ b/script/percy.sh @@ -1,3 +1,3 @@ #!/bin/bash bundle exec rails assets:precompile -PERCY_TARGET_BRANCH=dev npx percy exec -- bundle exec rspec spec/features/percy/ +PERCY_TARGET_BRANCH=dev npx percy exec -- bundle exec rspec spec/features/ From a495807739250f83eb9621faea6fc2433e8aade3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 14:29:49 +1200 Subject: [PATCH 279/549] Percy snapshots for notifications --- spec/features/notifications_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/features/notifications_spec.rb b/spec/features/notifications_spec.rb index 347d27627..c184bfb46 100644 --- a/spec/features/notifications_spec.rb +++ b/spec/features/notifications_spec.rb @@ -16,6 +16,7 @@ describe "Notifications", :js do before do login_as recipient visit notification_path(notification) + Percy.snapshot(page, name: "notifications#show") end it "Replying to the notification" do @@ -23,6 +24,7 @@ describe "Notifications", :js do expect(page).to have_content "Notification body" fill_in 'notification_body', with: "Response body" + Percy.snapshot(page, name: "notifications#new") click_button "Send" expect(page).to have_content "Message was successfully sent" @@ -34,6 +36,7 @@ describe "Notifications", :js do FactoryBot.create_list :notification, 34, recipient: recipient login_as recipient visit notifications_path + Percy.snapshot(page, name: "notifications#index") end it 'has page navigation' do From 6d8c02f282e556fc36f0742164d0c2c12995bf22 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 14:38:00 +1200 Subject: [PATCH 280/549] Make the member icon tiny on comments --- app/views/comments/_single.html.haml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/comments/_single.html.haml b/app/views/comments/_single.html.haml index e0726f343..b29502adf 100644 --- a/app/views/comments/_single.html.haml +++ b/app/views/comments/_single.html.haml @@ -1,8 +1,7 @@ .card.comment .card-body .row - .col-md-1 - = render partial: "members/avatar", locals: { member: comment.author } + .col-md-1= render "members/tiny", member: comment.author .col-md-11.border-left - if can?(:edit, comment) || can?(:destroy, comment) .dropdown.float-right From 44e861dc6f6f816f58ad41fdbdf23fb2a622993b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 14:47:43 +1200 Subject: [PATCH 281/549] block buttons --- app/views/crops/_harvests.html.haml | 2 +- app/views/crops/_plantings.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/crops/_harvests.html.haml b/app/views/crops/_harvests.html.haml index 23b071e69..ad25f65b5 100644 --- a/app/views/crops/_harvests.html.haml +++ b/app/views/crops/_harvests.html.haml @@ -16,6 +16,6 @@ %p= link_to "View all #{crop.name} harvests", crop_harvests_path(crop) - if crop.approved? - if current_member - %p= link_to "Harvest #{crop.name}", new_harvest_path(crop_id: crop.id), class: 'btn' + %p= link_to "Harvest #{crop.name}", new_harvest_path(crop_id: crop.id), class: 'btn btn-block' - else = render partial: 'shared/signin_signup', locals: { to: "track your #{crop.name} harvests" } diff --git a/app/views/crops/_plantings.html.haml b/app/views/crops/_plantings.html.haml index 611f2d081..889eb8d26 100644 --- a/app/views/crops/_plantings.html.haml +++ b/app/views/crops/_plantings.html.haml @@ -11,6 +11,6 @@ .card-footer - if crop.approved? - if current_member - %p= link_to "Plant #{crop.name}", new_planting_path(crop_id: crop.id), class: 'btn' + %p= link_to "Plant #{crop.name}", new_planting_path(crop_id: crop.id), class: 'btn btn-block' - else = render partial: 'shared/signin_signup', locals: { to: "track your #{crop.name} plantings" } From 878c692b2776bf95a85ec5de7d41a4ad9a1c0f47 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 14:48:00 +1200 Subject: [PATCH 282/549] posts display --- app/views/crops/_posts.html.haml | 1 - app/views/members/_tiny.haml | 2 +- app/views/plantings/index.html.haml | 3 ++- app/views/posts/_preview.haml | 9 +++++---- app/views/posts/show.html.haml | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/views/crops/_posts.html.haml b/app/views/crops/_posts.html.haml index 304eb6c82..2012f642a 100644 --- a/app/views/crops/_posts.html.haml +++ b/app/views/crops/_posts.html.haml @@ -15,7 +15,6 @@ = page_entries_info @posts = render 'layouts/pagination', collection: @posts - @posts.each do |post| - -# = render partial: "posts/single", locals: { post: post, subject: true } = render 'posts/preview', post: post .pagination diff --git a/app/views/members/_tiny.haml b/app/views/members/_tiny.haml index dd7d78fda..346da1165 100644 --- a/app/views/members/_tiny.haml +++ b/app/views/members/_tiny.haml @@ -1,2 +1,2 @@ = link_to member do - = image_tag(avatar_uri(member, 50), alt: '', class: 'img img-responsive avatar rounded') \ No newline at end of file + = image_tag(avatar_uri(member, 50), alt: '', class: 'img img-responsive avatar rounded', height: 75) \ No newline at end of file diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index fda4224db..7ae3f41a2 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -1,7 +1,8 @@ - content_for :title, title('plantings', @owner, @crop, @planting) + %h1 = planting_icon - =title('plantings', @owner, @crop, @planting) + %strong= title('plantings', @owner, @crop, @planting) = render 'layouts/nav', model: Planting diff --git a/app/views/posts/_preview.haml b/app/views/posts/_preview.haml index e6623a6c9..1d7ccbf37 100644 --- a/app/views/posts/_preview.haml +++ b/app/views/posts/_preview.haml @@ -1,13 +1,14 @@ %section .row .col-md-12 - .card.card-cascade.wider.reverse - .card-body.card-body-cascade.text-center - %h2.font-weight-bold - = link_to post.subject, post + .card.card-cascade + .card-header + %h2= link_to post.subject, post %p Written by %strong= link_to post.author, post.author + .card-body + .float-right= render 'members/tiny', member: post.author %p = truncate(strip_tags(post.body), length: 200) diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index 604107128..186f5dd88 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -47,7 +47,7 @@ = icon 'fas', 'comment' Comment - = render "comments", post: @post + %secion.comments= render "comments", post: @post .col-md-4.col-12 = render @post.author From cfac7defedd5a6b2914e969ee7c93e8e326c1fbb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 16:20:11 +1200 Subject: [PATCH 283/549] Remove commented out gem --- Gemfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile b/Gemfile index 3ec60e5be..6ab49ce81 100644 --- a/Gemfile +++ b/Gemfile @@ -16,7 +16,6 @@ gem 'sass-rails' gem 'jsonapi-resources' # CSS framework -# gem 'bootstrap-sass' gem 'bootstrap', '4.1.1' gem 'material-sass', '4.1.1' From 39586cc1ba542cace4476855163bb46e179d08fd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 16:23:29 +1200 Subject: [PATCH 284/549] Update app/controllers/plantings_controller.rb --- app/controllers/plantings_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 70ad87b72..3ba06367b 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -48,7 +48,6 @@ class PlantingsController < ApplicationController ) @seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id] - # using find_by_id here because it returns nil, unlike find @crop = Crop.approved.find_by(id: params[:crop_id]) || Crop.new @planting.garden = Garden.find_by( owner: current_member, From 9285ffaec7be6f83648c40be4397ef72ee34fbbe Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 12 Jun 2019 16:51:55 +1200 Subject: [PATCH 285/549] Update app/views/members/_actions.html.haml --- app/views/members/_actions.html.haml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/members/_actions.html.haml b/app/views/members/_actions.html.haml index 58c1b152e..9e69566d0 100644 --- a/app/views/members/_actions.html.haml +++ b/app/views/members/_actions.html.haml @@ -1,4 +1,3 @@ --# - content_for :buttonbar do -# %p.btn-group -# - if can? :update, @member -# = link_to edit_member_registration_path, class: 'btn btn-default text-right' do @@ -13,4 +12,4 @@ -# - if !follow && can?(:create, Follow) # not already following -# = link_to 'Follow', follows_path(followed: @member), method: :post, class: 'btn btn-default text-right' -# - if follow && can?(:destroy, follow) # already following --# = link_to 'Unfollow', follow_path(follow), method: :delete, class: 'btn btn-default text-right' \ No newline at end of file +-# = link_to 'Unfollow', follow_path(follow), method: :delete, class: 'btn btn-default text-right' From a9f8df62c5a0399f1db9ee5b4d7066868bf44803 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Wed, 12 Jun 2019 04:52:57 +0000 Subject: [PATCH 286/549] [CodeFactor] Apply fixes --- spec/features/notifications_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/features/notifications_spec.rb b/spec/features/notifications_spec.rb index c184bfb46..d925d785f 100644 --- a/spec/features/notifications_spec.rb +++ b/spec/features/notifications_spec.rb @@ -7,10 +7,10 @@ describe "Notifications", :js do context "On existing notification" do let!(:notification) do create :notification, - sender: sender, - recipient: recipient, - body: "Notification body", - post_id: nil + sender: sender, + recipient: recipient, + body: "Notification body", + post_id: nil end before do From a26003940dd9fc76ce1524a3e6aeacb5cb89a9ce Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Thu, 13 Jun 2019 13:54:59 +0930 Subject: [PATCH 287/549] Crop search result page - doubled breadcrumbs --- app/views/crops/search.html.haml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/views/crops/search.html.haml b/app/views/crops/search.html.haml index 5c1578224..9a62ca512 100644 --- a/app/views/crops/search.html.haml +++ b/app/views/crops/search.html.haml @@ -9,12 +9,8 @@ %h1 Crop search - content_for :breadcrumbs do - %nav{"aria-label" => "breadcrumb"} - %ol.breadcrumb - %li.breadcrumb-item - = link_to 'Home', root_path - %li.breadcrumb-item= link_to 'Crops', crops_path - %li.breadcrumb-item.active= link_to 'Search', search_crops_path(term: @term) + %li.breadcrumb-item= link_to 'Crops', crops_path + %li.breadcrumb-item.active= link_to 'Search', search_crops_path(term: @term) %div = form_tag search_crops_path, method: :get, id: 'crop-search', class: 'form-inline' do From 347dfc3258197eb7f9cf4b01e9137cbb70103dae Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Thu, 13 Jun 2019 13:56:53 +0930 Subject: [PATCH 288/549] Apply similar layout to app/views/crops/index.html.haml --- app/views/crops/search.html.haml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/views/crops/search.html.haml b/app/views/crops/search.html.haml index 9a62ca512..8ae4119fd 100644 --- a/app/views/crops/search.html.haml +++ b/app/views/crops/search.html.haml @@ -32,6 +32,12 @@ instead. - else - .row - - @crops.each do |crop| - .col-md-2= render 'crops/thumbnail', crop: crop + .pagination= render 'layouts/pagination', collection: @crops + + .crops + .row + - @crops.each do |crop| + .col-6.col-md-3= render 'crops/thumbnail', crop: crop + + + .pagination= render 'layouts/pagination', collection: @crops From dcc10273ef14fbb668d4e3cc6edc3cfb21239f84 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Thu, 13 Jun 2019 13:59:19 +0930 Subject: [PATCH 289/549] Update search placeholder --- app/views/crops/_search_bar.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/crops/_search_bar.haml b/app/views/crops/_search_bar.haml index bea22af51..f6828156b 100644 --- a/app/views/crops/_search_bar.haml +++ b/app/views/crops/_search_bar.haml @@ -1,6 +1,6 @@ = form_tag search_crops_path, method: :get, class: 'form-inline my-2 my-lg-0', id: 'navbar-search' do .input-group - %input.form-control.mr-sm-2{name: 'term', "aria-label" => "Search", placeholder: "Search", type: "search"}/ + %input.form-control.mr-sm-2{name: 'term', "aria-label" => "Search crops", placeholder: "Search crops", type: "search"}/ %button.btn.btn-default.text-white{type: "submit"} = icon 'fas', 'search' - Search \ No newline at end of file + Search From 6c49f1768ce8e53ec6fe7272f40341b1b32c4bb3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 13 Jun 2019 19:51:18 +1200 Subject: [PATCH 290/549] add extra click into spec --- spec/features/scientific_name_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/features/scientific_name_spec.rb b/spec/features/scientific_name_spec.rb index 00563deb6..a113b6e07 100644 --- a/spec/features/scientific_name_spec.rb +++ b/spec/features/scientific_name_spec.rb @@ -29,6 +29,7 @@ describe "Scientific names", js: true do expect(page.status_code).to equal 200 expect(page).to have_content "CROP WRANGLER" expect(page).to have_content zea_mays.name + click_link zea_mays.name expect(page).to have_link "Edit", href: edit_scientific_name_path(zea_mays) within('.scientific_names') { click_on "Edit" } expect(page.status_code).to equal 200 @@ -41,6 +42,7 @@ describe "Scientific names", js: true do it "Crop wranglers can delete scientific names" do visit crop_path(zea_mays.crop) + click_link zea_mays.name expect(page).to have_link "Delete", href: scientific_name_path(zea_mays) within('.scientific_names') { click_on "Delete" } From 6825f8810f497e1b0416524196b6937050e62378 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 13 Jun 2019 20:01:21 +1200 Subject: [PATCH 291/549] tidy up seeds form --- app/views/seeds/_form.html.haml | 11 ++++++----- spec/features/seeds/adding_seeds_spec.rb | 10 +++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/views/seeds/_form.html.haml b/app/views/seeds/_form.html.haml index 96173af5f..9e5ee118e 100644 --- a/app/views/seeds/_form.html.haml +++ b/app/views/seeds/_form.html.haml @@ -13,13 +13,14 @@ %ul - @seed.errors.full_messages.each do |msg| %li= msg - = f.label :crop, 'Crop:', class: 'control-label' + = required_field_help_text + = f.label :crop, 'Crop' - if @planting = link_to @planting, planting_path(@planting) = f.hidden_field :parent_planting_id, value: @planting.id - else = auto_suggest @seed, :crop, class: 'form-control', default: @crop - %legend + %span.help-inline Can't find what you're looking for? = link_to "Request new crops.", new_crop_path .row @@ -42,9 +43,9 @@ .row .col-md-4.col-12= f.select(:organic, Seed::ORGANIC_VALUES, {}, default: 'unknown') - .col-md-4.col-12= f.select(:gmo, Seed::GMO_VALUES, {}, class: 'form-control', default: 'unknown') - .col-md-4.col-12= f.select(:heirloom, Seed::HEIRLOOM_VALUES, {}, class: 'form-control', default: 'unknown') - = f.text_area :description, rows: 6, class: 'form-control' + .col-md-4.col-12= f.select(:gmo, Seed::GMO_VALUES, {}, default: 'unknown') + .col-md-4.col-12= f.select(:heirloom, Seed::HEIRLOOM_VALUES, {}, default: 'unknown') + = f.text_area :description, rows: 6 %hr/ = t('.trade_help', site_name: ENV['GROWSTUFF_SITE_NAME']) diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb index e407c3782..36ce441dc 100644 --- a/spec/features/seeds/adding_seeds_spec.rb +++ b/spec/features/seeds/adding_seeds_spec.rb @@ -18,14 +18,14 @@ describe "Seeds", :js, :elasticsearch do describe "displays required and optional fields properly" do it { expect(page).to have_selector ".form-group.required", text: "Crop:" } - it { expect(page).to have_optional 'input#seed_quantity' } - it { expect(page).to have_optional 'input#seed_plant_before' } - it { expect(page).to have_optional 'input#seed_days_until_maturity_min' } - it { expect(page).to have_optional 'input#seed_days_until_maturity_max' } + it { expect(page).to have_selector 'input#seed_quantity' } + it { expect(page).to have_selector 'input#seed_plant_before' } + it { expect(page).to have_selector 'input#seed_days_until_maturity_min' } + it { expect(page).to have_selector 'input#seed_days_until_maturity_max' } it { expect(page).to have_selector '.form-group.required', text: 'Organic?' } it { expect(page).to have_selector '.form-group.required', text: 'GMO?' } it { expect(page).to have_selector '.form-group.required', text: 'Heirloom?' } - it { expect(page).to have_optional 'textarea#seed_description' } + it { expect(page).to have_selector 'textarea#seed_description' } it { expect(page).to have_selector '.form-group.required', text: 'Will trade:' } end From 10475cb7114e0bcd0c62adf7d106b2f6490e19a9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 13 Jun 2019 20:26:45 +1200 Subject: [PATCH 292/549] Matching labels on seeds form to specs --- app/views/seeds/_form.html.haml | 27 ++++++++++++------------ spec/features/seeds/adding_seeds_spec.rb | 10 ++++----- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/app/views/seeds/_form.html.haml b/app/views/seeds/_form.html.haml index 9e5ee118e..ddb8a1de3 100644 --- a/app/views/seeds/_form.html.haml +++ b/app/views/seeds/_form.html.haml @@ -24,32 +24,33 @@ Can't find what you're looking for? = link_to "Request new crops.", new_crop_path .row - .col-md-4.col-12= f.number_field :quantity, label: 'Quantity' - .col-md-8.col-12 + .col-12= f.number_field :quantity, label: 'Quantity' + .col-12 = f.text_field :plant_before, class: 'add-datepicker', value: @seed.plant_before ? @seed.plant_before.to_s(:ymd) : '' + .row - .col-md-4.col-12 + .col-12 = f.check_box :finished, label: 'Mark as finished' - %small= t('.finish_helper') - .col-md-8.col-12 - = f.text_field :finished_at, class: 'add-datepicker', - value: @seed.finished_at ? @seed.finished_at.to_s(:ymd) : '' + .col-12 + = f.text_field :finished_at, class: 'add-datepicker', value: @seed.finished_at ? @seed.finished_at.to_s(:ymd) : '' + .col-12 + %span.help-inline= t('.finish_helper') .row - .col-md-4.col-12= f.number_field :days_until_maturity_min, append: " days" - .col-md-4.col-12= f.number_field :days_until_maturity_max, append: " days" + .col-md-6.col-12= f.number_field :days_until_maturity_min, label_as_placeholder: true, label: 'min', prepend: 'Days until maturity' + .col-md-6.col-12= f.number_field :days_until_maturity_max, label_as_placeholder: true, label: 'max', prepend: 'to', append: "days" .row - .col-md-4.col-12= f.select(:organic, Seed::ORGANIC_VALUES, {}, default: 'unknown') - .col-md-4.col-12= f.select(:gmo, Seed::GMO_VALUES, {}, default: 'unknown') - .col-md-4.col-12= f.select(:heirloom, Seed::HEIRLOOM_VALUES, {}, default: 'unknown') + .col-md-4.col-12= f.select(:organic, Seed::ORGANIC_VALUES, {label: 'Organic?'}, default: 'unknown') + .col-md-4.col-12= f.select(:gmo, Seed::GMO_VALUES, {label: 'GMO?'}, default: 'unknown') + .col-md-4.col-12= f.select(:heirloom, Seed::HEIRLOOM_VALUES, {label: 'Heirloom?'}, default: 'unknown') = f.text_area :description, rows: 6 %hr/ = t('.trade_help', site_name: ENV['GROWSTUFF_SITE_NAME']) - = f.select(:tradable_to, Seed::TRADABLE_TO_VALUES, {}, label: 'Will trade') + = f.select(:tradable_to, Seed::TRADABLE_TO_VALUES, {label: 'Will trade'}) %span.help_inline - if current_member.location.blank? Don't forget to diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb index 36ce441dc..08d48e313 100644 --- a/spec/features/seeds/adding_seeds_spec.rb +++ b/spec/features/seeds/adding_seeds_spec.rb @@ -34,15 +34,15 @@ describe "Seeds", :js, :elasticsearch do fill_autocomplete "crop", with: "mai" select_from_autocomplete "maize" within "form#new_seed" do - fill_in "Quantity:", with: 42 - fill_in "Plant before:", with: "2014-06-15" - fill_in "Days until maturity:", with: 999 - fill_in "to", with: 1999 + fill_in "Quantity", with: 42 + fill_in "Plant before", with: "2014-06-15" + fill_in "min", with: 999 + fill_in "max", with: 1999 select "certified organic", from: "Organic?" select "non-certified GMO-free", from: "GMO?" select "heirloom", from: "Heirloom?" fill_in "Description", with: "It's killer." - select "internationally", from: "Will trade:" + select "internationally", from: "Will trade" click_button "Save" end end From d551a99da6678a6cc540702c5efaf8d586b60eb2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 13 Jun 2019 20:51:27 +1200 Subject: [PATCH 293/549] set text in post body to find in post rss spec --- spec/views/posts/index.rss.haml_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/views/posts/index.rss.haml_spec.rb b/spec/views/posts/index.rss.haml_spec.rb index 83576079f..030e22c05 100644 --- a/spec/views/posts/index.rss.haml_spec.rb +++ b/spec/views/posts/index.rss.haml_spec.rb @@ -4,21 +4,21 @@ describe 'posts/index.rss.haml', type: "view" do before do controller.stub(:current_user) { nil } author = FactoryBot.create(:member) - @post1 = FactoryBot.create(:post, id: 1, author: author) + @post1 = FactoryBot.create(:post, id: 1, author: author, body: 'This is some text.') @post2 = FactoryBot.create(:post, id: 2, author: author) assign(:posts, [@post1, @post2]) render end it 'shows RSS feed title' do - rendered.should have_content "Recent posts from all members" + expect(rendered).to have_content "Recent posts from all members" end it 'shows content of posts' do - rendered.should have_content "This is some text." + expect(rendered).to have_content "This is some text." end it 'gives the author in the item title' do - rendered.should have_content "#{@post1.subject} by #{@post1.author}" + expect(rendered).to have_content "#{@post1.subject} by #{@post1.author}" end end From 82661c577cae2d9aa3dd24706a04f07205aca2f8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 13 Jun 2019 21:05:29 +1200 Subject: [PATCH 294/549] Removing comments views --- app/views/comments/index.html.haml | 18 ------------- app/views/comments/show.html.haml | 17 ------------- spec/views/comments/index.html.haml_spec.rb | 28 --------------------- spec/views/comments/show.html.haml_spec.rb | 14 ----------- 4 files changed, 77 deletions(-) delete mode 100644 app/views/comments/index.html.haml delete mode 100644 app/views/comments/show.html.haml delete mode 100644 spec/views/comments/index.html.haml_spec.rb delete mode 100644 spec/views/comments/show.html.haml_spec.rb diff --git a/app/views/comments/index.html.haml b/app/views/comments/index.html.haml deleted file mode 100644 index c87781b16..000000000 --- a/app/views/comments/index.html.haml +++ /dev/null @@ -1,18 +0,0 @@ -= content_for :title, "Recent comments" - -= page_entries_info @comments -= render 'layouts/pagination', collection: @comments - -- @comments.each do |comment| - %h2 - Comment on - = link_to comment.post.subject, comment.post - = render partial: "single", locals: { comment: comment } - -= page_entries_info @comments -= render 'layouts/pagination', collection: @comments - -%p - Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} - = succeed "." do - = link_to "comments RSS feed", comments_path(format: 'rss') diff --git a/app/views/comments/show.html.haml b/app/views/comments/show.html.haml deleted file mode 100644 index 8d58dc0e5..000000000 --- a/app/views/comments/show.html.haml +++ /dev/null @@ -1,17 +0,0 @@ -= content_for :title, @comment.post.subject -- content_for :opengraph do - = tag("meta", property: "og:image", content: avatar_uri(@comment.post.author, 200)) - = tag("meta", property: "og:image:user_generated", content: "true") - = tag("meta", property: "og:title", content: @comment.post.subject) - = tag("meta", property: "og:description", content: og_description(@comment.post.body)) - = tag("meta", property: "og:type", content: "website") - = tag("meta", property: "og:url", content: request.original_url) - = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) - -= render partial: "posts/single", locals: { post: @comment.post } - -%h2 Showing 1 comment - -= render partial: "single", locals: { comment: @comment } - -= link_to "View all comments", post_path(@comment.post) diff --git a/spec/views/comments/index.html.haml_spec.rb b/spec/views/comments/index.html.haml_spec.rb deleted file mode 100644 index b9e577562..000000000 --- a/spec/views/comments/index.html.haml_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'rails_helper' - -describe "comments/index" do - before do - controller.stub(:current_user) { nil } - page = 1 - per_page = 2 - total_entries = 2 - comments = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| - pager.replace([ - FactoryBot.create(:comment), - FactoryBot.create(:comment, body: 'ROFL') - ]) - end - assign(:comments, comments) - render - end - - it "renders a list of comments" do - render - rendered.should have_content 'OMG LOL' - rendered.should have_content 'ROFL' - end - - it "contains an RSS feed link" do - assert_select "a", href: comments_path(format: 'rss') - end -end diff --git a/spec/views/comments/show.html.haml_spec.rb b/spec/views/comments/show.html.haml_spec.rb deleted file mode 100644 index 32a524d65..000000000 --- a/spec/views/comments/show.html.haml_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'rails_helper' - -describe "comments/show" do - before do - controller.stub(:current_user) { nil } - @comment = assign(:comment, FactoryBot.create(:comment)) - render - end - - it "renders the comment" do - rendered.should have_content @comment.author.login_name - rendered.should have_content @comment.body - end -end From e801a1d7c6b31aae83b105d62110bf3f58c91fc9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 13 Jun 2019 21:06:10 +1200 Subject: [PATCH 295/549] Removing unused views --- app/views/gardens/_thumbnail.html.haml | 37 ---------- app/views/harvests/_list.html.haml | 12 ---- app/views/layouts/_header.bak | 78 --------------------- app/views/plantings/_list.html.haml | 14 ---- app/views/plantings/_progress_bar.html.haml | 13 ---- app/views/plantings/_stats.haml | 13 ---- app/views/seeds/_list.html.haml | 2 - app/views/shared/_form_optional.html.haml | 2 - 8 files changed, 171 deletions(-) delete mode 100644 app/views/gardens/_thumbnail.html.haml delete mode 100644 app/views/harvests/_list.html.haml delete mode 100644 app/views/layouts/_header.bak delete mode 100644 app/views/plantings/_list.html.haml delete mode 100644 app/views/plantings/_progress_bar.html.haml delete mode 100644 app/views/plantings/_stats.haml delete mode 100644 app/views/seeds/_list.html.haml delete mode 100644 app/views/shared/_form_optional.html.haml diff --git a/app/views/gardens/_thumbnail.html.haml b/app/views/gardens/_thumbnail.html.haml deleted file mode 100644 index f26ab62b9..000000000 --- a/app/views/gardens/_thumbnail.html.haml +++ /dev/null @@ -1,37 +0,0 @@ -.panel.panel-success - .panel-heading - %h3.panel-title - = link_to display_garden_name(garden), garden_path(garden) - - if can? :edit, garden - %a.text-right{ href: edit_garden_path(garden), role: "button", id: "edit_garden_glyphicon" } - %span.glyphicon.glyphicon-pencil{ title: "Edit" } - .panel-body{ id: "gardens_panel_body" } - .row - .col-md-4 - = link_to image_tag(garden_image_path(garden), - alt: garden.name, class: 'img'), - garden_path(garden) - .col-md-8 - %dl.dl-horizontal - %dt Name : - %dd= link_to display_garden_name(garden), garden_path(garden) - %dt Location : - %dd - - if garden.location.blank? - not specified - - else - = link_to garden.location, place_path(garden.location, anchor: "gardens") - %dt Area : - %dd= garden.area.nil? ? "not specified" : pluralize(garden.area, garden.area_unit) - %dt Active? : - %dd= garden.active ? "Yes" : "No" - .col-md-12 - %b - = localize_plural(garden.plantings, Planting) - = ":" - = display_garden_plantings(garden.plantings.current.includes(:crop).first(2)) - - if garden.plantings.size > 2 - = link_to "See more plantings >>", garden_path(garden) - .panel-footer - %dt Description - %dd= display_garden_description(garden) diff --git a/app/views/harvests/_list.html.haml b/app/views/harvests/_list.html.haml deleted file mode 100644 index fa4d3e01f..000000000 --- a/app/views/harvests/_list.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -- harvests.each do |harvest| - - cache harvest do - .card - .view.overlay - = link_to harvest do - %img.card-img-top.img-responsive{alt: harvest, src: harvest.default_photo.fullsize_url}/ - .card-body.p-3 - %h5.card-title.font-weight-bold.fuchsia-rose-text.mb-0 - = link_to harvest, harvest - %small - %i= harvest.owner.location - %hr/ diff --git a/app/views/layouts/_header.bak b/app/views/layouts/_header.bak deleted file mode 100644 index b4f35ace5..000000000 --- a/app/views/layouts/_header.bak +++ /dev/null @@ -1,78 +0,0 @@ --# .navbar.navbar-default.navbar-fixed-top{ role: "navigation" } -%nav.navbar.navbar-dark.default-color.bg-dark - .container-fluid - .navbar-header - %button.navbar-toggle{"data-target" => ".navbar-responsive-collapse", "data-toggle" => "collapse", type: "button"} - %span.glyphicon.glyphicon-menu-hamburger.text-white - %a.navbar-brand.hidden-xs{ href: root_path } - = image_tag("growstuff-brand.png", size: "200x50", alt: ENV['GROWSTUFF_SITE_NAME']) - %a.navbar-brand.visible-xs{ href: root_path } - = image_tag("growstuff-apple-touch-icon-precomposed.png", - size: "40x40", alt: ENV['GROWSTUFF_SITE_NAME']) - = render 'crops/search_bar' - - .navbar-collapse.collapse.navbar-responsive-collapse - %ul.nav.navbar-nav.navbar-right - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path }= t('.crops') - %ul.dropdown-menu - %li= link_to t('.browse_crops'), crops_path - %li= link_to t('.seeds'), seeds_path - %li= link_to t('.plantings'), plantings_path - %li= link_to t('.harvests'), harvests_path - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: members_path } - = t('.community') - %ul.dropdown-menu - %li= link_to t('.community_map'), places_path - %li= link_to t('.browse_members'), members_path - %li= link_to t('.posts'), posts_path - %li= link_to t('.forums'), forums_path - - if member_signed_in? - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: root_path } - - if current_member.notifications.unread_count.positive? - = t('.your_stuff', unread_count: current_member.notifications.unread_count) - - else - = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) - %ul.dropdown-menu - %li - = link_to member_path(current_member) do - = member_icon - = t('.profile') - %li - = link_to member_gardens_path(current_member) do - = garden_icon - = t('.gardens') - %li - = link_to member_plantings_path(current_member) do - = planting_icon - = t('.plantings') - %li - = link_to member_harvests_path(current_member) do - = harvest_icon - = t('.harvest') - %li - = link_to member_seeds_path(current_member) do - = seed_icon - = t('.seeds') - %li= link_to t('.posts'), member_posts_path(current_member) - %li - - if current_member.notifications.unread_count.positive? - = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), - notifications_path) - - else - = link_to(t('.inbox'), notifications_path) - - if current_member.role?(:crop_wrangler) || current_member.role?(:admin) - %li.divider{ role: 'presentation' } - - if current_member.role?(:crop_wrangler) - %li= link_to t('.crop_wrangling'), wrangle_crops_path - - if current_member.role?(:admin) - %li= link_to t('.admin'), admin_path - - %li= link_to t('.sign_out'), destroy_member_session_path, method: :delete - - - else - %li= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' - %li= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' - diff --git a/app/views/plantings/_list.html.haml b/app/views/plantings/_list.html.haml deleted file mode 100644 index 0e2a87148..000000000 --- a/app/views/plantings/_list.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -- plantings.each do |planting| - - cache planting do - .card - .view.overlay - = link_to planting do - %img.card-img-top.img-responsive{alt: planting, src: planting_image_path(planting, full_size: true)}/ - .card-body.p-3 - %h5.card-title.font-weight-bold.fuchsia-rose-text.mb-0 - = link_to planting, planting - - %p.float-right - = link_to planting.owner do - = image_tag(avatar_uri(planting.owner, 50), alt: '', class: 'img img-responsive avatar rounded-circle') - %hr/ diff --git a/app/views/plantings/_progress_bar.html.haml b/app/views/plantings/_progress_bar.html.haml deleted file mode 100644 index aa2e6391b..000000000 --- a/app/views/plantings/_progress_bar.html.haml +++ /dev/null @@ -1,13 +0,0 @@ -.progress - - if progress.nil? - .progress-bar-text= status - - else - -# haml-lint:disable InlineStyles - %div{ class: "progress-bar progress-bar-#{status}", role: "progressbar", style: "width: #{progress}%" } - - if progress >= 30 - .progress-bar-text - #{sprintf '%.0f', progress}% - - if progress < 30 - .progress-bar-text - #{sprintf '%.0f', progress}% - -# haml-lint:enable InlineStyles diff --git a/app/views/plantings/_stats.haml b/app/views/plantings/_stats.haml deleted file mode 100644 index 31c87329e..000000000 --- a/app/views/plantings/_stats.haml +++ /dev/null @@ -1,13 +0,0 @@ -.planting-stats - %span.badge.harvest-count{'data-toggle': "tooltip", 'data-placement': "top", title: 'Harvests'} - = harvest_icon - = planting.harvests.size - %span.badge.child-seeds-count{'data-toggle': "tooltip", 'data-placement': "top", title: 'Seeds saved'} - = seed_icon - = planting.child_seeds.size - %span.badge.photos-count{'data-toggle': "tooltip", 'data-placement': "top", title: 'Photos'} - = photo_icon - = planting.photos.size - %span.badge.photos-count{'data-toggle': "tooltip", 'data-placement': "top", title: 'Age in days'} - = planting_icon - = planting.age_in_days diff --git a/app/views/seeds/_list.html.haml b/app/views/seeds/_list.html.haml deleted file mode 100644 index 2f503aba9..000000000 --- a/app/views/seeds/_list.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -- seeds.each do |seed| - = render 'seeds/card', seed: seed diff --git a/app/views/shared/_form_optional.html.haml b/app/views/shared/_form_optional.html.haml deleted file mode 100644 index 0b298d0c1..000000000 --- a/app/views/shared/_form_optional.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -%span.help-block.optional - = I18n.t 'optional', scope: 'forms' From 8e986ff2c38d1bed58c9789a71778645eb494384 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 13 Jun 2019 22:31:53 +1200 Subject: [PATCH 296/549] consistent use of card-link on crops#show --- app/views/crops/_find_seeds.html.haml | 8 ++++---- app/views/crops/_harvests.html.haml | 7 ++++--- app/views/crops/_plantings.html.haml | 5 +++-- app/views/crops/show.html.haml | 14 ++++++++++---- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/app/views/crops/_find_seeds.html.haml b/app/views/crops/_find_seeds.html.haml index d13764f7c..60feea431 100644 --- a/app/views/crops/_find_seeds.html.haml +++ b/app/views/crops/_find_seeds.html.haml @@ -8,17 +8,17 @@ %ul.list-group - crop.seeds.tradable.each do |seed| %li.list-group-item - = link_to "#{seed.owner} will trade #{seed.tradable_to}.", seed_path(seed) + = link_to "#{seed.owner} will trade #{seed.tradable_to}.", seed_path(seed), class: 'card-link' = render 'members/location', member: seed.owner %li.list-group-item.d-flex.justify-content-between.align-items-center - = link_to crop_seeds_path(crop) do + = link_to crop_seeds_path(crop), class: 'card-link' do = seed_icon View all #{crop.name} seeds %span.badge.badge-primary.badge-pill=crop.seeds.size %ul.list-group %li.list-group-item - = link_to crop_ebay_seeds_url(crop), + = link_to crop_ebay_seeds_url(crop), class: 'card-link', target: "_blank", rel: "noopener noreferrer" do = icon 'fas', 'money-check-alt' @@ -27,7 +27,7 @@ - if crop.approved? - if current_member %li.list-group-item - = link_to new_seed_path(crop_id: crop.id) do + = link_to new_seed_path(crop_id: crop.id), class: 'card-link' do = seed_icon List #{crop.name} seeds to trade - else diff --git a/app/views/crops/_harvests.html.haml b/app/views/crops/_harvests.html.haml index ad25f65b5..d004ef447 100644 --- a/app/views/crops/_harvests.html.haml +++ b/app/views/crops/_harvests.html.haml @@ -7,13 +7,14 @@ %ul.list-group.list-group-flush - crop.harvests.order(harvested_at: :desc).limit(3).each do |harvest| %li.list-group-item - = harvest_icon - = link_to "#{harvest.owner} harvested #{display_quantity(harvest)}.", harvest_path(harvest) + = link_to harvest_path(harvest), class: 'card-link' do + = harvest_icon + #{harvest.owner} harvested #{display_quantity(harvest)}. .float-right= render 'members/location', member: harvest.owner .harvest-timeago %small #{distance_of_time_in_words(harvest.harvested_at, Time.zone.now)} ago. .card-footer - %p= link_to "View all #{crop.name} harvests", crop_harvests_path(crop) + %p= link_to "View all #{crop.name} harvests", crop_harvests_path(crop), class: 'card-link' - if crop.approved? - if current_member %p= link_to "Harvest #{crop.name}", new_harvest_path(crop_id: crop.id), class: 'btn btn-block' diff --git a/app/views/crops/_plantings.html.haml b/app/views/crops/_plantings.html.haml index 889eb8d26..8aff740a6 100644 --- a/app/views/crops/_plantings.html.haml +++ b/app/views/crops/_plantings.html.haml @@ -5,8 +5,9 @@ %ul.list-group.list-group-flush - crop.plantings.order(planted_at: :desc).limit(5).each do |planting| %li.list-group-item - = planting_icon - = link_to planting, planting + = link_to planting, class: 'card-link' do + = planting_icon + = planting .float-right= render 'members/location', member: planting.owner .card-footer - if crop.approved? diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 0d134d86c..08487eff5 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -87,13 +87,13 @@ #{@crop.name.capitalize} plantings %span.badge.badge-primary.badge-pill=@crop.plantings.size .list-group-item.d-flex.justify-content-between.align-items-center - = link_to crop_harvests_path(@crop) do + = link_to crop_harvests_path(@crop), class: 'card-link' do = harvest_icon #{@crop.name.capitalize} harvests %span.badge.badge-primary.badge-pill=@crop.harvests.size .list-group-item.d-flex.justify-content-between.align-items-center - = link_to crop_seeds_path(@crop) do + = link_to crop_seeds_path(@crop), class: 'card-link' do = seed_icon #{@crop.name.capitalize} seeds %span.badge.badge-primary.badge-pill=@crop.seeds.size @@ -124,17 +124,23 @@ %li.list-group-item = link_to "https://openfarm.cc/en/crops/#{CGI.escape @crop.name}", + class: 'card-link', target: "_blank", rel: "noopener noreferrer" do = icon 'fas', 'external-link-alt' OpenFarm - Growing guide %li.list-group-item = link_to "http://www.gardenate.com/plant/#{CGI.escape @crop.name}", - target: "_blank", rel: "noopener noreferrer" do + target: "_blank", + class: 'card-link', + rel: "noopener noreferrer" do = icon 'fas', 'external-link-alt' Gardenate - Planting reminders - if current_member && current_member.location %li.list-group-item - = link_to 'http://www.google.com/search?q=' + CGI.escape(['Growing', @crop.name, current_member.location].join(' ')), target: "_blank", rel: "noopener noreferrer" do + = link_to 'http://www.google.com/search?q=' + CGI.escape(['Growing', @crop.name, current_member.location].join(' ')), + target: "_blank", + class: 'card-link', + rel: "noopener noreferrer" do = icon 'fas', 'external-link-alt' Google From fbef77b5d03d06b04e88900ca2cae1b38fb25711 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 13 Jun 2019 23:00:54 +1200 Subject: [PATCH 297/549] Fix members list spec, and DRY --- spec/features/members_list_spec.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/features/members_list_spec.rb b/spec/features/members_list_spec.rb index 9523b6238..f00b1daaf 100644 --- a/spec/features/members_list_spec.rb +++ b/spec/features/members_list_spec.rb @@ -6,25 +6,25 @@ describe "members list" do let!(:member2) { create :member, login_name: "Zephyrosaurus", confirmed_at: Time.zone.parse('2014-01-11') } let!(:member3) { create :member, login_name: "Testingname", confirmed_at: Time.zone.parse('2014-05-09') } - it "default alphabetical sort" do + subject { page.all("#maincontainer h4.login-name") } + + before do visit members_path expect(page).to have_css "#sort" expect(page).to have_selector "form" + end + + it "default alphabetical sort" do click_button('Show') - all_links = page.all("#maincontainer p.login-name") - expect(all_links.first).to have_text member1.login_name - expect(all_links.last).to have_text member2.login_name + expect(subject.first).to have_text member1.login_name + expect(subject.last).to have_text member2.login_name end it "recently joined sort" do - visit members_path - expect(page).to have_css "#sort" - expect(page).to have_selector "form" select("recently", from: 'sort') click_button('Show') - all_links = page.all("#maincontainer p.login-name") - expect(all_links.first).to have_text member3.login_name - expect(all_links.last).to have_text member1.login_name + expect(subject.first).to have_text member3.login_name + expect(subject.last).to have_text member1.login_name end end end From a25955714dc0938e8526a238290119077f721ca4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 13 Jun 2019 23:04:06 +1200 Subject: [PATCH 298/549] class on member link, so spec finds it --- app/views/members/_member.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/members/_member.haml b/app/views/members/_member.haml index c8e595cfb..ec043d7ef 100644 --- a/app/views/members/_member.haml +++ b/app/views/members/_member.haml @@ -4,7 +4,7 @@ = link_to member do = image_tag(avatar_uri(member, 150), class: 'rounded-circle img-fluid shadow member-avatar', alt: member) .card-body - %h4.card-title= link_to member, member + %h4.card-title.login-name= link_to member, member %hr/ %p %small From 6f036271c53e475c3ed4992a4e2ad8f773f81824 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 13 Jun 2019 23:05:02 +1200 Subject: [PATCH 299/549] update harvest spec to find edit behind actions menu --- spec/features/harvests/harvesting_a_crop_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index e91f84c81..626207f34 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -85,6 +85,7 @@ describe "Harvesting a crop", :js, :elasticsearch do before do visit harvest_path(existing_harvest) + click_link 'Action' click_link "Edit" end From 52edaae43b018bbdde4a0e3dc3debe42dfdb0ea1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 13 Jun 2019 23:05:02 +1200 Subject: [PATCH 300/549] update harvest spec to find edit behind actions menu --- spec/features/harvests/harvesting_a_crop_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index e91f84c81..c425dfa4f 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -85,6 +85,7 @@ describe "Harvesting a crop", :js, :elasticsearch do before do visit harvest_path(existing_harvest) + click_link 'Actions' click_link "Edit" end From c0c1b1df706b488c8ec3ee742ad5af69e771f4cc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 09:56:12 +1200 Subject: [PATCH 301/549] Tidy up on photos#new --- app/views/photos/new.html.haml | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/app/views/photos/new.html.haml b/app/views/photos/new.html.haml index bac4952a9..546eb43af 100644 --- a/app/views/photos/new.html.haml +++ b/app/views/photos/new.html.haml @@ -1,8 +1,7 @@ - content_for :title, "New Photo" -%h3 - Choose photo for - = @item +%h1 New Photo +%h2 Choose photo for #{link_to @item, @item} - if @flickr_auth %p @@ -11,33 +10,32 @@ = link_to @flickr_auth.name, "http://flickr.com/photos/#{@flickr_auth.uid}" Please select a photo from your recent uploads. - - if @sets && @current_set - %h2= @sets.key(@current_set) - if @sets && !@sets.empty? %p - = form_tag(new_photo_path, method: :get, class: 'form-inline') do - = label_tag :set, "Choose a photo album:", class: 'control-label' - = select_tag :set, options_for_select(@sets, @current_set), class: 'input-large' + = bootstrap_form_tag(url: new_photo_path, method: :get, layout: :inline) do |f| + = f.select :set, options_for_select(@sets, @current_set), label: "Choose a photo album" = hidden_field_tag :type, @type = hidden_field_tag :id, @id - = submit_tag "Search", class: 'btn btn-primary' + = f.submit "Search", class: "btn btn-success" + - if @sets && @current_set + %h2= @sets.key(@current_set) + .row.pagination .col-md-12= page_entries_info @photos - .col-md-12= render 'layouts/pagination', collection: @photos + .col-md-12= will_paginate @photos .row - @photos.each do |p| - .col-md-2.six-across + .col-md-2.col-6 .thumbnail{ style: 'height: 220px' } - = link_to image_tag(FlickRaw.url_q(p), alt: '', class: 'img'), + = link_to image_tag(FlickRaw.url_q(p), alt: '', class: 'img', width: 150, height: 150), photos_path(photo: { flickr_photo_id: p.id }, type: @type, id: @id), method: :post - %p - = p.title + %p.photo-title= p.title .row.pagination - .col-md-12= render 'layouts/pagination', collection: @photos + .col-md-12= will_paginate @photos - else .alert You must From 729254ac24ffb6066d6853ccf93d4ed27a09f096 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 10:00:28 +1200 Subject: [PATCH 302/549] added href to link so capybara finds it --- app/views/harvests/_actions.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/harvests/_actions.html.haml b/app/views/harvests/_actions.html.haml index a40b20c9d..7cb6ca9a0 100644 --- a/app/views/harvests/_actions.html.haml +++ b/app/views/harvests/_actions.html.haml @@ -1,6 +1,6 @@ - if can?(:edit, harvest) .dropdown.float-right.harvest-actions - %a#harvest-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button"} Actions + %a#harvest-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button", href: '#'} Actions .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "harvest-actions-button"} = harvest_edit_button(harvest, classes: 'dropdown-item') = add_photo_button(harvest, classes: 'dropdown-item') From 4cedc6e26272cdbb8a98f562a27c30aa7fe5e447 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 10:03:51 +1200 Subject: [PATCH 303/549] Action menus for photos#show --- app/views/photos/_actions.html.haml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/photos/_actions.html.haml b/app/views/photos/_actions.html.haml index 1b19a50a5..1329e04f5 100644 --- a/app/views/photos/_actions.html.haml +++ b/app/views/photos/_actions.html.haml @@ -1,7 +1,7 @@ -.photo-actions - - if can?(:edit, @photo) && can?(:destroy, @photo) - %p - - if can?(:edit, @photo) - = edit_button(edit_photo_path(@photo)) - - if can?(:destroy, @photo) - = delete_button(@photo) +- if can?(:edit, @photo) && can?(:destroy, @photo) + .dropdown.float-right.photo-actions + %a#harvest-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button", href: '#'} Actions + .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "harvest-actions-button"} + = edit_button(edit_photo_path(@photo), classes: 'dropdown-item') + .dropdown-divider + = delete_button(@photo, classes: 'dropdown-item text-danger') From 9a5ebc52608fe4fbc11161fbbc37740335adc9f8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 10:06:48 +1200 Subject: [PATCH 304/549] rename photos/photo_associations to photos/associations --- .../{_photo_associations.html.haml => _associations.html.haml} | 0 app/views/photos/show.html.haml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename app/views/photos/{_photo_associations.html.haml => _associations.html.haml} (100%) diff --git a/app/views/photos/_photo_associations.html.haml b/app/views/photos/_associations.html.haml similarity index 100% rename from app/views/photos/_photo_associations.html.haml rename to app/views/photos/_associations.html.haml diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index ae11fe521..dd4e752a2 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -35,4 +35,4 @@ = @photo.license_name - if @photo.associations? - = render "photo_associations", photo: @photo \ No newline at end of file + = render "associations", photo: @photo \ No newline at end of file From f8e9cd8fbf1f03310fe6324699c195ce81cef082 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 10:11:55 +1200 Subject: [PATCH 305/549] Tidy up photo associations on photos#show --- app/helpers/icons_helper.rb | 4 ++++ app/views/photos/_association_delete_button.haml | 6 ++++++ app/views/photos/_associations.html.haml | 8 ++++---- app/views/photos/_photo_association_delete.haml | 5 ----- 4 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 app/views/photos/_association_delete_button.haml delete mode 100644 app/views/photos/_photo_association_delete.haml diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index bb6c61ee9..071f2dc96 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -57,6 +57,10 @@ module IconsHelper planted_from end + def delete_association_icon + icon('fas', 'backspace') + end + def sunniness_icon(sunniness) if sunniness.present? image_tag("sunniness_#{sunniness}.png", class: 'img', alt: sunniness, width: 55) diff --git a/app/views/photos/_association_delete_button.haml b/app/views/photos/_association_delete_button.haml new file mode 100644 index 000000000..1a0f0510f --- /dev/null +++ b/app/views/photos/_association_delete_button.haml @@ -0,0 +1,6 @@ +- if can? :edit, photo + = link_to photo_associations_path(photo_id: photo.id, type: type, id: thing.id), + data: { confirm: "Removing photo from this #{type}. Are you sure?" }, + method: 'delete', class: 'text-warning btn-sm' do + = delete_association_icon + diff --git a/app/views/photos/_associations.html.haml b/app/views/photos/_associations.html.haml index 2f1d34317..7486321ad 100644 --- a/app/views/photos/_associations.html.haml +++ b/app/views/photos/_associations.html.haml @@ -5,22 +5,22 @@ %li = planting_icon = link_to t('photos.show.planting', planting: planting.to_s, owner: planting.owner.to_s), planting_path(planting) - = render partial: "photo_association_delete", locals: { photo: @photo, type: 'planting', thing: planting } + = render "association_delete_button", photo: @photo, type: 'planting', thing: planting - @photo.harvests.each do |harvest| %li = harvest_icon = link_to t('photos.show.harvest', crop: harvest.crop.name, owner: harvest.owner.to_s), harvest_path(harvest) - = render partial: "photo_association_delete", locals: { photo: @photo, type: 'harvest', thing: harvest } + = render "association_delete_button", photo: @photo, type: 'harvest', thing: harvest - @photo.gardens.each do |garden| %li = garden_icon = link_to t('photos.show.garden', garden: garden.to_s, owner: garden.owner.to_s), garden_path(garden) - = render partial: "photo_association_delete", locals: { photo: @photo, type: 'garden', thing: garden } + = render "association_delete_button", photo: @photo, type: 'garden', thing: garden - @photo.seeds.each do |seed| %li = seed_icon = link_to t('photos.show.seed', seed: seed.to_s, owner: seed.owner.to_s), seed_path(seed) - = render partial: "photo_association_delete", locals: { photo: @photo, type: 'seed', thing: seed } + = render "association_delete_button", photo: @photo, type: 'seed', thing: seed diff --git a/app/views/photos/_photo_association_delete.haml b/app/views/photos/_photo_association_delete.haml deleted file mode 100644 index 9f33d85ba..000000000 --- a/app/views/photos/_photo_association_delete.haml +++ /dev/null @@ -1,5 +0,0 @@ -- if can? :edit, photo - = link_to photo_associations_path(photo_id: photo.id, type: type, id: thing.id), - method: 'delete', class: 'btn btn-danger btn-xs' do - %i.fas.fa-backspace - From 6e9207c2ed3c33db913877b261f5c818134111f7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 10:13:02 +1200 Subject: [PATCH 306/549] Fix tabulation error in haml --- app/views/crops/search.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/crops/search.html.haml b/app/views/crops/search.html.haml index 8ae4119fd..c98029a0a 100644 --- a/app/views/crops/search.html.haml +++ b/app/views/crops/search.html.haml @@ -9,8 +9,8 @@ %h1 Crop search - content_for :breadcrumbs do - %li.breadcrumb-item= link_to 'Crops', crops_path - %li.breadcrumb-item.active= link_to 'Search', search_crops_path(term: @term) + %li.breadcrumb-item= link_to 'Crops', crops_path + %li.breadcrumb-item.active= link_to 'Search', search_crops_path(term: @term) %div = form_tag search_crops_path, method: :get, id: 'crop-search', class: 'form-inline' do From 22e7a853886c6c59fdbe0fe534661cdeceddd367 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 10:54:30 +1200 Subject: [PATCH 307/549] inline search form on crops#search --- app/views/crops/search.html.haml | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/app/views/crops/search.html.haml b/app/views/crops/search.html.haml index c98029a0a..4891dadb4 100644 --- a/app/views/crops/search.html.haml +++ b/app/views/crops/search.html.haml @@ -2,7 +2,7 @@ - content_for :title, "Crops matching \"#{@term}\"" %h1 Crops matching "#{@term}" - if @crops - %h2 #{@crops.size} total + %h2.text-muted Found #{@crops.size} total - else - content_for :title, "Crop search" @@ -12,15 +12,14 @@ %li.breadcrumb-item= link_to 'Crops', crops_path %li.breadcrumb-item.active= link_to 'Search', search_crops_path(term: @term) -%div - = form_tag search_crops_path, method: :get, id: 'crop-search', class: 'form-inline' do - .form-group - = label_tag :term, "Search crops:", class: 'sr-only' - = text_field_tag 'term', nil, - class: 'search-query input-medium form-control', - placeholder: 'Search crops', - value: @term - = submit_tag "Search", class: 'btn btn-primary' +.search-form + = bootstrap_form_tag(url: search_crops_path, method: :get, id: 'crop-search', layout: :inline) do |f| + = f.label :term, "Search crops:", class: 'sr-only' + = f.text_field 'term', class: 'search-query input-medium', + placeholder: 'Search crops', + label: 'crop', + value: @term + = f.submit "Search", class: 'btn btn-success' - if @crops.empty? %h2 No results found @@ -32,7 +31,7 @@ instead. - else - .pagination= render 'layouts/pagination', collection: @crops + .pagination= will_paginate @crops .crops .row @@ -40,4 +39,4 @@ .col-6.col-md-3= render 'crops/thumbnail', crop: crop - .pagination= render 'layouts/pagination', collection: @crops + .pagination= will_paginate @crops From c0b2a8431ba04e37e9ad46e6fd0d796f15bb61ce Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 11:01:16 +1200 Subject: [PATCH 308/549] Reinstate likes --- app/helpers/icons_helper.rb | 4 ++++ app/views/posts/_likes.html.haml | 18 ++++++++++++++++++ app/views/posts/show.html.haml | 4 +++- 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 app/views/posts/_likes.html.haml diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 071f2dc96..66274c1f7 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -61,6 +61,10 @@ module IconsHelper icon('fas', 'backspace') end + def like_icon + icon('fas', 'thumbs-up') + end + def sunniness_icon(sunniness) if sunniness.present? image_tag("sunniness_#{sunniness}.png", class: 'img', alt: sunniness, width: 55) diff --git a/app/views/posts/_likes.html.haml b/app/views/posts/_likes.html.haml new file mode 100644 index 000000000..56ed606d7 --- /dev/null +++ b/app/views/posts/_likes.html.haml @@ -0,0 +1,18 @@ + +- if member_signed_in? + - if !post.members.include? current_member + - if can?(:new, Like) + = link_to 'Like', likes_path(post_id: post.id, format: :json), + method: :post, remote: true, class: 'post-like btn' + - else + - like = post.likes.find_by(member: current_member) + - if like && can?(:destroy, like) + = link_to 'Unlike', like_path(id: like.id, format: :json), + method: :delete, remote: true, class: 'post-like btn' + + +%span.badge.badge-info + .like-count + - unless post.likes.empty? + = like_icon + = pluralize(post.likes.count, "like") diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index 186f5dd88..f81a9efa7 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -38,9 +38,11 @@ %h2.display-3.float-left = @post.subject = render 'posts/actions', post: @post - .card-body= render 'posts/single', post: @post + .card-body + = render 'posts/single', post: @post .card-footer + = render 'posts/likes', post: @post .float-right - if can? :create, Comment = link_to new_comment_path(post_id: @post.id), class: 'btn' do From 798fff43cf2c2606c5ed8987843a7fd151f6200d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 11:20:06 +1200 Subject: [PATCH 309/549] DRY the photos helper --- app/helpers/photos_helper.rb | 49 ++++++++++++------------------------ 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb index e78bc12da..b61edcf84 100644 --- a/app/helpers/photos_helper.rb +++ b/app/helpers/photos_helper.rb @@ -1,55 +1,38 @@ module PhotosHelper def crop_image_path(crop, full_size: false) - if crop.default_photo.present? - photo = crop.default_photo - full_size ? photo.fullsize_url : photo.thumbnail_url - else - placeholder_image - end + photo_or_placeholder(crop, full_size: full_size) end def garden_image_path(garden, full_size: false) - if garden.default_photo.present? - photo = garden.default_photo - full_size ? photo.fullsize_url : photo.thumbnail_url - else - placeholder_image - end + photo_or_placeholder(garden, full_size: full_size) end def planting_image_path(planting, full_size: false) - if planting.photos.present? - photo = planting.photos.order(date_taken: :desc).first - full_size ? photo.fullsize_url : photo.thumbnail_url - else - placeholder_image - end + photo_or_placeholder(planting, full_size: full_size) end def harvest_image_path(harvest, full_size: false) - if harvest.photos.present? - photo = harvest.photos.order(date_taken: :desc).first - full_size ? photo.fullsize_url : photo.thumbnail_url - elsif harvest.planting.present? - planting_image_path(harvest.planting, full_size: full_size) - else - placeholder_image - end + photo_or_placeholder(harvest, full_size: full_size) end def seed_image_path(seed, full_size: false) - if seed.default_photo.present? - photo = seed.default_photo - full_size ? photo.fullsize_url : photo.thumbnail_url - elsif seed.crop.default_photo.present? - photo = seed.crop.default_photo - full_size ? photo.fullsize_url : photo.thumbnail_url + photo_or_placeholder(seed, full_size: full_size) + end + + private + + def photo_or_placeholder(item, full_size: false) + if item.default_photo.present? + item_photo(item, full_size: full_size) else placeholder_image end end - private + def item_photo(item, full_size:) + photo = item.default_photo + full_size ? photo.fullsize_url : photo.thumbnail_url + end def placeholder_image 'placeholder_150.png' From def468827cbef486e72ce377b43ed934354076bc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 11:21:23 +1200 Subject: [PATCH 310/549] Update helper spec --- spec/helpers/plantings_helper_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/helpers/plantings_helper_spec.rb b/spec/helpers/plantings_helper_spec.rb index f71fc6ef4..af69f9c49 100644 --- a/spec/helpers/plantings_helper_spec.rb +++ b/spec/helpers/plantings_helper_spec.rb @@ -10,7 +10,7 @@ describe PlantingsHelper do planted_from: '', owner: member) result = helper.display_planting(planting) - expect(result).to eq "crop_lady." + expect(result).to eq "crop_lady planted magic bean." end it "does not have a quantity provided" do From bd8ab9365dd06a02cc5e9a5d85841c39a701d7d1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 11:26:11 +1200 Subject: [PATCH 311/549] padding on member icon --- app/assets/stylesheets/overrides.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index 2987ffa9b..f586489c5 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -95,6 +95,7 @@ h3 { border-radius: 50%; z-index: 2; position: relative; + padding: 1em; } .profile-sidebar { From 6086a1aaa56316902013d762caec922834231297 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 11:26:29 +1200 Subject: [PATCH 312/549] strip tags on subjects --- app/views/posts/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index 5d3cc777a..62ffed5ce 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -18,7 +18,7 @@ = render 'members/avatar', member: post.author .col-10.border-left %h5.card-title - = link_to post.subject, post + = link_to strip_tags(post.subject), post - if post.comments.size.positive? %span.badge.badge-pill.badge-info.float-right = icon 'fas', 'comment' From e0b9acc27d8d2bb3e5ed4d340e8d65945a9d915a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 11:27:43 +1200 Subject: [PATCH 313/549] Tidier link to member posts --- app/views/posts/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index f81a9efa7..f73a8aecf 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -27,7 +27,7 @@ - content_for :breadcrumbs do %li.breadcrumb-item= link_to @post.author, @post.author - %li.breadcrumb-item= link_to 'posts', posts_path(member_slug: @post.author.slug) + %li.breadcrumb-item= link_to 'posts', member_posts_path(member_slug: @post.author.slug) %li.breadcrumb-item.active{"aria-current" => "page"}= @post.subject .row From 58e28b9311660ae9fcf3a20687634ac859aa2cd2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 11:45:55 +1200 Subject: [PATCH 314/549] nicer link to member gardens --- app/views/gardens/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/gardens/index.html.haml b/app/views/gardens/index.html.haml index 19d3210e6..a7623ec9e 100644 --- a/app/views/gardens/index.html.haml +++ b/app/views/gardens/index.html.haml @@ -9,7 +9,7 @@ - content_for :breadcrumbs do - if @owner %li.breadcrumb-item= link_to 'Gardens', gardens_path - %li.breadcrumb-item.active= link_to "#{@owner}'s gardens", gardens_path(owner: @owner) + %li.breadcrumb-item.active= link_to "#{@owner}'s gardens", member_gardens_path(@owner) - else %li.breadcrumb-item.active= link_to 'Gardens', gardens_path From 2949abd6bf2096fcde8c0a1e008d12e39266f169 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 11:47:15 +1200 Subject: [PATCH 315/549] SEt subject of post in spec, so it matches the tests --- spec/models/post_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index b39d4aff0..340495efa 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -6,7 +6,7 @@ describe Post do it_behaves_like "it is likeable" it "has a slug" do - post = FactoryBot.create(:post, author: member) + post = FactoryBot.create(:post, author: member, subject: 'A Post') time = post.created_at datestr = time.strftime("%Y%m%d") # 2 digit day and month, full-length years From 7f7f2cae47f3956d797456b626418e6fff49da14 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 11:52:10 +1200 Subject: [PATCH 316/549] Revert "DRY the photos helper" This reverts commit 798fff43cf2c2606c5ed8987843a7fd151f6200d. --- app/helpers/photos_helper.rb | 71 ++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb index b61edcf84..e78bc12da 100644 --- a/app/helpers/photos_helper.rb +++ b/app/helpers/photos_helper.rb @@ -1,39 +1,56 @@ module PhotosHelper def crop_image_path(crop, full_size: false) - photo_or_placeholder(crop, full_size: full_size) - end - - def garden_image_path(garden, full_size: false) - photo_or_placeholder(garden, full_size: full_size) - end - - def planting_image_path(planting, full_size: false) - photo_or_placeholder(planting, full_size: full_size) - end - - def harvest_image_path(harvest, full_size: false) - photo_or_placeholder(harvest, full_size: full_size) - end - - def seed_image_path(seed, full_size: false) - photo_or_placeholder(seed, full_size: full_size) - end - - private - - def photo_or_placeholder(item, full_size: false) - if item.default_photo.present? - item_photo(item, full_size: full_size) + if crop.default_photo.present? + photo = crop.default_photo + full_size ? photo.fullsize_url : photo.thumbnail_url else placeholder_image end end - def item_photo(item, full_size:) - photo = item.default_photo - full_size ? photo.fullsize_url : photo.thumbnail_url + def garden_image_path(garden, full_size: false) + if garden.default_photo.present? + photo = garden.default_photo + full_size ? photo.fullsize_url : photo.thumbnail_url + else + placeholder_image + end end + def planting_image_path(planting, full_size: false) + if planting.photos.present? + photo = planting.photos.order(date_taken: :desc).first + full_size ? photo.fullsize_url : photo.thumbnail_url + else + placeholder_image + end + end + + def harvest_image_path(harvest, full_size: false) + if harvest.photos.present? + photo = harvest.photos.order(date_taken: :desc).first + full_size ? photo.fullsize_url : photo.thumbnail_url + elsif harvest.planting.present? + planting_image_path(harvest.planting, full_size: full_size) + else + placeholder_image + end + end + + def seed_image_path(seed, full_size: false) + if seed.default_photo.present? + photo = seed.default_photo + full_size ? photo.fullsize_url : photo.thumbnail_url + elsif seed.crop.default_photo.present? + photo = seed.crop.default_photo + full_size ? photo.fullsize_url : photo.thumbnail_url + else + placeholder_image + end + end + + private + def placeholder_image 'placeholder_150.png' end From 0af9fe0e4ccf636b35e8b25237c4c5fb02e026c4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 12:00:41 +1200 Subject: [PATCH 317/549] Updated a wierd spec on crop.photos.size that looked wrong --- spec/models/crop_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 5947e7912..fa642a540 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -184,10 +184,10 @@ describe Crop do expect(crop.default_photo).to eq nil end - it { expect(crop.photos.size).to eq 3 } - it { expect(crop.planting_photos.size).to eq 1 } - it { expect(crop.harvest_photos.size).to eq 1 } - it { expect(crop.seed_photos.size).to eq 1 } + it { expect(crop.photos.size).to eq 0 } + it { expect(crop.planting_photos.size).to eq 0 } + it { expect(crop.harvest_photos.size).to eq 0 } + it { expect(crop.seed_photos.size).to eq 0 } end describe 'finding all photos' do From bd6533ccc36597822ab376e354a6ebcc7f3d85fb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 12:01:33 +1200 Subject: [PATCH 318/549] Revert "Revert "DRY the photos helper"" This reverts commit 7f7f2cae47f3956d797456b626418e6fff49da14. --- app/helpers/photos_helper.rb | 49 ++++++++++++------------------------ 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb index e78bc12da..b61edcf84 100644 --- a/app/helpers/photos_helper.rb +++ b/app/helpers/photos_helper.rb @@ -1,55 +1,38 @@ module PhotosHelper def crop_image_path(crop, full_size: false) - if crop.default_photo.present? - photo = crop.default_photo - full_size ? photo.fullsize_url : photo.thumbnail_url - else - placeholder_image - end + photo_or_placeholder(crop, full_size: full_size) end def garden_image_path(garden, full_size: false) - if garden.default_photo.present? - photo = garden.default_photo - full_size ? photo.fullsize_url : photo.thumbnail_url - else - placeholder_image - end + photo_or_placeholder(garden, full_size: full_size) end def planting_image_path(planting, full_size: false) - if planting.photos.present? - photo = planting.photos.order(date_taken: :desc).first - full_size ? photo.fullsize_url : photo.thumbnail_url - else - placeholder_image - end + photo_or_placeholder(planting, full_size: full_size) end def harvest_image_path(harvest, full_size: false) - if harvest.photos.present? - photo = harvest.photos.order(date_taken: :desc).first - full_size ? photo.fullsize_url : photo.thumbnail_url - elsif harvest.planting.present? - planting_image_path(harvest.planting, full_size: full_size) - else - placeholder_image - end + photo_or_placeholder(harvest, full_size: full_size) end def seed_image_path(seed, full_size: false) - if seed.default_photo.present? - photo = seed.default_photo - full_size ? photo.fullsize_url : photo.thumbnail_url - elsif seed.crop.default_photo.present? - photo = seed.crop.default_photo - full_size ? photo.fullsize_url : photo.thumbnail_url + photo_or_placeholder(seed, full_size: full_size) + end + + private + + def photo_or_placeholder(item, full_size: false) + if item.default_photo.present? + item_photo(item, full_size: full_size) else placeholder_image end end - private + def item_photo(item, full_size:) + photo = item.default_photo + full_size ? photo.fullsize_url : photo.thumbnail_url + end def placeholder_image 'placeholder_150.png' From 35fa2122b8076a46efd401ded8fe8c837e91d7f5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 12:20:55 +1200 Subject: [PATCH 319/549] padding on thumbnail photos --- app/assets/stylesheets/overrides.scss | 30 ----------------------- app/assets/stylesheets/photos.scss | 34 +++++++++++++++++++++++++++ app/views/crops/_photos.html.haml | 8 +++---- 3 files changed, 37 insertions(+), 35 deletions(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index f586489c5..bb750cb24 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -204,36 +204,6 @@ p.stats { list-style-type: none; } -.photo-thumbnail { - padding: 0; - position: relative; - - img { - width: 100%; - } - - .text { - display: none; - color: #000; - position: absolute; - bottom: 0; - background: rgba(0, 0, 0, 0.8); - width: 100%; - margin: 0; - } - - p { - padding: 5px; - margin: 0; - color: #fff; - } - - &:hover { - .text { - display: block; - } - } -} li.crop-hierarchy { list-style-type: disc; diff --git a/app/assets/stylesheets/photos.scss b/app/assets/stylesheets/photos.scss index 4756f1656..074548cf5 100644 --- a/app/assets/stylesheets/photos.scss +++ b/app/assets/stylesheets/photos.scss @@ -33,4 +33,38 @@ .hero-photo { max-height: 500px; +} + +.photo-thumbnail { + margin-right: 1em; + margin-bottom: 1em; + max-width: 150px; + padding: 0; + position: relative; + + img { + width: 100%; + } + + .text { + display: none; + color: #000; + position: absolute; + bottom: 0; + background: rgba(0, 0, 0, 0.8); + width: 100%; + margin: 0; + } + + p { + padding: 5px; + margin: 0; + color: #fff; + } + + &:hover { + .text { + display: block; + } + } } \ No newline at end of file diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index 56073919d..ed164d82d 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -1,16 +1,14 @@ %section.photos - if @crop.photos.size.positive? - %h2 - = photo_icon - Photos + %h2 #{photo_icon} Photos - [Planting, Harvest, Seed].each do |model_name| - if photos.by_model(model_name).size.positive? .crop-photos %h3 #{@crop.name.capitalize} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} - .row + .index-cards - photos.by_model(model_name).limit(6).each do |photo| - .col-6.col-md-2= render 'photos/thumbnail', photo: photo + = render 'photos/thumbnail', photo: photo = link_to 'more photos »', crop_photos_path(@crop), class: 'btn' %hr/ From 3863c0e0e8f0e7c133bb276f8d1d8e3fbd6d48bf Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 15:06:39 +1200 Subject: [PATCH 320/549] These colours returned --- app/assets/stylesheets/application.scss | 7 ++- app/assets/stylesheets/overrides.scss | 4 -- app/assets/stylesheets/variables.scss | 80 ++++++++++++++++--------- 3 files changed, 58 insertions(+), 33 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 0753bfd64..d2c535be4 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -1,5 +1,10 @@ -@import "material"; +// Import original variables so they can be used in overrides + + + @import "variables"; +@import "material"; +@import "bootstrap/variables.scss"; @import "jquery-ui/autocomplete"; @import "bootstrap-datepicker"; diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index bb750cb24..5e6cae772 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -8,10 +8,6 @@ body { // padding-top: $navbar-height } -// Font Awesome -@import "font-awesome-sprockets"; -@import "font-awesome"; - section { padding-top: 1em; margin: 0; diff --git a/app/assets/stylesheets/variables.scss b/app/assets/stylesheets/variables.scss index 2994e991b..83a8ee9c6 100644 --- a/app/assets/stylesheets/variables.scss +++ b/app/assets/stylesheets/variables.scss @@ -1,8 +1,3 @@ -// Use this file to override Twitter Bootstrap variables or define own variables. - -// Import original variables so they can be used in overrides -@import "bootstrap/variables.scss"; - //$screen-md-min: 1028px // Base colours @@ -16,28 +11,57 @@ $orange: #ffa500; $yellow: #b2935c; $white: #ffffff; -$body-bg: $beige; -$text-color: $brown; -$link-color: $green; -$graph-hover: $orange; -$brand-primary: $green; +// $body-bg: $beige; +// $text-color: $brown; +// $link-color: $green; +// $graph-hover: $orange; -$font-family-sans-serif: "Helvetica Neue", Helvetica, Arial, sans-serif; -$font-family-serif: Georgia, "Times New Roman", Times, serif; -$font-family-mono: Monaco, Menlo, Consolas, "Courier New", monospace; +// $brand-primary: $green; -$font-size-base: 14px; -$font-family-base: $font-family-sans-serif; -$line-height-base: 1.5; -$alt-font-family: $font-family-serif; +$primary: ( + color: $green, + dark: darken($green, 10%), + light: lighten($green, 10%) +); -$headings-font-family: $font-family-sans-serif; -$headings-font-weight: bold; -$headings-color: inherit; +$secondary: ( + color: $blue, + dark: darken($blue, 10%), + light: lighten($blue, 10%) +); +$success: ( + color: $green, + dark: darken($green, 10%), + light: lighten($green, 10%) +); +$danger: ( + color: $red, + dark: darken($red, 10%), + light: lighten($red, 10%) +); +$dark: ( + color: $brown, + dark: darken($brown, 10%), + light: lighten($brown, 10%) +); -// Hero unit -$jumbotron-bg: darken($body-bg, 10%); + +// $font-family-sans-serif: "Helvetica Neue", Helvetica, Arial, sans-serif; +// $font-family-serif: Georgia, "Times New Roman", Times, serif; +// $font-family-mono: Monaco, Menlo, Consolas, "Courier New", monospace; + +// $font-size-base: 14px; +// $font-family-base: $font-family-sans-serif; +// $line-height-base: 1.5; +// $alt-font-family: $font-family-serif; + +// $headings-font-family: $font-family-sans-serif; +// $headings-font-weight: bold; +// $headings-color: inherit; + +// // Hero unit +// $jumbotron-bg: darken($body-bg, 10%); // Nav bar $navbar-default-bg: $brown; @@ -48,10 +72,10 @@ $navbar-default-link-hover-color: $beige; $navbar-default-link-active-color: darken($beige, 80%); $navbar-default-brand-color: lighten($green, 20%); -// Top nav collapse threshold -//$grid-float-breakpoint: $screen-md-min +// // Top nav collapse threshold +// //$grid-float-breakpoint: $screen-md-min -$dropdown-bg: lighten($beige, 10%); -$dropdown-link-color: $brown; -$dropdown-link-hover-color: $brown; -$dropdown-link-hover-bg: lighten($green, 50%); +// $dropdown-bg: lighten($beige, 10%); +// $dropdown-link-color: $brown; +// $dropdown-link-hover-color: $brown; +// $dropdown-link-hover-bg: lighten($green, 50%); From 62302b3fd7fa318ae066f16876465953a3aa3126 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 15:06:55 +1200 Subject: [PATCH 321/549] Fix round display of member avatars --- app/views/members/_avatar.html.haml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/views/members/_avatar.html.haml b/app/views/members/_avatar.html.haml index a576186d9..cc9a208c4 100644 --- a/app/views/members/_avatar.html.haml +++ b/app/views/members/_avatar.html.haml @@ -1,4 +1 @@ -= link_to image_tag(avatar_uri(member, 150), - alt: member, - class: 'img img-responsive avatar mr-3 shadow'), - member_path(member) += link_to image_tag(avatar_uri(member, 150), alt: member, class: 'avatar img img-fluid'), member_path(member) From ab3f65742f9889a6b0c4d24ceb662a6195098b9b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 15:07:44 +1200 Subject: [PATCH 322/549] better hover on members avatar --- app/views/members/_member.haml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/members/_member.haml b/app/views/members/_member.haml index ec043d7ef..25ee2e059 100644 --- a/app/views/members/_member.haml +++ b/app/views/members/_member.haml @@ -1,8 +1,7 @@ - cache member do .card.member-card.text-center - .avatar.mx-auto - = link_to member do - = image_tag(avatar_uri(member, 150), class: 'rounded-circle img-fluid shadow member-avatar', alt: member) + = link_to member do + = image_tag(avatar_uri(member, 150), class: 'img img-fluid avatar rounded', alt: member) .card-body %h4.card-title.login-name= link_to member, member %hr/ From 5ec29b40d0f86a65007b29368ae5328ac1c3d5df Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 15:08:01 +1200 Subject: [PATCH 323/549] tidy up sci name action menu --- app/views/crops/_scientific_names.html.haml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/crops/_scientific_names.html.haml b/app/views/crops/_scientific_names.html.haml index b5e97414a..66036e198 100644 --- a/app/views/crops/_scientific_names.html.haml +++ b/app/views/crops/_scientific_names.html.haml @@ -8,12 +8,13 @@ %li.list-group-item.d-flex.justify-content-between.align-items-center - if can? :edit, sn .dropdown.planting-actions - %a#planting-actions-scinames.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button", :href => '#'}= sn.name + %a#planting-actions-scinames.dropdown-toggle.card-link{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button", :href => '#'}= sn.name .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "planting-actions-button"} = link_to edit_scientific_name_path(sn), class: 'dropdown-item' do = edit_icon = t('.edit') - = link_to sn, method: :delete, data: { confirm: 'Are you sure?' }, class: 'dropdown-item' do + .dropdown-divider + = link_to sn, method: :delete, data: { confirm: 'Are you sure?' }, class: 'dropdown-item text-danger' do = delete_icon = t('.delete') - else From 533c9aefdb56bc84256a9342128eb14ba2b2cfc9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 15:14:22 +1200 Subject: [PATCH 324/549] push the link to bottom of member cards --- app/views/members/_member.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/members/_member.haml b/app/views/members/_member.haml index 25ee2e059..30bfd197e 100644 --- a/app/views/members/_member.haml +++ b/app/views/members/_member.haml @@ -4,7 +4,7 @@ = image_tag(avatar_uri(member, 150), class: 'img img-fluid avatar rounded', alt: member) .card-body %h4.card-title.login-name= link_to member, member - %hr/ + .card-footer %p %small Joined From c5988ded4e5374d53a585dea4902116ca5b38d0a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 15:21:06 +1200 Subject: [PATCH 325/549] tidy up badges and progress bar --- app/assets/stylesheets/plantings.scss | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/plantings.scss b/app/assets/stylesheets/plantings.scss index 46caa8569..38f8c1fb1 100755 --- a/app/assets/stylesheets/plantings.scss +++ b/app/assets/stylesheets/plantings.scss @@ -1,14 +1,12 @@ .planting { .planting-badges { - font-size: 1.5em; + font-size: 1em; position: absolute; - top: 3em; - + top: 1em; .badge-super-late { background-color: $red; } - .badge-harvest { background-color: $blue; } @@ -29,7 +27,12 @@ } } .progress { - min-height: 25px; + .progress-bar { + border-bottom-color: $green; + } + .progress-bar:after { + background-color: $beige; + } } .planting-name { From 6d18400a8bb240f5a5ae3ffd12ec14d40f88296c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 15:22:53 +1200 Subject: [PATCH 326/549] turn off all link hover underlines --- app/assets/stylesheets/overrides.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index 5e6cae772..f853e7f34 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -20,6 +20,7 @@ a { a:hover { color: $white; background-color: $green; + text-decoration: none; } span.badge { From f2e87c986327cae43de8cf742e839b065252c368 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 15:31:16 +1200 Subject: [PATCH 327/549] elipsis when photo title is too long --- app/assets/stylesheets/overrides.scss | 6 ++++++ app/views/photos/_thumbnail.html.haml | 2 +- app/views/photos/show.html.haml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index f853e7f34..3522f2071 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -13,6 +13,12 @@ section { margin: 0; } +.ellipsis { + overflow:hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + a { color: $green; } diff --git a/app/views/photos/_thumbnail.html.haml b/app/views/photos/_thumbnail.html.haml index 7ee9c2da8..dfc6483d3 100644 --- a/app/views/photos/_thumbnail.html.haml +++ b/app/views/photos/_thumbnail.html.haml @@ -1,7 +1,7 @@ .thumbnail .photo-thumbnail = link_to image_tag(photo.thumbnail_url, alt: photo.title, class: 'img img-responsive rounded'), photo - .text + .text.ellipsis %p = link_to photo.title, photo %br/ diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index dd4e752a2..bd8632f4d 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -13,7 +13,7 @@ .row .col-md-8 - %h1.text-center=@photo.title + %h1.text-center.ellipsis=@photo.title %p.text-center = image_tag(@photo.fullsize_url, alt: @photo.title, class: 'rounded img-fluid shadow-sm') .col-md-4 From feb11811a595d4b903bf733bd3e7c65a1b717bea Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 15:35:22 +1200 Subject: [PATCH 328/549] badges were overlapping the menu --- app/assets/stylesheets/plantings.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/plantings.scss b/app/assets/stylesheets/plantings.scss index 38f8c1fb1..6a776aef6 100755 --- a/app/assets/stylesheets/plantings.scss +++ b/app/assets/stylesheets/plantings.scss @@ -3,7 +3,7 @@ .planting-badges { font-size: 1em; position: absolute; - top: 1em; + top: 3em; .badge-super-late { background-color: $red; } From 6c233024355fbd3ede20b7014d3c039c78d8412a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 15:52:05 +1200 Subject: [PATCH 329/549] Fix duplicate labels on crop form --- app/views/crops/_form.html.haml | 43 +++++++++++---------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/app/views/crops/_form.html.haml b/app/views/crops/_form.html.haml index 43ddc23f8..72471b58c 100644 --- a/app/views/crops/_form.html.haml +++ b/app/views/crops/_form.html.haml @@ -1,5 +1,5 @@ -.card.col-12.col-md-8.mx-auto.float-none.white.z-depth-1.py-2.px-2 - = bootstrap_form_for(@crop) do |f| += bootstrap_form_for(@crop) do |f| + .card.col-12.col-md-8.mx-auto.float-none.white .card-header - if content_for? :title %h1.h2-responsive.text-center @@ -53,10 +53,9 @@ -# Everyone (wranglers and requesters) gets to add scientific names - %h2 - Scientific names - = button_tag "+", id: "add-sci_name-row", type: "button" - = button_tag "-", id: "remove-sci_name-row", type: "button" + %h2 Scientific names + = button_tag "+", id: "add-sci_name-row", type: "button" + = button_tag "-", id: "remove-sci_name-row", type: "button" .form-group#scientific_names - @crop.scientific_names.each.with_index do |sci, index| @@ -66,10 +65,9 @@ .col-8 = text_field_tag "sci_name[#{index + 1}]", sci.name, id: "sci_name[#{index + 1}]", class: 'form-control' %span.help-block Scientific name of crop. - %h2 - Alternate names - = button_tag "+", id: "add-alt_name-row", type: "button" - = button_tag "-", id: "remove-alt_name-row", type: "button" + %h2 Alternate names + = button_tag "+", id: "add-alt_name-row", type: "button" + = button_tag "-", id: "remove-alt_name-row", type: "button" .form-group#alternate_names - @crop.alternate_names.each.with_index do |alt, index| @@ -86,10 +84,7 @@ - if (can?(:wrangle, @crop) && @crop.requester) || (cannot?(:wrangle, @crop) && @crop.new_record?) %h2 Crop request notes - .form-group - = f.label :request_notes, 'Comments', class: 'control-label col-2' - .col-8 - = f.text_area :request_notes, rows: 3, id: 'request_notes' + = f.text_area :request_notes, rows: 3, id: 'request_notes', label: 'Comments' -# A final explanation of what's going to happen next, for crop requesters - unless can? :wrangle, @crop @@ -100,22 +95,12 @@ -# Now, for crop wranglers, let's have approval/rejection at the bottom of the page - if can?(:wrangle, @crop) && @crop.requester %h2 Approve or reject pending crops - .form-group - = f.label :approval_status, 'Approval status', class: 'control-label col-2' - .col-8 - = f.select(:approval_status, @crop.approval_statuses, {}) + = f.select(:approval_status, @crop.approval_statuses, {}) + = f.select(:reason_for_rejection, @crop.reasons_for_rejection, include_blank: true) - .form-group - = f.label :reason_for_rejection, 'Reason for rejection', class: 'control-label col-2' - .col-8 - = f.select(:reason_for_rejection, @crop.reasons_for_rejection, include_blank: true) - - .form-group - = f.label :rejection_notes, 'Rejection notes', class: 'control-label col-2' - .col-8 - = f.text_area :rejection_notes, rows: 3 - %span.help-block - Please provide additional notes why this crop request was rejected if the above reasons do not apply. + = f.text_area :rejection_notes, rows: 3 + %span.help-block + Please provide additional notes why this crop request was rejected if the above reasons do not apply. .card-footer .text-right= f.submit 'Save' From 465c7c7b6d73a626c5900cc4566e8e153c806d1c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 15:54:04 +1200 Subject: [PATCH 330/549] Move crop form error messages to alert --- app/views/crops/_form.html.haml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/crops/_form.html.haml b/app/views/crops/_form.html.haml index 72471b58c..53c329f7c 100644 --- a/app/views/crops/_form.html.haml +++ b/app/views/crops/_form.html.haml @@ -1,19 +1,19 @@ = bootstrap_form_for(@crop) do |f| + - if @crop.errors.any? + #error_explanation.alert.alert-warning{role: "alert"} + %h3 + = pluralize(@crop.errors.size, "error") + prohibited this crop from being saved: + %ul + - @crop.errors.full_messages.each do |msg| + %li= msg + .card.col-12.col-md-8.mx-auto.float-none.white .card-header - if content_for? :title %h1.h2-responsive.text-center %strong=yield :title .card-body - - if @crop.errors.any? - #error_explanation - %h3 - = pluralize(@crop.errors.size, "error") - prohibited this crop from being saved: - %ul - - @crop.errors.full_messages.each do |msg| - %li= msg - -# Handy link to crop wrangling policy/style guide, shown to wranglers only - if can? :wrangle, @crop %p From d7b973e684a9047bf31abf9523d6c08f793c7753 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 15:58:22 +1200 Subject: [PATCH 331/549] Add harvest predictions to homepage blurb --- app/views/home/_blurb.html.haml | 8 +++----- config/locales/en.yml | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/views/home/_blurb.html.haml b/app/views/home/_blurb.html.haml index ab1e27651..486aa854b 100644 --- a/app/views/home/_blurb.html.haml +++ b/app/views/home/_blurb.html.haml @@ -2,11 +2,9 @@ .col-md-8.info %h1= ENV['GROWSTUFF_SITE_NAME'] %p= t('.intro', site_name: ENV['GROWSTUFF_SITE_NAME']) - = render partial: 'stats' + = render 'stats' .col-md-4 .signup %p= t('.perks') - %p= link_to(t('.sign_up'), new_member_registration_path, class: 'btn btn-success btn-lg') - %p - %small - = t('.already_html', sign_in: link_to(t('.sign_in_linktext'), new_member_session_path)) + %p= link_to(t('.sign_up'), new_member_registration_path, class: 'btn btn-success btn-block') + %p= t('.already_html', sign_in: link_to(t('.sign_in_linktext'), new_member_session_path, class: 'btn')) \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 8ebecbd2a..49da3f7db 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -131,7 +131,7 @@ en: blurb: already_html: Or %{sign_in} if you already have an account intro: "%{site_name} is a community of food gardeners. We're building an open source platform to help you learn about growing food, track what you plant and harvest, and swap seeds and produce with other gardeners near you.\n" - perks: Join now for your free garden journal, seed sharing, forums, and more. + perks: Join now for your free garden journal, harvest predictions, forums, and more. sign_in_linktext: sign in sign_up: Sign up some_of_our_crops: Some of our crops From 28f68717f5dd7abad195d8482001086698c39f6d Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Fri, 14 Jun 2019 13:36:20 +0930 Subject: [PATCH 332/549] Address code climate concerns by extracting query methods --- app/controllers/members_controller.rb | 73 +++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 10 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index cb12f6221..06ef950a9 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -11,6 +11,62 @@ class MembersController < ApplicationController format.json { render json: @members.to_json(only: member_json_fields) } end end + + # Queries for the show view/action + def plantings_for_show + Planting.select( + :id, + "'planting' as event_type", + 'planted_at as event_at', + :owner_id, + :crop_id, + :slug + ) + end + + def harvests_for_show + Harvest.select( + :id, + "'harvest' as event_type", + 'harvested_at as event_at', + :owner_id, + :crop_id, + :slug + ) + end + + def posts_for_show + Post.select( + :id, + "'post' as event_type", + 'posts.created_at as event_at', + 'author_id as owner_id', + 'null as crop_id', + :slug + ) + end + + def comments_for_show + Comment.select( + :id, + "'comment' as event_type", + 'comments.created_at as event_at', + 'author_id as owner_id', + 'null as crop_id', + 'null as slug' + ) + end + + def photos_for_show + Photo.select( + :id, + "'photo' as event_type", + "photos.created_at as event_at", + 'photos.owner_id', + 'null as crop_id', + 'null as slug' + ) + end def show @member = Member.confirmed.find_by!(slug: params[:slug]) @@ -18,16 +74,13 @@ class MembersController < ApplicationController @flickr_auth = @member.auth('flickr') @facebook_auth = @member.auth('facebook') @posts = @member.posts - plantings = Planting.select(:id, "'planting' as event_type", 'planted_at as event_at', :owner_id, :crop_id, :slug) - harvests = Harvest.select(:id, "'harvest' as event_type", 'harvested_at as event_at', :owner_id, :crop_id, :slug) - posts = Post.select(:id, "'post' as event_type", 'posts.created_at as event_at', 'author_id as owner_id', 'null as crop_id', :slug) - comments = Comment.select(:id, "'comment' as event_type", 'comments.created_at as event_at', 'author_id as owner_id', 'null as crop_id', 'null as slug') - photos = Photo.select(:id, "'photo' as event_type", "photos.created_at as event_at", 'photos.owner_id', 'null as crop_id', 'null as slug') - @activity = plantings - .union_all(harvests) - .union_all(posts) - .union_all(comments) - .union_all(photos) + + # TODO: Consider shifting all of these onto a member activity model? + @activity = plantings_for_show + .union_all(harvests_for_show) + .union_all(posts_for_show) + .union_all(comments_for_show) + .union_all(photos_for_show) .where(owner_id: @member.id) .order(event_at: :desc) .limit(30) From 19eae7d2599bac129ea0872c3feed77260f242e1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:06:32 +1200 Subject: [PATCH 333/549] crop search form on white background for readability --- app/assets/stylesheets/crops.scss | 5 +++++ app/views/crops/search.html.haml | 23 ++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/assets/stylesheets/crops.scss b/app/assets/stylesheets/crops.scss index 646f1e4d7..8baec9274 100644 --- a/app/assets/stylesheets/crops.scss +++ b/app/assets/stylesheets/crops.scss @@ -14,3 +14,8 @@ .crop-photos { margin-left: 3em; } + +.crops-search-form { + background-color: $white; + padding: 1em; +} \ No newline at end of file diff --git a/app/views/crops/search.html.haml b/app/views/crops/search.html.haml index 4891dadb4..2fc65a06e 100644 --- a/app/views/crops/search.html.haml +++ b/app/views/crops/search.html.haml @@ -1,18 +1,19 @@ -- if @term - - content_for :title, "Crops matching \"#{@term}\"" - %h1 Crops matching "#{@term}" - - if @crops - %h2.text-muted Found #{@crops.size} total - -- else - - content_for :title, "Crop search" - %h1 Crop search - - content_for :breadcrumbs do %li.breadcrumb-item= link_to 'Crops', crops_path %li.breadcrumb-item.active= link_to 'Search', search_crops_path(term: @term) -.search-form +%section.crops-search-form + + - if @term + - content_for :title, "Crops matching \"#{@term}\"" + %h1 Crops matching "#{@term}" + - if @crops + %h2.text-muted Found #{@crops.size} total + - else + - content_for :title, "Crop search" + %h1 Crop search + + = bootstrap_form_tag(url: search_crops_path, method: :get, id: 'crop-search', layout: :inline) do |f| = f.label :term, "Search crops:", class: 'sr-only' = f.text_field 'term', class: 'search-query input-medium', From d98e94bd21ba16374846796804023998efb1623e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:13:53 +1200 Subject: [PATCH 334/549] Switch from poltergeist to selenium chrome headless --- Gemfile | 5 +++-- Gemfile.lock | 11 +++++------ spec/rails_helper.rb | 14 +++++--------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Gemfile b/Gemfile index 6ab49ce81..43b053fb5 100644 --- a/Gemfile +++ b/Gemfile @@ -141,12 +141,11 @@ group :development, :test do gem 'haml-rails' # HTML templating language gem 'haml_lint', '>= 0.25.1' # Checks haml files for goodness gem 'i18n-tasks' # adds tests for finding missing and unused translations - gem 'poltergeist' # for headless JS testing + # gem 'poltergeist' # for headless JS testing gem 'rspec-activemodel-mocks' gem 'rspec-rails' # unit testing framework gem 'rubocop', '~> 0.70' gem 'rubocop-rspec' - gem 'selenium-webdriver' gem 'webrat' # provides HTML matchers for view tests end @@ -155,6 +154,8 @@ group :test do gem 'percy-capybara', '~> 4.0.0' gem 'rails-controller-testing' gem 'timecop' + gem 'selenium-webdriver' + gem 'webdrivers' end group :travis do diff --git a/Gemfile.lock b/Gemfile.lock index 9379f76e4..844c3b7b0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -103,7 +103,6 @@ GEM chartkick (3.2.0) childprocess (1.0.1) rake (< 13.0) - cliver (0.3.2) codeclimate-test-reporter (1.0.9) simplecov (<= 0.13) coderay (1.1.2) @@ -345,10 +344,6 @@ GEM platform-api (2.2.0) heroics (~> 0.0.25) moneta (~> 1.0.0) - poltergeist (1.18.1) - capybara (>= 2.1, < 4) - cliver (~> 0.3.1) - websocket-driver (>= 0.2.0) popper_js (1.14.5) public_suffix (3.0.3) puma (3.12.1) @@ -512,6 +507,10 @@ GEM uniform_notifier (1.12.1) warden (1.2.8) rack (>= 2.0.6) + webdrivers (4.0.1) + nokogiri (~> 1.6) + rubyzip (~> 1.0) + selenium-webdriver (>= 3.0, < 4.0) webrat (0.7.3) nokogiri (>= 1.2.0) rack (>= 1.0) @@ -593,7 +592,6 @@ DEPENDENCIES percy-capybara (~> 4.0.0) pg (< 1.0.0) platform-api - poltergeist puma rack-protection (>= 2.0.1) rails (= 5.2.2.1) @@ -615,6 +613,7 @@ DEPENDENCIES timecop uglifier unicorn + webdrivers webrat will_paginate will_paginate-bootstrap4 diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 5b89cd26d..7c7d7148e 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -23,18 +23,14 @@ require 'rspec/rails' Rails.application.eager_load! require 'capybara' -require 'capybara/poltergeist' require 'capybara/rspec' +require 'selenium/webdriver' require 'capybara-screenshot/rspec' -Capybara.javascript_driver = :poltergeist -if ENV['GROWSTUFF_CAPYBARA_DRIVER'].present? - case ENV['GROWSTUFF_CAPYBARA_DRIVER'] - when 'selenium' - require 'selenium-webdriver' - end - Capybara.javascript_driver = ENV['GROWSTUFF_CAPYBARA_DRIVER'].to_sym -end +require 'webdrivers' + +Capybara.default_driver = :selenium_chrome_headless +Capybara.javascript_driver = :selenium_chrome_headless Capybara::Screenshot.register_filename_prefix_formatter(:rspec) do |example| "screenshot_#{example.description.tr(' ', '-').gsub(%r{^.*/spec/}, '')}" From 0d252bf3d301173db3db01393557a6aa2e97e8c4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:14:59 +1200 Subject: [PATCH 335/549] Add chrome, from apt, on travis-ci --- .travis.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3c51f41bf..a7a685bda 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,14 @@ cache: directories: - travis_phantomjs - tmp/cache/assets/test/sprockets +addons: + apt: + packages: + - chromium-chromedriver + - google-chrome-stable + code_climate: + repo_token: + secure: "PfhLGBKRgNqhKuYCJsK+VPhdAzcgWFGeeOyxC/eS8gtlvIISVdgyZE+r30uIei0DFI6zEiN62eW4d+xtT4j7/e2ZcAcx7U52mza/SnQNuu3nCGQDJB8VOvV5NbnwXfi8vfr4e889Mt7k3ocd2c4gqB4UtRqrzhygj7HN+B/GfEk=" env: matrix: - GROWSTUFF_ELASTICSEARCH=true RSPEC_TAG=elasticsearch COVERAGE=true PERCY_CHECKS=true @@ -67,7 +75,3 @@ deploy: - restart after_deploy: - bundle exec script/heroku_maintenance.rb off -addons: - code_climate: - repo_token: - secure: "PfhLGBKRgNqhKuYCJsK+VPhdAzcgWFGeeOyxC/eS8gtlvIISVdgyZE+r30uIei0DFI6zEiN62eW4d+xtT4j7/e2ZcAcx7U52mza/SnQNuu3nCGQDJB8VOvV5NbnwXfi8vfr4e889Mt7k3ocd2c4gqB4UtRqrzhygj7HN+B/GfEk=" From 19350e7aa0850dfa23374b12a9f61d15f59c73fe Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:15:49 +1200 Subject: [PATCH 336/549] Removing phantom --- .travis.yml | 2 -- config/application.yml.example | 1 - 2 files changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index a7a685bda..3001ab197 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,8 +24,6 @@ env: - GROWSTUFF_SITE_NAME="Growstuff (travis)" - RAILS_SECRET_TOKEN='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' before_install: - - ./script/install_phantomjs.sh - - export PATH=$PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH - ./script/install_codeclimate.sh - ./script/install_linters.sh - VERSION="6.2.3" ./script/install_elasticsearch.sh diff --git a/config/application.yml.example b/config/application.yml.example index c4c3a1f6c..2a38dad4f 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -76,7 +76,6 @@ GROWSTUFF_EMAIL: 'noreply@dev.growstuff.org' test: GROWSTUFF_SITE_NAME: Growstuff (test) - GROWSTUFF_CAPYBARA_DRIVER: poltergeist # Note: there is no good way to deploy settings from Figaro to # Travis-CI. If you need env vars set there in order for tests to pass, From 5cedea9da8ebc6bf86ffea52382ba184fbcd21ea Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:23:31 +1200 Subject: [PATCH 337/549] removing trailing whitespace --- app/assets/stylesheets/overrides.scss | 2 +- app/controllers/members_controller.rb | 10 +++++----- app/views/devise/unlocks/new.html.haml | 3 --- app/views/gardens/_form.html.haml | 2 +- app/views/members/_thumbnail.html.haml | 17 +---------------- app/views/photos/new.html.haml | 2 +- app/views/shared/buttons/_edit.haml | 2 +- 7 files changed, 10 insertions(+), 28 deletions(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index 3522f2071..7adbb7362 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -14,7 +14,7 @@ section { } .ellipsis { - overflow:hidden; + overflow:hidden; white-space: nowrap; text-overflow: ellipsis; } diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 06ef950a9..ab00ac45d 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -11,7 +11,7 @@ class MembersController < ApplicationController format.json { render json: @members.to_json(only: member_json_fields) } end end - + # Queries for the show view/action def plantings_for_show Planting.select( @@ -23,8 +23,8 @@ class MembersController < ApplicationController :slug ) end - - def harvests_for_show + + def harvests_for_show Harvest.select( :id, "'harvest' as event_type", @@ -45,7 +45,7 @@ class MembersController < ApplicationController :slug ) end - + def comments_for_show Comment.select( :id, @@ -56,7 +56,7 @@ class MembersController < ApplicationController 'null as slug' ) end - + def photos_for_show Photo.select( :id, diff --git a/app/views/devise/unlocks/new.html.haml b/app/views/devise/unlocks/new.html.haml index 3160bcfac..b8efdf0ac 100644 --- a/app/views/devise/unlocks/new.html.haml +++ b/app/views/devise/unlocks/new.html.haml @@ -9,10 +9,7 @@ %h2 Resend unlock instructions = devise_error_messages! - = f.email_field :email, class: 'form-control', placeholder: 'email' - = f.submit "Resend unlock instructions", class: 'btn btn-block my-4 btn-primary' - = render "devise/shared/links" diff --git a/app/views/gardens/_form.html.haml b/app/views/gardens/_form.html.haml index 9a7a29564..8d61ee8c1 100644 --- a/app/views/gardens/_form.html.haml +++ b/app/views/gardens/_form.html.haml @@ -34,7 +34,7 @@ .col-12 = f.check_box :active, label: 'Active?' %p - You can mark a garden as inactive if you no longer use it. + You can mark a garden as inactive if you no longer use it. Note: this will mark all plantings in the garden as "finished". .card-footer .text-right= f.submit 'Save Garden' diff --git a/app/views/members/_thumbnail.html.haml b/app/views/members/_thumbnail.html.haml index c64f36843..dc9d7b9ca 100644 --- a/app/views/members/_thumbnail.html.haml +++ b/app/views/members/_thumbnail.html.haml @@ -1,18 +1,3 @@ --# .member-thumbnail.well --# %div --# = render "members/avatar", member: member --# %div --# %p.login-name --# = link_to member.login_name, member --# - unless member.location.blank? --# %small --# %br/ --# %i= member.location --# - unless member.plantings.empty? --# %small --# %br/ --# Recently planted: --# != member.plantings.order(created_at: :desc).first(3).map { |p| link_to p.crop_name, p }.join(", ") - cache member do .card.text-center / Background color @@ -20,7 +5,7 @@ / Avatar .avatar.mx-auto.white = link_to member do - = image_tag(avatar_uri(member, 150), class: 'rounded-circle img-fluid', alt: member) + = image_tag(avatar_uri(member, 150), class: 'rounded-circle img-fluid', alt: member) .card-body / Name %h4.card-title diff --git a/app/views/photos/new.html.haml b/app/views/photos/new.html.haml index 546eb43af..ea35ecddd 100644 --- a/app/views/photos/new.html.haml +++ b/app/views/photos/new.html.haml @@ -21,7 +21,7 @@ - if @sets && @current_set %h2= @sets.key(@current_set) - + .row.pagination .col-md-12= page_entries_info @photos .col-md-12= will_paginate @photos diff --git a/app/views/shared/buttons/_edit.haml b/app/views/shared/buttons/_edit.haml index f80cdf917..a546b82d0 100644 --- a/app/views/shared/buttons/_edit.haml +++ b/app/views/shared/buttons/_edit.haml @@ -1,3 +1,3 @@ = link_to path, class: 'btn btn-default' do - = render 'shared/glyphicon', icon: 'pencil', title: 'buttons.edit' + = render 'shared/glyphicon', icon: 'pencil', title: 'buttons.edit' =t('buttons.edit') From 6143d88576f24fa5a77a3cc45e5c37de67d795f2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:24:51 +1200 Subject: [PATCH 338/549] Remove trailing whitespace --- app/views/members/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index bb33f9cab..2a0574998 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -72,7 +72,7 @@ - comment = Comment.find(event.id) = comment_icon = link_to 'commented', comment - on + on = link_to comment.post, comment.post - elsif event.event_type == 'post' - post = Post.find(event.id) From dea14ff0ff843755e32f42ced457d8ddc3e868b6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:26:06 +1200 Subject: [PATCH 339/549] Add new line at end of file --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index f9346eced..b0d40f04f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -75,4 +75,4 @@ Metrics/PerceivedComplexity: Rails/SkipsModelValidations: Exclude: - 'db/migrate/20190317023129_finished_boolean.rb' - - 'db/seeds.rb' \ No newline at end of file + - 'db/seeds.rb' From 43d300820cd301e87387d5ffb27646227c5564c3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:26:31 +1200 Subject: [PATCH 340/549] indentation fix --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3001ab197..5918161a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,8 @@ cache: addons: apt: packages: - - chromium-chromedriver - - google-chrome-stable + - chromium-chromedriver + - google-chrome-stable code_climate: repo_token: secure: "PfhLGBKRgNqhKuYCJsK+VPhdAzcgWFGeeOyxC/eS8gtlvIISVdgyZE+r30uIei0DFI6zEiN62eW4d+xtT4j7/e2ZcAcx7U52mza/SnQNuu3nCGQDJB8VOvV5NbnwXfi8vfr4e889Mt7k3ocd2c4gqB4UtRqrzhygj7HN+B/GfEk=" From d98cb87d955cd9296bcbdaca6568058d48cc4485 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:27:28 +1200 Subject: [PATCH 341/549] Wrapped long line --- config/locales/en.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 49da3f7db..4baf2e74f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -130,7 +130,9 @@ en: home: blurb: already_html: Or %{sign_in} if you already have an account - intro: "%{site_name} is a community of food gardeners. We're building an open source platform to help you learn about growing food, track what you plant and harvest, and swap seeds and produce with other gardeners near you.\n" + intro: > + %{site_name} is a community of food gardeners. We're building an open source platform to help you learn about growing food, + track what you plant and harvest, and swap seeds and produce with other gardeners near you.\n" perks: Join now for your free garden journal, harvest predictions, forums, and more. sign_in_linktext: sign in sign_up: Sign up From dc0607c42af6eee8b0b686eb0adf18176bfc735e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:28:13 +1200 Subject: [PATCH 342/549] Remove duplicated translations --- config/locales/en.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 4baf2e74f..80dfbee70 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -291,12 +291,6 @@ en: view_owners_profile: View %{owner}'s profile >> the_data_on_this_page_is_available_in_the_following_formats: 'The data on this page is available in the following formats:' string: "%{crop} planting in %{garden} by %{owner}" - badges: - late_finishing: late finishing - super_late: super late - days_until_finished: days until finished - harvesting_now: harvesting now - days_until_harvest: days until harvest progress: progress_0_not_planted_yet: 'Progress: 0% - not planted yet' posts: From 27b1b5e8db80d9dd9d29ab775d3ecbdb2de95cb9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:30:26 +1200 Subject: [PATCH 343/549] prefer single quotes --- app/assets/stylesheets/application.scss | 40 ++++++++++++------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index d2c535be4..6ed435d3c 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -1,30 +1,28 @@ // Import original variables so they can be used in overrides +@import 'variables'; +@import 'material'; +@import 'bootstrap/variables.scss'; +@import 'jquery-ui/autocomplete'; +@import 'bootstrap-datepicker'; +@import 'leaflet'; +@import 'leaflet.markercluster'; -@import "variables"; -@import "material"; -@import "bootstrap/variables.scss"; +@import 'predictions'; +@import 'plantings'; +@import 'members'; +@import 'harvests'; +@import 'seeds'; +@import 'crops'; -@import "jquery-ui/autocomplete"; -@import "bootstrap-datepicker"; -@import "leaflet"; -@import "leaflet.markercluster"; - -@import "predictions"; -@import "plantings"; -@import "members"; -@import "harvests"; -@import "seeds"; -@import "crops"; - -@import "homepage"; -@import "photos"; +@import 'homepage'; +@import 'photos'; // Font Awesome -@import "font-awesome-sprockets"; -@import "font-awesome"; -@import "material_icons"; +@import 'font-awesome-sprockets'; +@import 'font-awesome'; +@import 'material_icons'; @import 'rails_bootstrap_forms'; -@import "overrides"; \ No newline at end of file +@import 'overrides'; \ No newline at end of file From 3ae8900b05f5be116f724f25b2c09dd89c6ee111 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:31:01 +1200 Subject: [PATCH 344/549] Sorting css --- app/assets/stylesheets/crops.scss | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/crops.scss b/app/assets/stylesheets/crops.scss index 8baec9274..220973fb6 100644 --- a/app/assets/stylesheets/crops.scss +++ b/app/assets/stylesheets/crops.scss @@ -1,9 +1,9 @@ .planting { .crop-card { - width: 100px; - min-height: 300px; - margin: 0.1em; height: 100%; + margin: 0.1em; + min-height: 300px; + width: 100px; } .img-thumbnail { From b259ac5b43d316447ace674d69b28e7d02d482e2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:31:20 +1200 Subject: [PATCH 345/549] New line at end of file --- app/assets/stylesheets/crops.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/crops.scss b/app/assets/stylesheets/crops.scss index 220973fb6..73ce0f1de 100644 --- a/app/assets/stylesheets/crops.scss +++ b/app/assets/stylesheets/crops.scss @@ -18,4 +18,4 @@ .crops-search-form { background-color: $white; padding: 1em; -} \ No newline at end of file +} From cfb1cd798fc4a1fef3c4a606832b51775650a4af Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:31:43 +1200 Subject: [PATCH 346/549] Removing un-used css --- app/assets/stylesheets/homepage.scss | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/app/assets/stylesheets/homepage.scss b/app/assets/stylesheets/homepage.scss index 1c2af5b5a..e0569d2b9 100644 --- a/app/assets/stylesheets/homepage.scss +++ b/app/assets/stylesheets/homepage.scss @@ -1,14 +1,3 @@ -// let's condense the hero unit a little -.jumbotron { - //padding-top: 30px - //padding-bottom: 30px -} - -// info under the main heading on homepage -.jumbotron .info { - // padding-top: 15px -} - // signup widget on homepage .jumbotron .signup { background-color: lighten($green, 40%); From 115b0925cd55cf9f5fd0d37c6ef0e7c8a150768c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:32:16 +1200 Subject: [PATCH 347/549] Sorting css --- app/assets/stylesheets/homepage.scss | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/homepage.scss b/app/assets/stylesheets/homepage.scss index e0569d2b9..d8e8c8fdb 100644 --- a/app/assets/stylesheets/homepage.scss +++ b/app/assets/stylesheets/homepage.scss @@ -16,10 +16,10 @@ // left: -0.5em; .card { - min-height: 100px; - margin: 0.5em; - padding: 0; left: -0.5em; + margin: 0.5em; + min-height: 100px; + padding: 0; %h3.crop-name { font-size: 2em; @@ -54,14 +54,14 @@ @include media-breakpoint-down(sm) { .homepage-cards { .seed-card { - width: 100%; - min-height: 80px; align: center; + min-height: 80px; + width: 100%; } .member-card { - width: 150px; - min-height: 80px; align: center; + min-height: 80px; + width: 150px; } } } From 8eb299c1469e08adb77f47394df85a8caf82caa1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:36:04 +1200 Subject: [PATCH 348/549] only show actions menu if you can do the actions --- app/views/posts/_actions.html.haml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/views/posts/_actions.html.haml b/app/views/posts/_actions.html.haml index 64cbf0748..393a3d58a 100644 --- a/app/views/posts/_actions.html.haml +++ b/app/views/posts/_actions.html.haml @@ -1,11 +1,12 @@ -.dropdown.float-right - %button#post-edit-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions - .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "post-edit-button"} - - if can? :edit, post - = link_to edit_post_path(post), class: 'dropdown-item' do - = edit_icon - Edit - - if can? :delete, post - = link_to post_path(post), class: 'dropdown-item text-danger', data: { confirm: 'Are you sure?' } do - = delete_icon - Delete \ No newline at end of file +- if can? :edit, post + .dropdown.float-right + %button#post-edit-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions + .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "post-edit-button"} + - if can? :edit, post + = link_to edit_post_path(post), class: 'dropdown-item' do + = edit_icon + Edit + - if can? :delete, post + = link_to post_path(post), class: 'dropdown-item text-danger', data: { confirm: 'Are you sure?' } do + = delete_icon + Delete \ No newline at end of file From f98c33e68880a31c7e92e0bf8950782d94743973 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:38:20 +1200 Subject: [PATCH 349/549] wrap long line --- app/helpers/posts_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index 62ef5d9e0..b4d9161f4 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -1,7 +1,8 @@ module PostsHelper def display_post_truncated(post) length = 300 - truncate(strip_tags(post.body), length: length, separator: ' ', omission: '... ') { link_to "Read more", post_path(post) } + truncate(strip_tags(post.body), length: length, + separator: ' ', omission: '... ') { link_to "Read more", post_path(post) } end def post_byline(post) From 2fc3c33520ed01aee124db733d3904b120ab96d9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:38:49 +1200 Subject: [PATCH 350/549] rubocop lint --- app/controllers/members_controller.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index ab00ac45d..ae13c3bd9 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -21,7 +21,7 @@ class MembersController < ApplicationController :owner_id, :crop_id, :slug - ) + ) end def harvests_for_show @@ -47,14 +47,14 @@ class MembersController < ApplicationController end def comments_for_show - Comment.select( - :id, - "'comment' as event_type", - 'comments.created_at as event_at', - 'author_id as owner_id', - 'null as crop_id', - 'null as slug' - ) + Comment.select( + :id, + "'comment' as event_type", + 'comments.created_at as event_at', + 'author_id as owner_id', + 'null as crop_id', + 'null as slug' + ) end def photos_for_show From b9e2154edbf4961c450901d6c3c6e5258025d021 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:39:25 +1200 Subject: [PATCH 351/549] rubocop lint --- app/controllers/plantings_controller.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 3ba06367b..a5570062f 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -49,10 +49,12 @@ class PlantingsController < ApplicationController @seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id] @crop = Crop.approved.find_by(id: params[:crop_id]) || Crop.new - @planting.garden = Garden.find_by( - owner: current_member, - id: params[:garden_id] - ) if params[:garden_id] + if params[:garden_id] + @planting.garden = Garden.find_by( + owner: current_member, + id: params[:garden_id] + ) + end respond_with @planting end From ad6ec0473c0b6d5417f3ffa39ccab7d4b95b992d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:39:59 +1200 Subject: [PATCH 352/549] Sort gems --- Gemfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 43b053fb5..090a6e92f 100644 --- a/Gemfile +++ b/Gemfile @@ -111,6 +111,9 @@ gem 'xmlrpc' # fixes rake error - can be removed if not needed later gem 'puma' +gem 'loofah', '>= 2.2.1' +gem 'rack-protection', '>= 2.0.1' + group :production do gem 'bonsai-elasticsearch-rails' # Integration with Bonsa-Elasticsearch on heroku gem 'dalli' @@ -153,13 +156,11 @@ group :test do gem 'codeclimate-test-reporter', require: false gem 'percy-capybara', '~> 4.0.0' gem 'rails-controller-testing' - gem 'timecop' gem 'selenium-webdriver' + gem 'timecop' gem 'webdrivers' end group :travis do gem 'platform-api' end -gem 'loofah', '>= 2.2.1' -gem 'rack-protection', '>= 2.0.1' From 7564a87232c80b97a61398cce441474ae5d50563 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:42:09 +1200 Subject: [PATCH 353/549] Bring back rails rubocops --- .codeclimate.yml | 2 +- .rubocop.yml | 1 + Gemfile | 1 + Gemfile.lock | 4 ++++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.codeclimate.yml b/.codeclimate.yml index 85d0a48d1..60b03e58c 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -1,7 +1,7 @@ engines: rubocop: enabled: true - channel: "rubocop-0-70" + channel: "rubocop-0-71" scss-lint: enabled: true shellcheck: diff --git a/.rubocop.yml b/.rubocop.yml index b0d40f04f..7bd29c37c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,5 @@ inherit_from: .rubocop_todo.yml +require: rubocop-rails AllCops: Exclude: - 'db/schema.rb' diff --git a/Gemfile b/Gemfile index 090a6e92f..b30f06225 100644 --- a/Gemfile +++ b/Gemfile @@ -148,6 +148,7 @@ group :development, :test do gem 'rspec-activemodel-mocks' gem 'rspec-rails' # unit testing framework gem 'rubocop', '~> 0.70' + gem 'rubocop-rails' gem 'rubocop-rspec' gem 'webrat' # provides HTML matchers for view tests end diff --git a/Gemfile.lock b/Gemfile.lock index 844c3b7b0..1ed9c99fb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -430,6 +430,9 @@ GEM rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 1.7) + rubocop-rails (2.0.1) + rack (>= 1.1) + rubocop (>= 0.70.0) rubocop-rspec (1.33.0) rubocop (>= 0.60.0) ruby-progressbar (1.10.1) @@ -603,6 +606,7 @@ DEPENDENCIES rspec-activemodel-mocks rspec-rails rubocop (~> 0.70) + rubocop-rails rubocop-rspec ruby-units sass-rails From 551d6f9aa3849a5bd264b57cb5f30468b40d1380 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 16:43:25 +1200 Subject: [PATCH 354/549] Bump up line length --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 7bd29c37c..7d564984d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -57,7 +57,7 @@ Metrics/BlockLength: - 'config/**/*.rb' Metrics/LineLength: - Max: 120 + Max: 140 # Remove the following once the code style matches Metrics/MethodLength: From 5816b6c64cd13109bc6ab7072b7f156c4d4229b0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 17:10:03 +1200 Subject: [PATCH 355/549] Removed comment show spec. Page doesn't exist now --- spec/requests/comments_spec.rb | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 spec/requests/comments_spec.rb diff --git a/spec/requests/comments_spec.rb b/spec/requests/comments_spec.rb deleted file mode 100644 index c9b2ba9dc..000000000 --- a/spec/requests/comments_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'rails_helper' - -describe "Comments" do - describe "GET /comments" do - it "works! (now write some real specs)" do - # Run the generator again with the --webrat flag if you want to use webrat methods/matchers - get comments_path - response.status.should be(200) - end - end -end From f73b260212ed4ae3c90a25f4b5920f600411dcc5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 18:06:41 +1200 Subject: [PATCH 356/549] replace existing database cleaner the old one doesn't play nice with capybara --- spec/support/database_cleaner.rb | 43 ++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb index 720a47032..dad9c5faf 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/support/database_cleaner.rb @@ -1,21 +1,42 @@ RSpec.configure do |config| + + # database cleaner warning if you turn this off config.before(:suite) do + if config.use_transactional_fixtures? + raise(<<-MSG) + Delete line `config.use_transactional_fixtures = true` from rails_helper.rb + (or set it to false) to prevent uncommitted transactions being used in + JavaScript-dependent specs. + + During testing, the app-under-test that the browser driver connects to + uses a different database connection to the database connection used by + the spec. The app's database connection would not be able to access + uncommitted transaction data setup over the spec's database connection. + MSG + end + DatabaseCleaner.clean_with(:truncation) end - - config.before do + config.before(:each) do DatabaseCleaner.strategy = :transaction end + # config.before(:suite) do + # DatabaseCleaner.clean_with(:truncation) + # end - config.before(:each, js: true) do - DatabaseCleaner.strategy = :truncation - end + # config.before do + # DatabaseCleaner.strategy = :transaction + # end - config.before do - DatabaseCleaner.start - end + # config.before(:each, js: true) do + # DatabaseCleaner.strategy = :truncation + # end - config.after do - DatabaseCleaner.clean - end + # config.before do + # DatabaseCleaner.start + # end + + # config.after do + # DatabaseCleaner.clean + # end end From 40c75e01098833bada575bc4848746ba695fca3e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 18:12:33 +1200 Subject: [PATCH 357/549] Delete needs confirmations in the specs --- spec/features/crops/alternate_name_spec.rb | 3 ++- spec/features/crops/delete_crop_spec.rb | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb index e6cc3057a..2656517eb 100644 --- a/spec/features/crops/alternate_name_spec.rb +++ b/spec/features/crops/alternate_name_spec.rb @@ -46,7 +46,8 @@ describe "Alternate names", js: true do expect(page).to have_link "Delete", href: alternate_name_path(alternate_eggplant) within('.alternate_names') { click_on "Delete" } - expect(page.status_code).to equal 200 + dismiss_confirm {click_link 'OK'} + expect(pending_alt_name.status_code).to equal 200 expect(page).not_to have_content alternate_eggplant.name expect(page).to have_content 'Alternate name was successfully deleted' end diff --git a/spec/features/crops/delete_crop_spec.rb b/spec/features/crops/delete_crop_spec.rb index 8a25b629a..1bdab7272 100644 --- a/spec/features/crops/delete_crop_spec.rb +++ b/spec/features/crops/delete_crop_spec.rb @@ -10,13 +10,17 @@ describe "Delete crop spec" do it "Delete approved crop" do visit crop_path(approved_crop) + click_link 'Actions' click_link 'Delete' + dismiss_confirm {click_link 'OK'} expect(page).to have_content "crop was successfully destroyed" end it "Delete pending crop" do visit crop_path(pending_crop) + click_link 'Actions' click_link 'Delete' + dismiss_confirm {click_link 'OK'} expect(page).to have_content "crop was successfully destroyed" end end From e46becac10953e155d44dac733bead1187e3b4b2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 20:22:35 +1200 Subject: [PATCH 358/549] give link a href so capybara can find it --- app/views/crops/_wrangle.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/crops/_wrangle.html.haml b/app/views/crops/_wrangle.html.haml index c56a7b8c8..f274ed430 100644 --- a/app/views/crops/_wrangle.html.haml +++ b/app/views/crops/_wrangle.html.haml @@ -6,7 +6,7 @@ = succeed "." do %strong CROP WRANGLER .dropdown.crop-actions - %button#crop-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions + %button#crop-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button", href: '#'} Actions .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "crop-actions-button"} = link_to edit_crop_path(crop), class: 'dropdown-item' do = edit_icon From 4fa4286670187213975f0977602f17d64a2e372b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 20:32:12 +1200 Subject: [PATCH 359/549] dismiss the alert when deleting crops --- spec/features/crops/delete_crop_spec.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spec/features/crops/delete_crop_spec.rb b/spec/features/crops/delete_crop_spec.rb index 1bdab7272..b3c108ef9 100644 --- a/spec/features/crops/delete_crop_spec.rb +++ b/spec/features/crops/delete_crop_spec.rb @@ -11,16 +11,18 @@ describe "Delete crop spec" do it "Delete approved crop" do visit crop_path(approved_crop) click_link 'Actions' - click_link 'Delete' - dismiss_confirm {click_link 'OK'} + accept_confirm do + click_link 'Delete' + end expect(page).to have_content "crop was successfully destroyed" end it "Delete pending crop" do visit crop_path(pending_crop) click_link 'Actions' - click_link 'Delete' - dismiss_confirm {click_link 'OK'} + accept_confirm do + click_link 'Delete' + end expect(page).to have_content "crop was successfully destroyed" end end From 6259d72ce09fba35b422341858d5063cfe9040ae Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 20:32:38 +1200 Subject: [PATCH 360/549] delete link on drops needs href --- app/views/crops/_wrangle.html.haml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/views/crops/_wrangle.html.haml b/app/views/crops/_wrangle.html.haml index f274ed430..3207d34b5 100644 --- a/app/views/crops/_wrangle.html.haml +++ b/app/views/crops/_wrangle.html.haml @@ -6,7 +6,7 @@ = succeed "." do %strong CROP WRANGLER .dropdown.crop-actions - %button#crop-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button", href: '#'} Actions + %a#crop-actions-button.btn.btn-info.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button", href: '#'} Actions .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "crop-actions-button"} = link_to edit_crop_path(crop), class: 'dropdown-item' do = edit_icon @@ -14,6 +14,5 @@ - if can? :destroy, crop .dropdown-divider - = link_to crop, method: :delete, class: 'dropdown-item text-danger' do - = delete_icon - Delete + = delete_button(crop, classes: 'dropdown-item text-danger') + From d93fdd02e3d52102adf9b7536867c57348d65d4c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 20:39:42 +1200 Subject: [PATCH 361/549] get specs for browsing crops working --- spec/features/crops/browse_crops_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/features/crops/browse_crops_spec.rb b/spec/features/crops/browse_crops_spec.rb index 9a4c23ac3..d3386dc40 100644 --- a/spec/features/crops/browse_crops_spec.rb +++ b/spec/features/crops/browse_crops_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' describe "browse crops" do - let(:tomato) { create :tomato } - let(:maize) { create :maize } - let(:pending_crop) { create :crop_request } - let(:rejected_crop) { create :rejected_crop } + let!(:tomato) { FactoryBot.create :tomato } + let!(:maize) { FactoryBot.create :maize } + let!(:pending_crop) { FactoryBot.create :crop_request } + let!(:rejected_crop) { FactoryBot.create :rejected_crop } it "has a form for sorting by" do visit crops_path From 43fea8f905a3ab80155ad777b7456891463b7ad0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 21:09:36 +1200 Subject: [PATCH 362/549] style the navbar search --- app/assets/stylesheets/overrides.scss | 31 +++++++++++++++++++-------- app/views/crops/_search_bar.haml | 6 +++--- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index 7adbb7362..4bbc46d1b 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -58,14 +58,27 @@ h3 { padding-right: 1em; } -// .navbar .navbar-form -// padding-top: 0 -// padding-bottom: 0 -// margin-right: 0 -// margin-left: 15px -// border: 0 -// -webkit-box-shadow: none -// box-shadow: none +#navbar-search { + .input-group { + input { + background-color: $white; + color: $black; + } + input::placeholder { + color: $navbar-default-link-color; + } + } +} +.navbar .navbar-form { + +// padding-top: 0; +// padding-bottom: 0; +// margin-right: 0; +// margin-left: 15px; +// border: 0; +// -webkit-box-shadow: none; +// box-shadow: none; +} .index-cards { display: flex; @@ -416,7 +429,7 @@ ul.thumbnail-buttons { } .navbar .navbar-form { - //width: 185px + // width: 185px; padding-left: 0; padding-right: 0; diff --git a/app/views/crops/_search_bar.haml b/app/views/crops/_search_bar.haml index f6828156b..1c33eae3a 100644 --- a/app/views/crops/_search_bar.haml +++ b/app/views/crops/_search_bar.haml @@ -1,6 +1,6 @@ -= form_tag search_crops_path, method: :get, class: 'form-inline my-2 my-lg-0', id: 'navbar-search' do += form_tag search_crops_path, method: :get, class: 'form-inline', id: 'navbar-search' do .input-group - %input.form-control.mr-sm-2{name: 'term', "aria-label" => "Search crops", placeholder: "Search crops", type: "search"}/ + %input.form-control{name: 'term', "aria-label" => "Search crops", placeholder: "Search crops", type: "search"}/ %button.btn.btn-default.text-white{type: "submit"} = icon 'fas', 'search' - Search + .sr-only Search From cb1dcc9f8fef4b279e78108fe291eb1f779d2273 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 21:10:02 +1200 Subject: [PATCH 363/549] variables for scss --- app/assets/stylesheets/variables.scss | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/variables.scss b/app/assets/stylesheets/variables.scss index 83a8ee9c6..fe89ebdbb 100644 --- a/app/assets/stylesheets/variables.scss +++ b/app/assets/stylesheets/variables.scss @@ -12,19 +12,16 @@ $yellow: #b2935c; $white: #ffffff; -// $body-bg: $beige; -// $text-color: $brown; -// $link-color: $green; -// $graph-hover: $orange; - -// $brand-primary: $green; +$body-bg: $beige; +$text-color: $brown; +$link-color: $green; +$graph-hover: $orange; $primary: ( color: $green, dark: darken($green, 10%), light: lighten($green, 10%) ); - $secondary: ( color: $blue, dark: darken($blue, 10%), From 44fbae6776768e2c195e07ae21f322fe99ef1dc9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 14 Jun 2019 21:30:04 +1200 Subject: [PATCH 364/549] Use comments for blog icon So it doesn't look like an edit button --- app/helpers/icons_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 66274c1f7..88e47a300 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -46,7 +46,7 @@ module IconsHelper end def blog_icon - icon('fas', 'pen') + icon('fas', 'comments') end def perennial_icon From 45ba712eb776cbf045b0f47fc57bea9cac3f160f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 08:06:54 +1200 Subject: [PATCH 365/549] Fix database connection to share with capybara and the database cleaner to use transactions, not truncation --- spec/support/database_cleaner.rb | 36 +++++++++++++++++--------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb index dad9c5faf..8aa076438 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/support/database_cleaner.rb @@ -1,6 +1,5 @@ RSpec.configure do |config| - - # database cleaner warning if you turn this off + # a warning if you turn this off config.before(:suite) do if config.use_transactional_fixtures? raise(<<-MSG) @@ -17,26 +16,29 @@ RSpec.configure do |config| DatabaseCleaner.clean_with(:truncation) end + config.before(:each) do DatabaseCleaner.strategy = :transaction end - # config.before(:suite) do - # DatabaseCleaner.clean_with(:truncation) - # end - # config.before do - # DatabaseCleaner.strategy = :transaction - # end + config.before(:each, type: :feature) do + # :rack_test driver's Rack app under test shares database connection + # with the specs, so continue to use transaction strategy for speed. + driver_shares_db_connection_with_specs = Capybara.current_driver == :rack_test - # config.before(:each, js: true) do - # DatabaseCleaner.strategy = :truncation - # end + unless driver_shares_db_connection_with_specs + # Driver is probably for an external browser with an app + # under test that does *not* share a database connection with the + # specs, so use truncation strategy. + DatabaseCleaner.strategy = :truncation + end + end - # config.before do - # DatabaseCleaner.start - # end + config.before(:each) do + DatabaseCleaner.start + end - # config.after do - # DatabaseCleaner.clean - # end + config.append_after(:each) do + DatabaseCleaner.clean + end end From ad67b66313a6d90bc63448fbadc09578dad9e00f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 08:25:11 +1200 Subject: [PATCH 366/549] buttons on homepage blurb --- app/views/home/_blurb.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/home/_blurb.html.haml b/app/views/home/_blurb.html.haml index 486aa854b..9c942acad 100644 --- a/app/views/home/_blurb.html.haml +++ b/app/views/home/_blurb.html.haml @@ -6,5 +6,5 @@ .col-md-4 .signup %p= t('.perks') - %p= link_to(t('.sign_up'), new_member_registration_path, class: 'btn btn-success btn-block') - %p= t('.already_html', sign_in: link_to(t('.sign_in_linktext'), new_member_session_path, class: 'btn')) \ No newline at end of file + %p= link_to(t('.sign_up'), new_member_registration_path, class: 'btn btn-info btn-block') + %p= t('.already_html', sign_in: link_to(t('.sign_in_linktext'), new_member_session_path, class: 'btn btn-primary')) \ No newline at end of file From 4ed80dde7bb8ec12ef980cf54b73fedcf889be7f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 08:25:23 +1200 Subject: [PATCH 367/549] More contrast in colours --- app/assets/stylesheets/variables.scss | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/assets/stylesheets/variables.scss b/app/assets/stylesheets/variables.scss index fe89ebdbb..f2342de28 100644 --- a/app/assets/stylesheets/variables.scss +++ b/app/assets/stylesheets/variables.scss @@ -19,28 +19,28 @@ $graph-hover: $orange; $primary: ( color: $green, - dark: darken($green, 10%), - light: lighten($green, 10%) + dark: darken($green, 20%), + light: lighten($green, 20%) ); $secondary: ( color: $blue, - dark: darken($blue, 10%), - light: lighten($blue, 10%) + dark: darken($blue, 20%), + light: lighten($blue, 20%) ); $success: ( color: $green, - dark: darken($green, 10%), - light: lighten($green, 10%) + dark: darken($green, 20%), + light: lighten($green, 20%) ); $danger: ( color: $red, - dark: darken($red, 10%), - light: lighten($red, 10%) + dark: darken($red, 20%), + light: lighten($red, 20%) ); $dark: ( color: $brown, - dark: darken($brown, 10%), - light: lighten($brown, 10%) + dark: darken($brown, 20%), + light: lighten($brown, 20%) ); From fe7bc0f721caa6f93a78c181c29ce93667063855 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 08:33:17 +1200 Subject: [PATCH 368/549] tidy up link hovers --- app/assets/stylesheets/overrides.scss | 8 ++++++-- app/views/members/_tiny.haml | 3 +-- app/views/seeds/_card.html.haml | 10 +++++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index 4bbc46d1b..a3496358c 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -24,9 +24,13 @@ a { } a:hover { - color: $white; - background-color: $green; text-decoration: none; + color: $brown; +} + +.card a:hover { + color: $blue; + background-color: $beige; } span.badge { diff --git a/app/views/members/_tiny.haml b/app/views/members/_tiny.haml index 346da1165..f8c534b3d 100644 --- a/app/views/members/_tiny.haml +++ b/app/views/members/_tiny.haml @@ -1,2 +1 @@ -= link_to member do - = image_tag(avatar_uri(member, 50), alt: '', class: 'img img-responsive avatar rounded', height: 75) \ No newline at end of file += image_tag(avatar_uri(member, 50), alt: '', class: 'img img-fluid avatar', height: 50) \ No newline at end of file diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index d77f9e816..53857a724 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -5,6 +5,10 @@ %h5= link_to seed, seed - if seed.tradable? %span.badge.badge-pill.badge-secondary Will trade #{seed.tradable_to} - .card-footer - %span.badge.badge-pill.badge-secondary=seed.owner.location - %p.float-right= render 'members/tiny', member: seed.owner \ No newline at end of file + = link_to seed.owner do + .card-footer + %ul.nav.nav-justified.small + %li.nav-item + %span.badge.badge-pill.badge-secondary=seed.owner.location + %li.nav-item + = render 'members/tiny', member: seed.owner \ No newline at end of file From 29ae663a47d2e47fc2215b488bac3ce2def42604 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 08:36:10 +1200 Subject: [PATCH 369/549] we don't need to manually trigger javascript events anymore --- spec/support/feature_helpers.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb index 836ff35eb..4b87dc66c 100644 --- a/spec/support/feature_helpers.rb +++ b/spec/support/feature_helpers.rb @@ -4,8 +4,9 @@ module FeatureHelpers fill_in field, with: options[:with] - page.execute_script " $('##{field}').trigger('focus'); " - page.execute_script " $('##{field}').trigger('keydown'); " + # Not needed if using a real browser headless instead of poltergeist + # page.execute_script " $('##{field}').trigger('focus'); " + # page.execute_script " $('##{field}').trigger('keydown'); " end def select_from_autocomplete(select) From d82d20743c6de74d20d4761ff29e84d09a1e33f5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 08:49:18 +1200 Subject: [PATCH 370/549] Add the required class back to seeds form --- app/views/seeds/_form.html.haml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/views/seeds/_form.html.haml b/app/views/seeds/_form.html.haml index ddb8a1de3..af864927a 100644 --- a/app/views/seeds/_form.html.haml +++ b/app/views/seeds/_form.html.haml @@ -29,7 +29,6 @@ = f.text_field :plant_before, class: 'add-datepicker', value: @seed.plant_before ? @seed.plant_before.to_s(:ymd) : '' - .row .col-12 = f.check_box :finished, label: 'Mark as finished' @@ -39,13 +38,16 @@ %span.help-inline= t('.finish_helper') .row - .col-md-6.col-12= f.number_field :days_until_maturity_min, label_as_placeholder: true, label: 'min', prepend: 'Days until maturity' - .col-md-6.col-12= f.number_field :days_until_maturity_max, label_as_placeholder: true, label: 'max', prepend: 'to', append: "days" + .col-md-6= f.number_field :days_until_maturity_min, label_as_placeholder: true, label: 'min', prepend: 'Days until maturity' + .col-md-6= f.number_field :days_until_maturity_max, label_as_placeholder: true, label: 'max', prepend: 'to', append: "days" .row - .col-md-4.col-12= f.select(:organic, Seed::ORGANIC_VALUES, {label: 'Organic?'}, default: 'unknown') - .col-md-4.col-12= f.select(:gmo, Seed::GMO_VALUES, {label: 'GMO?'}, default: 'unknown') - .col-md-4.col-12= f.select(:heirloom, Seed::HEIRLOOM_VALUES, {label: 'Heirloom?'}, default: 'unknown') + .col-md-4 + = f.select(:organic, Seed::ORGANIC_VALUES, {label: 'Organic?', wrapper: { class: 'required'}}, default: 'unknown', required: true) + .col-md-4 + = f.select(:gmo, Seed::GMO_VALUES, {label: 'GMO?', wrapper: { class: 'required'}}, default: 'unknown', required: true) + .col-md-4 + = f.select(:heirloom, Seed::HEIRLOOM_VALUES, {label: 'Heirloom?', wrapper: { class: 'required'}}, default: 'unknown', required: true) = f.text_area :description, rows: 6 %hr/ From bfe3e1ea6953e9ff7af7e08cb1678930c95b876a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 08:50:34 +1200 Subject: [PATCH 371/549] Updated labels to look for in spec for adding seeds --- spec/features/seeds/adding_seeds_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb index 08d48e313..ce5ab31b4 100644 --- a/spec/features/seeds/adding_seeds_spec.rb +++ b/spec/features/seeds/adding_seeds_spec.rb @@ -17,7 +17,7 @@ describe "Seeds", :js, :elasticsearch do end describe "displays required and optional fields properly" do - it { expect(page).to have_selector ".form-group.required", text: "Crop:" } + it { expect(page).to have_selector ".form-group.required", text: "Crop" } it { expect(page).to have_selector 'input#seed_quantity' } it { expect(page).to have_selector 'input#seed_plant_before' } it { expect(page).to have_selector 'input#seed_days_until_maturity_min' } @@ -26,7 +26,7 @@ describe "Seeds", :js, :elasticsearch do it { expect(page).to have_selector '.form-group.required', text: 'GMO?' } it { expect(page).to have_selector '.form-group.required', text: 'Heirloom?' } it { expect(page).to have_selector 'textarea#seed_description' } - it { expect(page).to have_selector '.form-group.required', text: 'Will trade:' } + it { expect(page).to have_selector '.form-group.required', text: 'Will trade' } end describe "Adding a new seed", js: true do From 71e8f6f76ca12ae43ee50c44e7f870d224ec0633 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 10:56:56 +1200 Subject: [PATCH 372/549] tradeable is required fields --- app/views/seeds/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/seeds/_form.html.haml b/app/views/seeds/_form.html.haml index af864927a..323aae64f 100644 --- a/app/views/seeds/_form.html.haml +++ b/app/views/seeds/_form.html.haml @@ -52,7 +52,7 @@ %hr/ = t('.trade_help', site_name: ENV['GROWSTUFF_SITE_NAME']) - = f.select(:tradable_to, Seed::TRADABLE_TO_VALUES, {label: 'Will trade'}) + = f.select(:tradable_to, Seed::TRADABLE_TO_VALUES, {label: 'Will trade', wrapper: { class: 'required'}}) %span.help_inline - if current_member.location.blank? Don't forget to From 6abf717234f60ff54ad26276e8c0bcda65c3521e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 10:59:06 +1200 Subject: [PATCH 373/549] crop is required on seeds form --- app/views/seeds/_form.html.haml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/app/views/seeds/_form.html.haml b/app/views/seeds/_form.html.haml index 323aae64f..4cd5606d7 100644 --- a/app/views/seeds/_form.html.haml +++ b/app/views/seeds/_form.html.haml @@ -14,15 +14,18 @@ - @seed.errors.full_messages.each do |msg| %li= msg = required_field_help_text - = f.label :crop, 'Crop' - - if @planting - = link_to @planting, planting_path(@planting) - = f.hidden_field :parent_planting_id, value: @planting.id - - else - = auto_suggest @seed, :crop, class: 'form-control', default: @crop - %span.help-inline - Can't find what you're looking for? - = link_to "Request new crops.", new_crop_path + + .form-group.required + = f.label :crop, 'Crop' + - if @planting + = link_to @planting, planting_path(@planting) + = f.hidden_field :parent_planting_id, value: @planting.id + - else + + = auto_suggest @seed, :crop, class: 'form-control', default: @crop + %span.help-inline + Can't find what you're looking for? + = link_to "Request new crops.", new_crop_path .row .col-12= f.number_field :quantity, label: 'Quantity' .col-12 From e639c63565339b2621bcf5a6765e59f8d041d18d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 13:21:41 +1200 Subject: [PATCH 374/549] Link to production at top of readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2f2e0aced..46dbdcb09 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ Welcome to the Growstuff project. +You can find our app at https://www.growstuff.org + Growstuff is an open source/open data project to create a website for food gardeners. We crowdsource information on what our members are growing and harvesting, aggregate it, and make it available as open data From d21cbf994ba2bda0e5402f08bbc67413b4edb140 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 13:10:54 +1200 Subject: [PATCH 375/549] poltergeist work around not needed anymore --- spec/features/crops/alternate_name_spec.rb | 8 ++++---- spec/features/plantings/planting_a_crop_spec.rb | 8 ++------ spec/support/feature_helpers.rb | 5 ----- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb index 2656517eb..04c344409 100644 --- a/spec/features/crops/alternate_name_spec.rb +++ b/spec/features/crops/alternate_name_spec.rb @@ -43,10 +43,10 @@ describe "Alternate names", js: true do it "Crop wranglers can delete alternate names" do visit crop_path(alternate_eggplant.crop) click_link 'aubergine' - expect(page).to have_link "Delete", - href: alternate_name_path(alternate_eggplant) - within('.alternate_names') { click_on "Delete" } - dismiss_confirm {click_link 'OK'} + expect(page).to have_link "Delete", href: alternate_name_path(alternate_eggplant) + accept_confirm do + click_link 'Delete' + end expect(pending_alt_name.status_code).to equal 200 expect(page).not_to have_content alternate_eggplant.name expect(page).to have_content 'Alternate name was successfully deleted' diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 28a6be9cc..24925b073 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -207,11 +207,7 @@ describe "Planting a crop", :js, :elasticsearch do fill_in "When?", with: "2014-07-01" check "Mark as finished" fill_in "Finished date", with: "2014-08-30" - - # Trigger click instead of using Capybara"s uncheck - # because a date selection widget is overlapping - # the checkbox preventing interaction. - find("#planting_finished").trigger 'click' + uncheck 'Mark as finished' end # Javascript removes the finished at date when the @@ -219,7 +215,7 @@ describe "Planting a crop", :js, :elasticsearch do expect(find("#planting_finished_at").value).to eq("") within "form#new_planting" do - find("#planting_finished").trigger 'click' + check 'Mark as finished' end # The finished at date was cached in Javascript in diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb index 4b87dc66c..857e6b250 100644 --- a/spec/support/feature_helpers.rb +++ b/spec/support/feature_helpers.rb @@ -1,12 +1,7 @@ module FeatureHelpers def fill_autocomplete(field, options = {}) Crop.reindex if ENV["GROWSTUFF_ELASTICSEARCH"] == "true" - fill_in field, with: options[:with] - - # Not needed if using a real browser headless instead of poltergeist - # page.execute_script " $('##{field}').trigger('focus'); " - # page.execute_script " $('##{field}').trigger('keydown'); " end def select_from_autocomplete(select) From 3bc69e65c23aedd64d605c7eb1c0bba8993b2e48 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 15:18:32 +1200 Subject: [PATCH 376/549] Click actions menu before checking for links in garden feature specs --- app/views/gardens/_actions.html.haml | 2 +- spec/features/gardens/actions_spec.rb | 36 ++++++++++++++------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index 99fbd6972..715dcdf38 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -1,6 +1,6 @@ - if can?(:edit, garden) .dropdown.float-right.garden-actions - %button#garden-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions + %a#garden-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button", href: '#'} Actions .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "garden-actions-button"} - if can?(:edit, garden) = garden_plant_something_button(garden, classes: 'dropdown-item') if garden.active diff --git a/spec/features/gardens/actions_spec.rb b/spec/features/gardens/actions_spec.rb index 4da6b1e32..0e53e178b 100644 --- a/spec/features/gardens/actions_spec.rb +++ b/spec/features/gardens/actions_spec.rb @@ -26,12 +26,16 @@ describe "Gardens" do before { visit gardens_path(member_slug: member.slug) } include_examples "has buttons bar at top" - it "has actions on garden" do - expect(subject).to have_link 'Plant something here' - expect(subject).to have_link 'Mark as inactive' - expect(subject).to have_link 'Edit' - expect(subject).to have_link 'Add photo' - expect(subject).to have_link 'Delete' + + context 'with actions menu expanded' do + before { click_link 'Actions' } + it "has actions on garden" do + expect(subject).to have_link 'Plant something here' + expect(subject).to have_link 'Mark as inactive' + expect(subject).to have_link 'Edit' + expect(subject).to have_link 'Add photo' + expect(subject).to have_link 'Delete' + end end end @@ -46,8 +50,7 @@ describe "Gardens" do include_examples "has buttons bar at top" describe 'does not show actions on other member garden' do - it { is_expected.not_to have_link 'Edit' } - it { is_expected.not_to have_link 'Delete' } + it { is_expected.not_to have_link 'Actions' } end end end @@ -56,19 +59,18 @@ describe "Gardens" do describe 'my garden' do before { visit garden_path(garden) } - it { is_expected.to have_link 'Edit' } - it { is_expected.to have_link 'Delete' } - it { is_expected.to have_content "Plant something here" } - it { is_expected.to have_content "Add photo" } + context 'with actions menu expanded' do + before { click_link 'Actions' } + it { is_expected.to have_link 'Edit' } + it { is_expected.to have_link 'Delete' } + it { is_expected.to have_content "Plant something here" } + it { is_expected.to have_content "Add photo" } + end end describe "someone else's garden" do before { visit garden_path(other_member_garden) } - - it { is_expected.not_to have_link 'Edit' } - it { is_expected.not_to have_link 'Delete' } - it { is_expected.not_to have_content "Plant something here" } - it { is_expected.not_to have_content "Add photo" } + it { is_expected.not_to have_link 'Actions' } end end end From 2a0c93ed1afb8d6594407468799203e8987bbc59 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 17:11:40 +1200 Subject: [PATCH 377/549] wrangle menu - and capybara needs to have screen size big enough to see the menu --- app/views/crops/_wrangle.html.haml | 21 ++++++++++----------- spec/rails_helper.rb | 3 +++ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/views/crops/_wrangle.html.haml b/app/views/crops/_wrangle.html.haml index 3207d34b5..7cedc4ca3 100644 --- a/app/views/crops/_wrangle.html.haml +++ b/app/views/crops/_wrangle.html.haml @@ -3,16 +3,15 @@ %h4 Crop wrangling %p You are a - = succeed "." do - %strong CROP WRANGLER - .dropdown.crop-actions - %a#crop-actions-button.btn.btn-info.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button", href: '#'} Actions - .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "crop-actions-button"} - = link_to edit_crop_path(crop), class: 'dropdown-item' do - = edit_icon - = t('.edit') + %strong CROP WRANGLER + .dropdown.crop-actions + %a#crop-actions-button.btn.btn-info.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button", href: '#'} Actions + .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "crop-actions-button"} + = link_to edit_crop_path(crop), class: 'dropdown-item' do + = edit_icon + = t('.edit') - - if can? :destroy, crop - .dropdown-divider - = delete_button(crop, classes: 'dropdown-item text-danger') + - if can? :destroy, crop + .dropdown-divider + = delete_button(crop, classes: 'dropdown-item text-danger') diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 7c7d7148e..c5dbe582b 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -36,6 +36,9 @@ Capybara::Screenshot.register_filename_prefix_formatter(:rspec) do |example| "screenshot_#{example.description.tr(' ', '-').gsub(%r{^.*/spec/}, '')}" end +width = 1280 +height = 1280 +Capybara.current_session.driver.browser.manage.window.resize_to(width, height) Capybara.app_host = 'http://localhost' Capybara.server_port = 8081 From 8599543daf5d6df6f7d44ff8494271a9ade963de Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 17:13:22 +1200 Subject: [PATCH 378/549] actions menu is a link, not a button. fix spec --- spec/features/crops/crop_wranglers_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/crops/crop_wranglers_spec.rb b/spec/features/crops/crop_wranglers_spec.rb index da83f2f0f..77571c0d4 100644 --- a/spec/features/crops/crop_wranglers_spec.rb +++ b/spec/features/crops/crop_wranglers_spec.rb @@ -35,7 +35,7 @@ describe "crop wranglers", js: true do describe "visiting a crop can see wrangler links" do before do visit crop_path(crops.first) - click_button 'Actions' + click_link 'Actions' end it { expect(page).to have_content 'You are a CROP WRANGLER' } From 9993c610cb51247fbc1a072a34263eb95d3bad42 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 18:20:51 +1200 Subject: [PATCH 379/549] Update rego form, so it matches the specs --- app/views/devise/registrations/new.html.haml | 32 ++++++++------------ 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index 5668b3b52..9535996e7 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -1,37 +1,31 @@ .form-page - %section.card.form-card - %h1 Join Growstuff + .card.form-card + %h1 Join #{ENV['GROWSTUFF_SITE_NAME']} .card-body - %p Sign up for a Growstuff account to track your veggie garden and connect with other local growers. + %p Sign up for a #{ENV['GROWSTUFF_SITE_NAME']} account to track your vegetable garden and connect with other local growers. - = form_for(resource, as: resource_name, - url: registration_path(resource_name), + = bootstrap_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { class: "text-center border border-light p-5" }) do |f| = devise_error_messages! - = f.text_field :login_name, class: 'form-control form-control-lg{', placeholder: 'login name' + = f.text_field :login_name %span This is the name that will show on the website. = icon 'fas', 'email' - = f.email_field :email, class: 'form-control', placeholder: 'email', type: :email + = f.email_field :email %span We'll use this address to contact you (we never spam!) - %hr/ - = f.password_field :password, class: "form-control", placeholder: 'password', type: :password - = f.password_field :password_confirmation, class: 'form-control', placeholder: 'confirm password' - - %hr/ + = f.password_field :password, type: :password + = f.password_field :password_confirmation %p - = f.check_box :tos_agreement - I agree to the - = link_to 'Terms of Service', "#{root_url}/policy/tos" + = f.check_box :tos_agreement, label: "I agree" + to the #{link_to 'Terms of Service', "/policy/tos"} %p - = f.check_box :newsletter, checked: true - Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} newsletter + = f.check_box :newsletter, checked: true, label: "Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} newsletter" %p= render partial: 'newsletter_blurb' - = f.submit "Sign up", class: 'btn btn-block my-4 btn-success' + = f.submit "Sign up", class: 'btn btn-block btn-success' - = render "devise/shared/links" + .card-footer= render "devise/shared/links" From 6d15f1393e2694592b4cce05ca069ad827664c78 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 18:53:21 +1200 Subject: [PATCH 380/549] confirm the alert dialogue when deleting --- spec/features/gardens_spec.rb | 4 +++- spec/features/scientific_name_spec.rb | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 816995dad..6e99f4f54 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -86,7 +86,9 @@ describe "Planting a crop", js: true do fill_in "Name", with: "New garden" click_button "Save" visit garden_path(Garden.last) - click_link 'Delete' + accept_confirm do + click_link 'Delete' + end expect(page).to have_content "Garden was successfully deleted" expect(page).to have_content "#{garden.owner}'s gardens" end diff --git a/spec/features/scientific_name_spec.rb b/spec/features/scientific_name_spec.rb index a113b6e07..0f12c4891 100644 --- a/spec/features/scientific_name_spec.rb +++ b/spec/features/scientific_name_spec.rb @@ -45,7 +45,11 @@ describe "Scientific names", js: true do click_link zea_mays.name expect(page).to have_link "Delete", href: scientific_name_path(zea_mays) - within('.scientific_names') { click_on "Delete" } + within('.scientific_names') do + accept_confirm do + click_link 'Delete' + end + end expect(page.status_code).to equal 200 expect(page).not_to have_content zea_mays.name expect(page).to have_content 'Scientific name was successfully deleted.' From 7bc497d92c1dc7ee37a4236fae8104854a218ade Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 18:56:18 +1200 Subject: [PATCH 381/549] add href to seeds actions so capybara can find it --- app/views/seeds/_actions.html.haml | 3 ++- spec/features/photos/new_photo_spec.rb | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/seeds/_actions.html.haml b/app/views/seeds/_actions.html.haml index e2200a743..716724399 100644 --- a/app/views/seeds/_actions.html.haml +++ b/app/views/seeds/_actions.html.haml @@ -4,7 +4,8 @@ Plant seeds - if can?(:edit, seed) .dropdown.float-right.seed-actions - %a#seed-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions + %a#seed-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button", href: '#'} + Actions .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "seed-actions-button"} = seed_edit_button(seed, classes: 'dropdown-item') = add_photo_button(seed, classes: 'dropdown-item') diff --git a/spec/features/photos/new_photo_spec.rb b/spec/features/photos/new_photo_spec.rb index 71cdfc198..7c45dd717 100644 --- a/spec/features/photos/new_photo_spec.rb +++ b/spec/features/photos/new_photo_spec.rb @@ -49,6 +49,7 @@ describe "new photo page" do it "add photo" do visit seed_path(seed) + click_link 'Actions' first('.seed-actions').click_link('Add photo') expect(page).to have_text seed.to_s end From 9fb07501bbe5dbe5666629337d4fcacc475ab152 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 18:59:11 +1200 Subject: [PATCH 382/549] click actions in menu when capybara test is adding photos --- spec/features/photos/new_photo_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/features/photos/new_photo_spec.rb b/spec/features/photos/new_photo_spec.rb index 7c45dd717..8bf89fc7e 100644 --- a/spec/features/photos/new_photo_spec.rb +++ b/spec/features/photos/new_photo_spec.rb @@ -13,6 +13,7 @@ describe "new photo page" do it "add photo" do visit planting_path(planting) + click_link 'Actions' within '.planting-actions' do click_link('Add photo') end @@ -25,6 +26,7 @@ describe "new photo page" do it "add photo" do visit harvest_path(harvest) + click_link 'Actions' within '.harvest-actions' do click_link "Add photo" end @@ -37,6 +39,7 @@ describe "new photo page" do it "add photo" do visit garden_path(garden) + click_link 'Actions' within '.garden-actions' do click_link "Add photo" end From 4b0b91c4d99f5f859c072c963b1d6209b1af0c72 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 19:13:11 +1200 Subject: [PATCH 383/549] Update spec for editing seeds --- spec/features/seeds/misc_seeds_spec.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/spec/features/seeds/misc_seeds_spec.rb b/spec/features/seeds/misc_seeds_spec.rb index 0d75dc3c4..620a07823 100644 --- a/spec/features/seeds/misc_seeds_spec.rb +++ b/spec/features/seeds/misc_seeds_spec.rb @@ -8,12 +8,13 @@ describe "seeds", js: true do before { login_as member } - describe "button on index to edit seed" do + xit "button on index to edit seed" do let!(:seed) { create :seed, owner: member } before do visit seeds_path - click_link "edit_seed_glyphicon" + click_link 'Actions' + click_link "Edit" end it { expect(current_path).to eq edit_seed_path(seed) } @@ -23,7 +24,7 @@ describe "seeds", js: true do describe "button on front page to add seeds" do before do visit root_path - click_link "Save seeds" + click_link(href: new_seed_path) end it { expect(current_path).to eq new_seed_path } @@ -44,9 +45,10 @@ describe "seeds", js: true do it "edit seeds" do seed = create :seed, owner: member visit seed_path(seed) + click_link 'Actions' click_link 'Edit' expect(current_path).to eq edit_seed_path(seed) - fill_in 'Quantity:', with: seed.quantity * 2 + fill_in 'Quantity', with: seed.quantity * 2 click_button 'Save' expect(current_path).to eq seed_path(seed) end @@ -56,7 +58,10 @@ describe "seeds", js: true do before do visit seed_path(seed) - click_link 'Delete' + click_link 'Actions' + accept_confirm do + click_link 'Delete' + end end it { expect(current_path).to eq seeds_path } From e678cc38418e38ae58945b11a68ef5807bf346e2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 19:37:39 +1200 Subject: [PATCH 384/549] can't check status code - so check text instead --- spec/features/members/deletion_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb index 64ceda9ad..1ad610727 100644 --- a/spec/features/members/deletion_spec.rb +++ b/spec/features/members/deletion_spec.rb @@ -60,7 +60,7 @@ describe "member deletion" do fill_in "current_pw_for_delete", with: "password1", match: :prefer_exact click_button "Delete" visit member_path(member) - expect(page.status_code).to eq(404) + expect(page).to have_text "The page you were looking for doesn't exist." end context "deletes and" do @@ -81,22 +81,22 @@ describe "member deletion" do it "removes plantings" do visit planting_path(planting) - expect(page.status_code).to eq(404) + expect(page).to have_text "The page you were looking for doesn't exist." end it "removes gardens" do visit garden_path(secondgarden) - expect(page.status_code).to eq(404) + expect(page).to have_text "The page you were looking for doesn't exist." end it "removes harvests and seeds" do visit harvest_path(harvest) - expect(page.status_code).to eq(404) + expect(page).to have_text "The page you were looking for doesn't exist." end it "removes seeds" do visit seed_path(seed) - expect(page.status_code).to eq(404) + expect(page).to have_text "The page you were looking for doesn't exist." end it "removes members from following" do @@ -108,7 +108,7 @@ describe "member deletion" do it "replaces posts with deletion note" do visit post_path(memberpost) - expect(page.status_code).to eq(404) + expect(page).to have_text "The page you were looking for doesn't exist." end it "replaces comments on others' posts with deletion note, leaving post intact" do From d2fdb499ed3146ba42679bc76b8d56a324cfc69d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 20:05:18 +1200 Subject: [PATCH 385/549] Move member specs to members folder --- spec/features/{members_list_spec.rb => members/list_spec.rb} | 0 spec/features/{member_profile_spec.rb => members/profile_spec.rb} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename spec/features/{members_list_spec.rb => members/list_spec.rb} (100%) rename spec/features/{member_profile_spec.rb => members/profile_spec.rb} (100%) diff --git a/spec/features/members_list_spec.rb b/spec/features/members/list_spec.rb similarity index 100% rename from spec/features/members_list_spec.rb rename to spec/features/members/list_spec.rb diff --git a/spec/features/member_profile_spec.rb b/spec/features/members/profile_spec.rb similarity index 100% rename from spec/features/member_profile_spec.rb rename to spec/features/members/profile_spec.rb From adb0a1043d4dd272f1a7c568d1d03fd8dc39570d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 20:07:48 +1200 Subject: [PATCH 386/549] Move gardens specs to gardens folder --- spec/features/{ => crops}/scientific_name_spec.rb | 0 spec/features/{ => gardens}/gardens_spec.rb | 0 spec/features/gardens/{gardens_index_spec.rb => index_spec.rb} | 0 spec/features/{ => members}/following_spec.rb | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename spec/features/{ => crops}/scientific_name_spec.rb (100%) rename spec/features/{ => gardens}/gardens_spec.rb (100%) rename spec/features/gardens/{gardens_index_spec.rb => index_spec.rb} (100%) rename spec/features/{ => members}/following_spec.rb (100%) diff --git a/spec/features/scientific_name_spec.rb b/spec/features/crops/scientific_name_spec.rb similarity index 100% rename from spec/features/scientific_name_spec.rb rename to spec/features/crops/scientific_name_spec.rb diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens/gardens_spec.rb similarity index 100% rename from spec/features/gardens_spec.rb rename to spec/features/gardens/gardens_spec.rb diff --git a/spec/features/gardens/gardens_index_spec.rb b/spec/features/gardens/index_spec.rb similarity index 100% rename from spec/features/gardens/gardens_index_spec.rb rename to spec/features/gardens/index_spec.rb diff --git a/spec/features/following_spec.rb b/spec/features/members/following_spec.rb similarity index 100% rename from spec/features/following_spec.rb rename to spec/features/members/following_spec.rb From 70bfcabaecabaf87c48735b9a9479541c1476682 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 21:18:10 +1200 Subject: [PATCH 387/549] Add seeds to member profile, and update specs --- app/controllers/members_controller.rb | 12 ++++++++++++ app/views/members/show.html.haml | 6 ++++++ spec/features/members/profile_spec.rb | 20 ++++++++++---------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index ae13c3bd9..4c65a65ca 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -68,6 +68,17 @@ class MembersController < ApplicationController ) end + def seeds_for_show + Seed.select( + :id, + "'seed' as event_type", + "seeds.created_at as event_at", + 'seeds.owner_id', + 'crop_id', + 'slug' + ) + end + def show @member = Member.confirmed.find_by!(slug: params[:slug]) @twitter_auth = @member.auth('twitter') @@ -81,6 +92,7 @@ class MembersController < ApplicationController .union_all(posts_for_show) .union_all(comments_for_show) .union_all(photos_for_show) + .union_all(seeds_for_show) .where(owner_id: @member.id) .order(event_at: :desc) .limit(30) diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 2a0574998..1f9be055d 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -63,6 +63,12 @@ = planting_icon planted = link_to planting.crop, planting + - elsif event.event_type == 'seed' + - seed = Seed.find(event.id) + = seed_icon + saved + = link_to seed.crop, seed + seeds - elsif event.event_type == 'harvest' - harvest = Harvest.find(event.id) = harvest_icon diff --git a/spec/features/members/profile_spec.rb b/spec/features/members/profile_spec.rb index 913115188..afaf2ebee 100644 --- a/spec/features/members/profile_spec.rb +++ b/spec/features/members/profile_spec.rb @@ -75,16 +75,16 @@ describe "member profile", js: true do expect(page).to have_content "0 posts" end - it "with some activity" do - create_list :planting, 2, owner: member - create_list :harvest, 3, owner: member - create_list :seed, 4, owner: member - create_list :post, 5, author: member - visit member_path(member) - expect(page).to have_link "2 plantings", href: member_plantings_path(member) - expect(page).to have_link "3 harvests", href: member_harvests_path(member) - expect(page).to have_link "4 seeds", href: member_seeds_path(member) - expect(page).to have_link "5 posts", href: member_posts_path(member) + context "with some activity" do + let!(:planting) { FactoryBot.create :planting, owner: member } + let!(:harvest) { FactoryBot.create :harvest, owner: member } + let!(:seed) { FactoryBot.create :seed, owner: member } + let!(:post) { FactoryBot.create :post, author: member } + before {visit member_path(member) } + it { expect(page).to have_link(href: planting_path(planting)) } + it { expect(page).to have_link(href: harvest_path(harvest)) } + it { expect(page).to have_link(href: seed_path(seed)) } + it { expect(page).to have_link(href: post_path(post)) } end end From 6eea0c4a8e5b5beb237ebcef4f670809b0d18923 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 21:42:41 +1200 Subject: [PATCH 388/549] Restore message button --- app/views/members/show.html.haml | 19 +++++++++++-------- spec/features/members/profile_spec.rb | 19 +++++-------------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 1f9be055d..4fbf3ba37 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -1,5 +1,4 @@ - content_for :title, @member.login_name -- content_for :subtitle, @member.location - content_for :opengraph do = tag("meta", property: "og:image", content: avatar_uri(@member, 200)) = tag("meta", property: "og:image:user_generated", content: "true") @@ -22,7 +21,9 @@ = render "bio", member: @member %p - @member.roles.each do |role| - %span.badge.badge-info= role.name + %span.badge.badge-info= role.name.titleize + %p + = @member.location %p %strong Member since = @member.created_at.to_s(:date) @@ -31,19 +32,21 @@ = @member.last_sign_in_at - if can? :update, @member - = link_to edit_member_registration_path, class: 'btn btn-default' do - = edit_icon + = link_to edit_member_registration_path, class: 'btn btn-block' do + = member_icon = t('members.edit_profile') - - if can?(:create, Notification) && current_member != @member - = link_to 'Send message', new_notification_path(recipient_id: @member.id), class: 'btn btn-default' + - if can?(:create, Notification) && current_member != @member + = link_to new_notification_path(recipient_id: @member.id), class: 'btn btn-block' do + = icon('fas', 'envelope') + Send message - if current_member && current_member != @member # must be logged in, can't follow yourself - follow = current_member.get_follow(@member) - if !follow && can?(:create, Follow) # not already following - = link_to 'Follow', follows_path(followed: @member), method: :post, class: 'btn btn-default' + = link_to 'Follow', follows_path(followed: @member), method: :post, class: 'btn btn-block' - if follow && can?(:destroy, follow) # already following - = link_to 'Unfollow', follow_path(follow), method: :delete, class: 'btn btn-default' + = link_to 'Unfollow', follow_path(follow), method: :delete, class: 'btn btn-block' = render "stats", member: @member .card-footer = render "contact", member: @member, twitter_auth: @twitter_auth, diff --git a/spec/features/members/profile_spec.rb b/spec/features/members/profile_spec.rb index afaf2ebee..1b20cb5e4 100644 --- a/spec/features/members/profile_spec.rb +++ b/spec/features/members/profile_spec.rb @@ -6,10 +6,9 @@ describe "member profile", js: true do it "basic details on member profile page" do visit member_path(member) - expect(page).to have_css("h1", text: member.login_name) + expect(page).to have_content("All about #{member.login_name}") expect(page).to have_content member.bio - expect(page).to have_content "Member since: #{member.created_at.to_s(:date)}" - expect(page).to have_link "More about this garden...", href: garden_path(member.gardens.first) + expect(page).to have_content "Member since #{member.created_at.to_s(:date)}" end it "no bio" do @@ -28,7 +27,7 @@ describe "member profile", js: true do it "member has set location" do london_member = create :london_member visit member_path(london_member) - expect(page).to have_css("h1>small", text: london_member.location) + expect(page).to have_content(london_member.location) expect(page).to have_css("#membermap") expect(page).to have_content "See other members, plantings, seeds and more near #{london_member.location}" end @@ -107,9 +106,7 @@ describe "member profile", js: true do let(:admin_member) { create :admin_member } let(:crop_wrangler) { create :crop_wrangling_member } - before do - login_as(member) - end + before { login_as(member) } it "admin user's page" do visit member_path(admin_member) @@ -128,13 +125,7 @@ describe "member profile", js: true do end context "your own profile page" do - before do - visit member_path(member) - end - - it "has a link to create new garden" do - expect(page).to have_link "New Garden", href: new_garden_path - end + before {visit member_path(member) } it "has a button to edit profile" do expect(page).to have_link "Edit profile", href: edit_member_registration_path From 67d90ec6f0e48f946adb9e0e5eaa909fc033cf9c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 22:20:51 +1200 Subject: [PATCH 389/549] mark status test as pending until we work out how on headless chrome --- spec/features/rss/members_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/features/rss/members_spec.rb b/spec/features/rss/members_spec.rb index 8bf13b3c5..34d06be05 100644 --- a/spec/features/rss/members_spec.rb +++ b/spec/features/rss/members_spec.rb @@ -3,13 +3,13 @@ require 'rails_helper' describe 'Members RSS feed' do let(:member) { create :member } - it 'The show action exists' do - visit member_path(member, format: 'rss') + before { visit member_path(member, format: 'rss') } + + pending 'The show action exists' do expect(page.status_code).to equal 200 end it 'The show action title is what we expect' do - visit member_path(member, format: 'rss') expect(page).to have_content "#{member.login_name}'s recent posts (#{ENV['GROWSTUFF_SITE_NAME']})" end end From 8ca5098f0f99b6dca9093031d890aa4e41f694a0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 22:35:39 +1200 Subject: [PATCH 390/549] photos display tidy up --- app/views/photos/_card.html.haml | 9 +++++++++ app/views/photos/_gallery.haml | 11 +++-------- app/views/plantings/_photos.haml | 10 ++++------ 3 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 app/views/photos/_card.html.haml diff --git a/app/views/photos/_card.html.haml b/app/views/photos/_card.html.haml new file mode 100644 index 000000000..6855c15da --- /dev/null +++ b/app/views/photos/_card.html.haml @@ -0,0 +1,9 @@ +.card + = link_to image_tag(photo.fullsize_url, alt: photo.title, class: 'img img-card'), photo + .card-body + %h3.ellipsis= link_to photo.title, photo + %p + %i by #{link_to photo.owner, photo.owner} + - if photo.date_taken.present? + %small= I18n.l(photo.date_taken.to_date) + diff --git a/app/views/photos/_gallery.haml b/app/views/photos/_gallery.haml index b2d72fac7..b61ebe7b1 100644 --- a/app/views/photos/_gallery.haml +++ b/app/views/photos/_gallery.haml @@ -1,8 +1,3 @@ -.photos-grid - .photo-grid-item= link_to image_tag(photos.first.fullsize_url, class: 'rounded mx-auto hero-photo'), photos.first - - photos.offset(1).each do |photo| - .photo-grid-item - = link_to photo do - = render 'photos/thumbnail', photo: photo - - if photo.date_taken.present? - %small= I18n.l(photo.date_taken.to_date) +- photos.each do |photo| + .photo-grid-item= render 'photos/card', photo: photo + diff --git a/app/views/plantings/_photos.haml b/app/views/plantings/_photos.haml index ef94a9e35..00141c76f 100644 --- a/app/views/plantings/_photos.haml +++ b/app/views/plantings/_photos.haml @@ -1,11 +1,9 @@ %h2 Photos - if planting.photos.size.positive? - .row - = render 'photos/gallery', photos: photos - .row - - if can?(:edit, planting) && can?(:create, Photo) - %p.text-right= add_photo_button(planting) - %p.text-right= link_to 'more photos', planting_photos_path(@planting), class: 'btn' + = render 'photos/gallery', photos: photos + - if can?(:edit, planting) && can?(:create, Photo) + %p.text-right= add_photo_button(planting) + %p.text-right= link_to 'more photos', planting_photos_path(@planting), class: 'btn' - else %p No photos. - if can?(:edit, planting) && can?(:create, Photo) From 505f0b24d3d5d92eb117dcf893975ad5f02e0fb6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 15 Jun 2019 22:53:10 +1200 Subject: [PATCH 391/549] tidy up crops photos --- app/views/crops/_photos.html.haml | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index ed164d82d..1151e330d 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -1,14 +1,11 @@ -%section.photos - - if @crop.photos.size.positive? - %h2 #{photo_icon} Photos - - [Planting, Harvest, Seed].each do |model_name| - - if photos.by_model(model_name).size.positive? - .crop-photos - %h3 - #{@crop.name.capitalize} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} - .index-cards - - photos.by_model(model_name).limit(6).each do |photo| - = render 'photos/thumbnail', photo: photo +- if @crop.photos.size.positive? + %h2 #{photo_icon} Photos + - [Planting, Harvest, Seed].each do |model_name| + - if photos.by_model(model_name).size.positive? + .crop-photos + %h3 #{@crop.name.capitalize} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} + .index-cards + = render 'photos/gallery', photos: photos.by_model(model_name).limit(8) - = link_to 'more photos »', crop_photos_path(@crop), class: 'btn' - %hr/ + = link_to 'more photos »', crop_photos_path(@crop), class: 'btn' + %hr/ From 36897433bf0ac8c3a1cab654f6e0c63d5c1b4c61 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 16 Jun 2019 10:23:51 +1200 Subject: [PATCH 392/549] login can be email or loginname --- app/views/devise/sessions/new.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 76bb744e9..00f47cbc5 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -6,7 +6,7 @@ url: session_path(resource_name), html: { class: "text-center border border-light p-5" }) do |f| = devise_error_messages! - = f.text_field :login, type: "email", label: 'Login', required: true + = f.text_field :login, label: 'Login', required: true = f.password_field :password, type: "password" - if devise_mapping.rememberable? %p From 31e1545a21f9433ec9f2b705fcecdaa847258f35 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 16 Jun 2019 10:25:13 +1200 Subject: [PATCH 393/549] comment out status code test until it works with chrome headless --- spec/features/crops/alternate_name_spec.rb | 14 +++++++------- spec/features/crops/scientific_name_spec.rb | 16 ++++++++-------- spec/features/rss/comments_spec.rb | 2 +- spec/features/rss/crops_spec.rb | 2 +- spec/features/rss/members_spec.rb | 2 +- spec/features/rss/plantings_spec.rb | 2 +- spec/features/rss/posts_spec.rb | 2 +- spec/features/rss/seeds_spec.rb | 2 +- spec/features/signout_spec.rb | 8 ++++---- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb index 04c344409..6fb6df2cd 100644 --- a/spec/features/crops/alternate_name_spec.rb +++ b/spec/features/crops/alternate_name_spec.rb @@ -6,7 +6,7 @@ describe "Alternate names", js: true do it "Display alternate names on crop page" do visit crop_path(alternate_eggplant.crop) - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_content alternate_eggplant.name end @@ -25,17 +25,17 @@ describe "Alternate names", js: true do it "Crop wranglers can edit alternate names" do visit crop_path(crop) - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_content "CROP WRANGLER" expect(page).to have_content alternate_eggplant.name click_link 'aubergine' expect(page).to have_link "Edit", href: edit_alternate_name_path(alternate_eggplant) within('.alternate_names') { click_on "Edit" } - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" fill_in 'Name', with: "alternative aubergine" click_on "Save" - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_content "alternative aubergine" expect(page).to have_content 'Alternate name was successfully updated' end @@ -57,18 +57,18 @@ describe "Alternate names", js: true do expect(page).to have_link "Add", href: new_alternate_name_path(crop_id: crop.id) within('.alternate_names') { click_on "Add" } - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" fill_in 'Name', with: "not an aubergine" click_on "Save" - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_content "not an aubergine" expect(page).to have_content 'Alternate name was successfully created' end it "The show-alternate-name page works" do visit alternate_name_path(alternate_eggplant) - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_content alternate_eggplant.crop.name end diff --git a/spec/features/crops/scientific_name_spec.rb b/spec/features/crops/scientific_name_spec.rb index 0f12c4891..be428f7b0 100644 --- a/spec/features/crops/scientific_name_spec.rb +++ b/spec/features/crops/scientific_name_spec.rb @@ -6,13 +6,13 @@ describe "Scientific names", js: true do it "Display scientific names on crop page" do visit crop_path(zea_mays.crop) - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_content zea_mays.name end it "Index page for scientific names" do visit scientific_names_path - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_content zea_mays.name end @@ -26,13 +26,13 @@ describe "Scientific names", js: true do it "Crop wranglers can edit scientific names" do visit crop_path(crop) - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_content "CROP WRANGLER" expect(page).to have_content zea_mays.name click_link zea_mays.name expect(page).to have_link "Edit", href: edit_scientific_name_path(zea_mays) within('.scientific_names') { click_on "Edit" } - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" fill_in 'Name', with: "Zea mirabila" click_on "Save" @@ -50,7 +50,7 @@ describe "Scientific names", js: true do click_link 'Delete' end end - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).not_to have_content zea_mays.name expect(page).to have_content 'Scientific name was successfully deleted.' end @@ -60,18 +60,18 @@ describe "Scientific names", js: true do expect(page).to have_link "Add", href: new_scientific_name_path(crop_id: crop.id) within('.scientific_names') { click_on "Add" } - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" fill_in 'Name', with: "Zea mirabila" click_on "Save" - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_content "Zea mirabila" expect(page).to have_content 'crop was successfully created.' end it "The show-scientific-name page works" do visit scientific_name_path(zea_mays) - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_link zea_mays.crop.name, href: crop_path(zea_mays.crop) end diff --git a/spec/features/rss/comments_spec.rb b/spec/features/rss/comments_spec.rb index fef92010a..547866f85 100644 --- a/spec/features/rss/comments_spec.rb +++ b/spec/features/rss/comments_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe 'Comments RSS feed' do it 'The index feed exists' do visit comments_path(format: 'rss') - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 end it 'The index title is what we expect' do diff --git a/spec/features/rss/crops_spec.rb b/spec/features/rss/crops_spec.rb index 80ca34b29..ca1514dd2 100644 --- a/spec/features/rss/crops_spec.rb +++ b/spec/features/rss/crops_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe 'Crops RSS feed' do it 'The index feed exists' do visit crops_path(format: 'rss') - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 end it 'The index title is what we expect' do diff --git a/spec/features/rss/members_spec.rb b/spec/features/rss/members_spec.rb index 34d06be05..59fc6a8ed 100644 --- a/spec/features/rss/members_spec.rb +++ b/spec/features/rss/members_spec.rb @@ -6,7 +6,7 @@ describe 'Members RSS feed' do before { visit member_path(member, format: 'rss') } pending 'The show action exists' do - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 end it 'The show action title is what we expect' do diff --git a/spec/features/rss/plantings_spec.rb b/spec/features/rss/plantings_spec.rb index 7624c22c0..ec3ff4de3 100644 --- a/spec/features/rss/plantings_spec.rb +++ b/spec/features/rss/plantings_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe 'Plantings RSS feed' do it 'The index feed exists' do visit plantings_path(format: 'rss') - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 end it 'The index title is what we expect' do diff --git a/spec/features/rss/posts_spec.rb b/spec/features/rss/posts_spec.rb index 93797c7bc..d68bdfd50 100644 --- a/spec/features/rss/posts_spec.rb +++ b/spec/features/rss/posts_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe 'Posts RSS feed' do it 'The index feed exists' do visit posts_path(format: 'rss') - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 end it 'The index title is what we expect' do diff --git a/spec/features/rss/seeds_spec.rb b/spec/features/rss/seeds_spec.rb index 5ae25949e..ab4229253 100644 --- a/spec/features/rss/seeds_spec.rb +++ b/spec/features/rss/seeds_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe 'Seeds RSS feed' do it 'The index feed exists' do visit seeds_path(format: 'rss') - expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 end it 'The index title is what we expect' do diff --git a/spec/features/signout_spec.rb b/spec/features/signout_spec.rb index 69f285ea7..c94221b1e 100644 --- a/spec/features/signout_spec.rb +++ b/spec/features/signout_spec.rb @@ -19,14 +19,14 @@ describe "signout" do it "after signout, redirect to signin page if page needs authentication" do visit path expect(current_path).to eq new_member_session_path - expect(page).to have_http_status(200) + # expect(page).to have_http_status(200) fill_in 'Login', with: member.login_name fill_in 'Password', with: member.password click_button 'Sign in' - expect(page).to have_http_status(200) + # expect(page).to have_http_status(200) expect(current_path).to eq path click_link 'Sign out' - expect(page).to have_http_status(200) + # expect(page).to have_http_status(200) expect(current_path).to eq new_member_session_path end end @@ -43,7 +43,7 @@ describe "signout" do garden = FactoryBot.create :garden, owner: member visit "/photos/new?id=#{garden.id}&type=garden" expect(current_path).to eq new_member_session_path - expect(page).to have_http_status(200) + # expect(page).to have_http_status(200) # photos/new needs id&type params, # but these are stripped after signing in end From 391874e27e1eaf6b931a7192204872ba6be9b05e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 16 Jun 2019 10:30:09 +1200 Subject: [PATCH 394/549] rubocop lint fixes --- spec/features/crops/alternate_name_spec.rb | 14 +++++++------- spec/features/members/deletion_spec.rb | 10 +++++----- spec/features/members/profile_spec.rb | 4 ++-- spec/features/rss/comments_spec.rb | 2 +- spec/features/rss/crops_spec.rb | 2 +- spec/features/rss/members_spec.rb | 2 +- spec/features/rss/plantings_spec.rb | 2 +- spec/features/rss/posts_spec.rb | 2 +- spec/features/rss/seeds_spec.rb | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb index 6fb6df2cd..497713cc8 100644 --- a/spec/features/crops/alternate_name_spec.rb +++ b/spec/features/crops/alternate_name_spec.rb @@ -6,7 +6,7 @@ describe "Alternate names", js: true do it "Display alternate names on crop page" do visit crop_path(alternate_eggplant.crop) - # expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_content alternate_eggplant.name end @@ -25,17 +25,17 @@ describe "Alternate names", js: true do it "Crop wranglers can edit alternate names" do visit crop_path(crop) - # expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_content "CROP WRANGLER" expect(page).to have_content alternate_eggplant.name click_link 'aubergine' expect(page).to have_link "Edit", href: edit_alternate_name_path(alternate_eggplant) within('.alternate_names') { click_on "Edit" } - # expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" fill_in 'Name', with: "alternative aubergine" click_on "Save" - # expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_content "alternative aubergine" expect(page).to have_content 'Alternate name was successfully updated' end @@ -57,18 +57,18 @@ describe "Alternate names", js: true do expect(page).to have_link "Add", href: new_alternate_name_path(crop_id: crop.id) within('.alternate_names') { click_on "Add" } - # expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" fill_in 'Name', with: "not an aubergine" click_on "Save" - # expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_content "not an aubergine" expect(page).to have_content 'Alternate name was successfully created' end it "The show-alternate-name page works" do visit alternate_name_path(alternate_eggplant) - # expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 expect(page).to have_content alternate_eggplant.crop.name end diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb index 1ad610727..7d5ac5972 100644 --- a/spec/features/members/deletion_spec.rb +++ b/spec/features/members/deletion_spec.rb @@ -81,22 +81,22 @@ describe "member deletion" do it "removes plantings" do visit planting_path(planting) - expect(page).to have_text "The page you were looking for doesn't exist." + expect(page).to have_text "The page you were looking for doesn't exist." end it "removes gardens" do visit garden_path(secondgarden) - expect(page).to have_text "The page you were looking for doesn't exist." + expect(page).to have_text "The page you were looking for doesn't exist." end it "removes harvests and seeds" do visit harvest_path(harvest) - expect(page).to have_text "The page you were looking for doesn't exist." + expect(page).to have_text "The page you were looking for doesn't exist." end it "removes seeds" do visit seed_path(seed) - expect(page).to have_text "The page you were looking for doesn't exist." + expect(page).to have_text "The page you were looking for doesn't exist." end it "removes members from following" do @@ -108,7 +108,7 @@ describe "member deletion" do it "replaces posts with deletion note" do visit post_path(memberpost) - expect(page).to have_text "The page you were looking for doesn't exist." + expect(page).to have_text "The page you were looking for doesn't exist." end it "replaces comments on others' posts with deletion note, leaving post intact" do diff --git a/spec/features/members/profile_spec.rb b/spec/features/members/profile_spec.rb index 1b20cb5e4..057e96925 100644 --- a/spec/features/members/profile_spec.rb +++ b/spec/features/members/profile_spec.rb @@ -79,7 +79,7 @@ describe "member profile", js: true do let!(:harvest) { FactoryBot.create :harvest, owner: member } let!(:seed) { FactoryBot.create :seed, owner: member } let!(:post) { FactoryBot.create :post, author: member } - before {visit member_path(member) } + before { visit member_path(member) } it { expect(page).to have_link(href: planting_path(planting)) } it { expect(page).to have_link(href: harvest_path(harvest)) } it { expect(page).to have_link(href: seed_path(seed)) } @@ -125,7 +125,7 @@ describe "member profile", js: true do end context "your own profile page" do - before {visit member_path(member) } + before { visit member_path(member) } it "has a button to edit profile" do expect(page).to have_link "Edit profile", href: edit_member_registration_path diff --git a/spec/features/rss/comments_spec.rb b/spec/features/rss/comments_spec.rb index 547866f85..1b0263d6d 100644 --- a/spec/features/rss/comments_spec.rb +++ b/spec/features/rss/comments_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe 'Comments RSS feed' do it 'The index feed exists' do visit comments_path(format: 'rss') - # expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 end it 'The index title is what we expect' do diff --git a/spec/features/rss/crops_spec.rb b/spec/features/rss/crops_spec.rb index ca1514dd2..704dd60ba 100644 --- a/spec/features/rss/crops_spec.rb +++ b/spec/features/rss/crops_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe 'Crops RSS feed' do it 'The index feed exists' do visit crops_path(format: 'rss') - # expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 end it 'The index title is what we expect' do diff --git a/spec/features/rss/members_spec.rb b/spec/features/rss/members_spec.rb index 59fc6a8ed..aa110789b 100644 --- a/spec/features/rss/members_spec.rb +++ b/spec/features/rss/members_spec.rb @@ -6,7 +6,7 @@ describe 'Members RSS feed' do before { visit member_path(member, format: 'rss') } pending 'The show action exists' do - # expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 end it 'The show action title is what we expect' do diff --git a/spec/features/rss/plantings_spec.rb b/spec/features/rss/plantings_spec.rb index ec3ff4de3..7a6e31b95 100644 --- a/spec/features/rss/plantings_spec.rb +++ b/spec/features/rss/plantings_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe 'Plantings RSS feed' do it 'The index feed exists' do visit plantings_path(format: 'rss') - # expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 end it 'The index title is what we expect' do diff --git a/spec/features/rss/posts_spec.rb b/spec/features/rss/posts_spec.rb index d68bdfd50..0b85590c4 100644 --- a/spec/features/rss/posts_spec.rb +++ b/spec/features/rss/posts_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe 'Posts RSS feed' do it 'The index feed exists' do visit posts_path(format: 'rss') - # expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 end it 'The index title is what we expect' do diff --git a/spec/features/rss/seeds_spec.rb b/spec/features/rss/seeds_spec.rb index ab4229253..5a50e8811 100644 --- a/spec/features/rss/seeds_spec.rb +++ b/spec/features/rss/seeds_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe 'Seeds RSS feed' do it 'The index feed exists' do visit seeds_path(format: 'rss') - # expect(page.status_code).to equal 200 + # expect(page.status_code).to equal 200 end it 'The index title is what we expect' do From ef91e26d2812ff0d01b1d54afee199e9dff11fda Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 16 Jun 2019 10:31:03 +1200 Subject: [PATCH 395/549] rubocop lint fixes --- Gemfile | 2 +- app/controllers/sessions_controller.rb | 4 +--- app/models/crop.rb | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index b30f06225..331630639 100644 --- a/Gemfile +++ b/Gemfile @@ -143,7 +143,7 @@ group :development, :test do gem 'haml-i18n-extractor' gem 'haml-rails' # HTML templating language gem 'haml_lint', '>= 0.25.1' # Checks haml files for goodness - gem 'i18n-tasks' # adds tests for finding missing and unused translations + gem 'i18n-tasks' # adds tests for finding missing and unused translations # gem 'poltergeist' # for headless JS testing gem 'rspec-activemodel-mocks' gem 'rspec-rails' # unit testing framework diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 6106e0c75..47870d38d 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -3,9 +3,7 @@ class SessionsController < Devise::SessionsController def create super do |_resource| - if Crop.pending_approval.present? && current_member.role?(:crop_wrangler) - flash[:alert] = "There are crops waiting to be wrangled." - end + flash[:alert] = "There are crops waiting to be wrangled." if Crop.pending_approval.present? && current_member.role?(:crop_wrangler) end end end diff --git a/app/models/crop.rb b/app/models/crop.rb index 96605bd23..ebd23f150 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -55,9 +55,7 @@ class Crop < ApplicationRecord #################################### # Elastic search configuration - if ENV["GROWSTUFF_ELASTICSEARCH"] == "true" - searchkick word_start: %i(name alternate_names scientific_names), case_sensitive: false - end + searchkick word_start: %i(name alternate_names scientific_names), case_sensitive: false if ENV["GROWSTUFF_ELASTICSEARCH"] == "true" def planting_photos Photo.joins(:plantings).where("plantings.crop_id": id) From b9dcd9e5b92184e40db7ee9d2295f71534225643 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 16 Jun 2019 17:06:33 +1200 Subject: [PATCH 396/549] Added missing icons --- app/views/plantings/_form.html.haml | 1 + app/views/seeds/_form.html.haml | 1 + 2 files changed, 2 insertions(+) diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml index bfbbf3dd2..220a9599f 100644 --- a/app/views/plantings/_form.html.haml +++ b/app/views/plantings/_form.html.haml @@ -2,6 +2,7 @@ .card-header - if content_for? :title %h1.h2-responsive.text-center + = planting_icon %strong=yield :title = bootstrap_form_for(@planting) do |f| .card-body diff --git a/app/views/seeds/_form.html.haml b/app/views/seeds/_form.html.haml index 4cd5606d7..5d0facb58 100644 --- a/app/views/seeds/_form.html.haml +++ b/app/views/seeds/_form.html.haml @@ -3,6 +3,7 @@ .card-header - if content_for? :title %h1.h2-responsive.text-center + = seed_icon %strong=yield :title .card-body - if @seed.errors.any? From a11193dcc60039418700fa00f1ad9f357a0727de Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 16 Jun 2019 17:06:49 +1200 Subject: [PATCH 397/549] show date planted --- app/views/plantings/_card.html.haml | 5 ++--- app/views/plantings/_progress.html.haml | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/plantings/_card.html.haml b/app/views/plantings/_card.html.haml index a539ff14f..6e70e5408 100644 --- a/app/views/plantings/_card.html.haml +++ b/app/views/plantings/_card.html.haml @@ -21,6 +21,5 @@ .card-body.text-center %h4.card-title= link_to planting.crop, planting .text-center= render 'plantings/badges', planting: planting - - if planting.percentage_grown.present? - .card-footer - = render 'plantings/progress', planting: planting \ No newline at end of file + .card-footer + = render 'plantings/progress', planting: planting \ No newline at end of file diff --git a/app/views/plantings/_progress.html.haml b/app/views/plantings/_progress.html.haml index acb1804a2..6577f2403 100644 --- a/app/views/plantings/_progress.html.haml +++ b/app/views/plantings/_progress.html.haml @@ -1,3 +1,5 @@ +- if planting.planted_at.present? + planted #{planting.planted_at} - if planting.percentage_grown.present? .progress .progress-bar.bg-success{"aria-valuemax" => "100", "aria-valuemin" => "0", "aria-valuenow" => planting.percentage_grown, :role => "progressbar", :style => "width: #{planting.percentage_grown}%; height: 25px"} From 941dc498f0d35cd66d6ee1da5db65915b676fe09 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 16 Jun 2019 17:07:04 +1200 Subject: [PATCH 398/549] Fix homepage links! --- app/views/home/index.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 701636ec7..1910e83aa 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -23,10 +23,10 @@ .row .col-md-6 =render 'plantings' - %p.text-right= link_to "#{t('home.plantings.view_all')} »", seeds_path, class: 'btn btn-block' + %p.text-right= link_to "#{t('home.plantings.view_all')} »", plantings_path, class: 'btn btn-block' .col-md-6 = render 'harvests' - %p.text-right= link_to "#{t('home.harvests.view_all')} »", seeds_path, class: 'btn btn-block' + %p.text-right= link_to "#{t('home.harvests.view_all')} »", harvests_path, class: 'btn btn-block' %section.seeds.mx-auto %h2.text-center= t('.seeds_available_to_trade') From ea261748c3530b7ffa33f3c83dd93d0548596609 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 16 Jun 2019 21:14:31 +1200 Subject: [PATCH 399/549] Update crop spec to expect the full size photos --- spec/features/crops/crop_photos_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/features/crops/crop_photos_spec.rb b/spec/features/crops/crop_photos_spec.rb index 1507a5a15..e66d645d3 100644 --- a/spec/features/crops/crop_photos_spec.rb +++ b/spec/features/crops/crop_photos_spec.rb @@ -30,18 +30,18 @@ describe "crop detail page", js: true do shared_examples "shows photos" do describe "show planting photos" do - it { is_expected.to have_xpath("//img[contains(@src,'#{photo1.thumbnail_url}')]") } - it { is_expected.to have_xpath("//img[contains(@src,'#{photo2.thumbnail_url}')]") } + it { is_expected.to have_xpath("//img[contains(@src,'#{photo1.fullsize_url}')]") } + it { is_expected.to have_xpath("//img[contains(@src,'#{photo2.fullsize_url}')]") } end describe "show harvest photos" do - it { is_expected.to have_xpath("//img[contains(@src,'#{photo3.thumbnail_url}')]") } - it { is_expected.to have_xpath("//img[contains(@src,'#{photo4.thumbnail_url}')]") } + it { is_expected.to have_xpath("//img[contains(@src,'#{photo3.fullsize_url}')]") } + it { is_expected.to have_xpath("//img[contains(@src,'#{photo4.fullsize_url}')]") } end describe "show seed photos" do - it { is_expected.to have_xpath("//img[contains(@src,'#{photo5.thumbnail_url}')]") } - it { is_expected.to have_xpath("//img[contains(@src,'#{photo6.thumbnail_url}')]") } + it { is_expected.to have_xpath("//img[contains(@src,'#{photo5.fullsize_url}')]") } + it { is_expected.to have_xpath("//img[contains(@src,'#{photo6.fullsize_url}')]") } end describe "link to more photos" do From 02b312ea810ea69421f15bdb598f8a5690a22549 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 17 Jun 2019 10:39:51 +1200 Subject: [PATCH 400/549] Gardens actions in the actions menu, and needing the confirm --- spec/features/gardens/gardens_spec.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/spec/features/gardens/gardens_spec.rb b/spec/features/gardens/gardens_spec.rb index 6e99f4f54..f1d449bf1 100644 --- a/spec/features/gardens/gardens_spec.rb +++ b/spec/features/gardens/gardens_spec.rb @@ -26,16 +26,24 @@ describe "Planting a crop", js: true do it "Marking a garden as inactive" do visit garden_path(garden) - click_link "Mark as inactive" + click_link 'Actions' + accept_confirm do + click_link "Mark as inactive" + end expect(page).to have_content "Garden was successfully updated" expect(page).to have_content "This garden is inactive" + + click_link 'Actions' expect(page).to have_content "Mark as active" expect(page).not_to have_content "Mark as inactive" end it "List only active gardens" do visit garden_path(garden) - click_link "Mark as inactive" + click_link 'Actions' + accept_confirm do + click_link "Mark as inactive" + end visit gardens_path expect(page).not_to have_link garden_path(garden) end @@ -63,6 +71,7 @@ describe "Planting a crop", js: true do end it "button on index to edit garden" do + click_link 'Actions' click_link href: edit_garden_path(garden) expect(page).to have_content 'Edit garden' end @@ -72,6 +81,7 @@ describe "Planting a crop", js: true do visit new_garden_path fill_in "Name", with: "New garden" click_button "Save" + click_link 'Actions' within '.garden-actions' do click_link 'Edit' end @@ -86,6 +96,7 @@ describe "Planting a crop", js: true do fill_in "Name", with: "New garden" click_button "Save" visit garden_path(Garden.last) + click_link 'Actions' accept_confirm do click_link 'Delete' end From f35444bf9efa55b710f1bde9b6d4f67653e7ac1e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 17 Jun 2019 10:40:23 +1200 Subject: [PATCH 401/549] add href to the plantings quick actions links --- app/views/plantings/_card.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/plantings/_card.html.haml b/app/views/plantings/_card.html.haml index 6e70e5408..23cee3cec 100644 --- a/app/views/plantings/_card.html.haml +++ b/app/views/plantings/_card.html.haml @@ -4,7 +4,7 @@ - if can? :edit, planting .planting-quick-actions .dropdown - %a.planting-menu.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button"} + %a.planting-menu.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button", href: '#'} .dropdown-menu{"aria-labelledby" => "planting-menu"} = planting_edit_button(planting, classes: 'dropdown-item') = add_photo_button(planting, classes: 'dropdown-item') From 7fc434bd00cf7bd7bbecbde8214c625047d64e3f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 17 Jun 2019 10:40:34 +1200 Subject: [PATCH 402/549] remove whitespace --- app/views/gardens/index.html.haml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/views/gardens/index.html.haml b/app/views/gardens/index.html.haml index a7623ec9e..444b9c4dc 100644 --- a/app/views/gardens/index.html.haml +++ b/app/views/gardens/index.html.haml @@ -13,8 +13,6 @@ - else %li.breadcrumb-item.active= link_to 'Gardens', gardens_path - - = link_to gardens_active_tickbox_path(@owner, @show_all) do = check_box_tag 'active', 'all', @show_all include in-active From fcf4e0f15dabb27a5870747b8cf912cf71209b5c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 17 Jun 2019 10:42:12 +1200 Subject: [PATCH 403/549] Icons from icon8, used with permission --- .gitignore | 2 -- app/assets/images/icons/delete.svg | 11 ++++++++++ app/assets/images/icons/finished.svg | 23 +++++++++++++++++++++ app/assets/images/icons/garden.svg | 26 ++++++++++++++++++++++++ app/assets/images/icons/harvest.svg | 5 +++++ app/assets/images/icons/home.svg | 5 +++++ app/assets/images/icons/plant-seeds.svg | 3 +++ app/assets/images/icons/planting.svg | 5 +++++ app/assets/images/icons/post.svg | 6 ++++++ app/assets/images/icons/seeds-colour.svg | 18 ++++++++++++++++ app/assets/images/icons/seeds.svg | 5 +++++ app/assets/images/icons/trade.svg | 5 +++++ app/assets/stylesheets/overrides.scss | 4 ++++ app/helpers/icons_helper.rb | 15 +++++++++----- 14 files changed, 126 insertions(+), 7 deletions(-) create mode 100644 app/assets/images/icons/delete.svg create mode 100644 app/assets/images/icons/finished.svg create mode 100644 app/assets/images/icons/garden.svg create mode 100644 app/assets/images/icons/harvest.svg create mode 100644 app/assets/images/icons/home.svg create mode 100644 app/assets/images/icons/plant-seeds.svg create mode 100644 app/assets/images/icons/planting.svg create mode 100644 app/assets/images/icons/post.svg create mode 100644 app/assets/images/icons/seeds-colour.svg create mode 100644 app/assets/images/icons/seeds.svg create mode 100644 app/assets/images/icons/trade.svg diff --git a/.gitignore b/.gitignore index 0cb26bd3b..96147c719 100644 --- a/.gitignore +++ b/.gitignore @@ -29,5 +29,3 @@ cc-test-reporter elasticsearch-*.deb elasticsearch-*.deb.sha512 -app/assets/images/*.svg -app/assets/images/icons/*.svg diff --git a/app/assets/images/icons/delete.svg b/app/assets/images/icons/delete.svg new file mode 100644 index 000000000..899b79b86 --- /dev/null +++ b/app/assets/images/icons/delete.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/app/assets/images/icons/finished.svg b/app/assets/images/icons/finished.svg new file mode 100644 index 000000000..e1e151dda --- /dev/null +++ b/app/assets/images/icons/finished.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/assets/images/icons/garden.svg b/app/assets/images/icons/garden.svg new file mode 100644 index 000000000..11b9396f7 --- /dev/null +++ b/app/assets/images/icons/garden.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/assets/images/icons/harvest.svg b/app/assets/images/icons/harvest.svg new file mode 100644 index 000000000..e941e9e92 --- /dev/null +++ b/app/assets/images/icons/harvest.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/assets/images/icons/home.svg b/app/assets/images/icons/home.svg new file mode 100644 index 000000000..ae5dc8d22 --- /dev/null +++ b/app/assets/images/icons/home.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/assets/images/icons/plant-seeds.svg b/app/assets/images/icons/plant-seeds.svg new file mode 100644 index 000000000..86fc2a6c7 --- /dev/null +++ b/app/assets/images/icons/plant-seeds.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/app/assets/images/icons/planting.svg b/app/assets/images/icons/planting.svg new file mode 100644 index 000000000..48d867aa0 --- /dev/null +++ b/app/assets/images/icons/planting.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/assets/images/icons/post.svg b/app/assets/images/icons/post.svg new file mode 100644 index 000000000..2e8615513 --- /dev/null +++ b/app/assets/images/icons/post.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/app/assets/images/icons/seeds-colour.svg b/app/assets/images/icons/seeds-colour.svg new file mode 100644 index 000000000..b2bc3e95b --- /dev/null +++ b/app/assets/images/icons/seeds-colour.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/assets/images/icons/seeds.svg b/app/assets/images/icons/seeds.svg new file mode 100644 index 000000000..e546336af --- /dev/null +++ b/app/assets/images/icons/seeds.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/assets/images/icons/trade.svg b/app/assets/images/icons/trade.svg new file mode 100644 index 000000000..d2395b956 --- /dev/null +++ b/app/assets/images/icons/trade.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index a3496358c..d6c9d6c65 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -95,6 +95,10 @@ h3 { } } +img.img-icon { + width: 1.2em; +} + .img-square { object-fit: cover; height: 150px; diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 88e47a300..68a84e9b0 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -2,11 +2,11 @@ module IconsHelper include FontAwesome::Sass::Rails::ViewHelpers def garden_icon - icon('fas', 'square') + image_icon 'home' end def planting_icon - icon('fas', 'seedling') + image_icon 'planting' end def member_icon @@ -14,11 +14,11 @@ module IconsHelper end def harvest_icon - icon('fas', 'carrot') + image_icon 'harvest' end def seed_icon - icon('fas', 'heart') + image_icon 'seeds' end def comment_icon @@ -46,7 +46,7 @@ module IconsHelper end def blog_icon - icon('fas', 'comments') + image_icon 'post' end def perennial_icon @@ -72,4 +72,9 @@ module IconsHelper image_tag("sunniness_not_specified.png", class: 'img', alt: 'unknown', width: 55) end end + + def image_icon(icon) + image_tag "icons/#{icon}.svg", class: 'img img-icon' + end + end From 52403d8dd62ac0406619526ba1a3329cd668b015 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 16 Jun 2019 15:02:39 +1200 Subject: [PATCH 404/549] Pin elasticsearch back at 6, to fix errors on staging/prod --- Gemfile | 1 + Gemfile.lock | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index ae27ffe12..5d1b6fe6f 100644 --- a/Gemfile +++ b/Gemfile @@ -88,6 +88,7 @@ gem "chartkick" # clever elastic search gem 'searchkick' +gem 'elasticsearch', '< 7.0.0' gem "hashie", ">= 3.5.3" diff --git a/Gemfile.lock b/Gemfile.lock index be0674706..578f0b411 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -63,9 +63,9 @@ GEM erubi (>= 1.0.0) rack (>= 0.9.0) bluecloth (2.2.0) - bonsai-elasticsearch-rails (7.0.1) - elasticsearch-model (< 8) - elasticsearch-rails (< 8) + bonsai-elasticsearch-rails (6.0.0) + elasticsearch-model (~> 6) + elasticsearch-rails (~> 6) bootstrap-datepicker-rails (1.8.0.1) railties (>= 3.0) bootstrap-kaminari-views (0.0.5) @@ -142,17 +142,17 @@ GEM warden (~> 1.2.3) diff-lcs (1.3) docile (1.1.5) - elasticsearch (7.1.0) - elasticsearch-api (= 7.1.0) - elasticsearch-transport (= 7.1.0) - elasticsearch-api (7.1.0) + elasticsearch (6.8.0) + elasticsearch-api (= 6.8.0) + elasticsearch-transport (= 6.8.0) + elasticsearch-api (6.8.0) multi_json elasticsearch-model (6.0.0) activesupport (> 3) elasticsearch (> 1) hashie elasticsearch-rails (6.0.0) - elasticsearch-transport (7.1.0) + elasticsearch-transport (6.8.0) faraday multi_json erubi (1.8.0) @@ -543,6 +543,7 @@ DEPENDENCIES dalli database_cleaner devise + elasticsearch (< 7.0.0) factory_bot_rails faker figaro @@ -609,4 +610,4 @@ RUBY VERSION ruby 2.6.0p0 BUNDLED WITH - 1.17.2 + 1.17.3 From f24ae3aafb2b0853931d7f29d78e0c55039234b1 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Sun, 16 Jun 2019 03:04:51 +0000 Subject: [PATCH 405/549] [CodeFactor] Apply fixes --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 5d1b6fe6f..eb3f8e8ae 100644 --- a/Gemfile +++ b/Gemfile @@ -87,8 +87,8 @@ gem 'omniauth-twitter' gem "chartkick" # clever elastic search -gem 'searchkick' gem 'elasticsearch', '< 7.0.0' +gem 'searchkick' gem "hashie", ">= 3.5.3" From cafc514ee5d91f05189f3b7de16ec6a361e6f2fa Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 24 Jun 2019 18:06:32 +1200 Subject: [PATCH 406/549] spec updates --- spec/features/crops/crop_detail_page_spec.rb | 5 +---- spec/features/gardens/gardens_spec.rb | 6 +++++- spec/views/comments/new.html.haml_spec.rb | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index 15b5dfed5..b94ebe107 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -16,10 +16,7 @@ describe "crop detail page", js: true do context "varieties" do it "The crop DOES NOT have varieties" do visit crop_path(crop) - - within ".varieties" do - expect(page).not_to have_text 'tomato' - end + expect(page).not_to have_text 'Varieties' end end diff --git a/spec/features/gardens/gardens_spec.rb b/spec/features/gardens/gardens_spec.rb index f1d449bf1..3ca3a26c3 100644 --- a/spec/features/gardens/gardens_spec.rb +++ b/spec/features/gardens/gardens_spec.rb @@ -107,7 +107,11 @@ describe "Planting a crop", js: true do describe "Making a planting inactive from garden show" do let(:path) { garden_path garden } let(:link_text) { "Mark as finished" } - + before do + within '.planting-quick-actions' do + click_link(aclass: 'planting-menu') + end + end it_behaves_like "append date" end diff --git a/spec/views/comments/new.html.haml_spec.rb b/spec/views/comments/new.html.haml_spec.rb index cc6638936..5892fce0b 100644 --- a/spec/views/comments/new.html.haml_spec.rb +++ b/spec/views/comments/new.html.haml_spec.rb @@ -11,15 +11,15 @@ describe "comments/new" do end it "shows the text of the post under discussion" do - rendered.should have_content @post.body + expect(rendered).to have_content @post.body end it "shows previous comments" do - rendered.should have_content @comment.body + expect(rendered).to have_content @comment.body end it "shows the correct comment count" do - rendered.should have_content "1 comment" + expect(rendered).to have_content "1 comment" end it "renders new comment form" do @@ -29,6 +29,6 @@ describe "comments/new" do end it 'shows markdown help' do - rendered.should have_content 'Markdown' + expect(rendered).to have_content 'Markdown' end end From 2546d0c704462b3d295b22d4a968d11d24201b1c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 24 Jun 2019 18:11:08 +1200 Subject: [PATCH 407/549] Split the search places spec, to quicker see what broke --- spec/features/places/searching_a_place_spec.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/spec/features/places/searching_a_place_spec.rb b/spec/features/places/searching_a_place_spec.rb index 29e49ce21..2db703c0a 100644 --- a/spec/features/places/searching_a_place_spec.rb +++ b/spec/features/places/searching_a_place_spec.rb @@ -7,13 +7,15 @@ describe "User searches" do let!(:seed1) { create :seed, owner: member } let!(:planting) { create :planting, garden: garden, owner: member, planted_at: Date.parse("2013-3-10") } - it "with a valid place" do - visit places_path - search_with "Philippines" - expect(page).to have_content "community near Philippines" - expect(page).to have_button "search_button" - expect(page).to have_content "Nearby members" - expect(page).not_to have_content "No results found" + describe "with a valid place" do + before do + visit places_path + search_with "Philippines" + end + it { expect(page).to have_content "community near Philippines" } + it { expect(page).to have_button "search_button" } + it { expect(page).to have_content "Nearby members" } + it { expect(page).not_to have_content "No results found" } end it "with a blank search string" do From c797f33c0869d817b047e8daa6c0efca10e1607f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 24 Jun 2019 18:12:48 +1200 Subject: [PATCH 408/549] add title back to places search --- app/views/places/show.html.haml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/places/show.html.haml b/app/views/places/show.html.haml index d005f2429..23fa46e3e 100644 --- a/app/views/places/show.html.haml +++ b/app/views/places/show.html.haml @@ -5,6 +5,8 @@ = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) + +%h1 #{ENV['GROWSTUFF_SITE_NAME']} community near #{@place} = render partial: 'search_form' #placesmap{ style: "height:300px" } From 926915aca038a05ed8f34603ac6bd4a52db56eca Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 24 Jun 2019 18:29:18 +1200 Subject: [PATCH 409/549] Update rss spec we can't check status codes anymore --- spec/features/rss/members_spec.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spec/features/rss/members_spec.rb b/spec/features/rss/members_spec.rb index aa110789b..1daefcd51 100644 --- a/spec/features/rss/members_spec.rb +++ b/spec/features/rss/members_spec.rb @@ -5,10 +5,6 @@ describe 'Members RSS feed' do before { visit member_path(member, format: 'rss') } - pending 'The show action exists' do - # expect(page.status_code).to equal 200 - end - it 'The show action title is what we expect' do expect(page).to have_content "#{member.login_name}'s recent posts (#{ENV['GROWSTUFF_SITE_NAME']})" end From 3f24fbe18165c03291d74a998cc5f80994d91aeb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 24 Jun 2019 18:38:28 +1200 Subject: [PATCH 410/549] rubocop linting --- app/helpers/icons_helper.rb | 1 - spec/features/percy/percy_spec.rb | 35 +++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 68a84e9b0..7422a44e6 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -76,5 +76,4 @@ module IconsHelper def image_icon(icon) image_tag "icons/#{icon}.svg", class: 'img img-icon' end - end diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index a2422b951..2a1c76493 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -27,19 +27,39 @@ describe 'Test with visual testing', type: :feature, js: true do let(:post_body) do "So, um, watering's important. Yep. Very important. -Well, what with moving into the house and all THAT entails...my plants are looking the worse for wear. They haven't gotten enough water. The oregano is dead. The basil and chives are just hanging on. The [tomato](crop) have sort of purple leaves. Seeing that the roots were all growing out of the bottom of the pots, I finally went and got soil to fill the basins I have for the tomatoes and spent the money on proper (much larger) pots for the herbs. +Well, what with moving into the house and all THAT entails...my plants +are looking the worse for wear. They haven't gotten enough water. The +oregano is dead. The basil and chives are just hanging on. The +[tomato](crop) have sort of purple leaves. Seeing that the roots were all +growing out of the bottom of the pots, I finally went and got soil +to fill the basins I have for the tomatoes and spent the money on proper +(much larger) pots for the herbs. -At Home Depot, it turned out that 7.5\" pots that are glazed inside and out (to prevent wicking & evaporation of water -- the problem my tomatoes were hitting with the teensy clay pots) were $10 for the pot and $5 for the saucer. Or there are 7.25\" self-watering pots for $15. So my herbs are now in self-watering pots where they should be able to survive Pennsic without me. I got a new oregano plant too. +At Home Depot, it turned out that 7.5\" pots that are glazed inside and out +(to prevent wicking & evaporation of water -- the problem my tomatoes +were hitting with the teensy clay pots) were $10 for the pot and $5 +for the saucer. Or there are 7.25\" self-watering pots for $15. So my + herbs are now in self-watering pots where they should be able to + survive Pennsic without me. I got a new oregano plant too. [ ![self-watering herbs](http://farm4.staticflickr.com/3735/9337893326_62a036bf56.jpg) ](http://www.flickr.com/photos/maco_nix/9337893326/) -The tomatoes are now in large plastic bins full of dirt/compost, where their roots can spread out. Turns out clay pots in weather that is always over 80, usually over 90, and hitting over 100 (celsius people, read those as 26, 32, 38) means you need to water at least daily, probably a couple of times a day, to keep the plants happy. +The tomatoes are now in large plastic bins full of dirt/compost, where +their roots can spread out. Turns out clay pots in weather that is always over 80, +usually over 90, and hitting over 100 (celsius people, read those as 26, 32, 38) +means you need to water at least daily, probably a couple of times a day, to keep +the plants happy. [ ![tomatoes in plastic cement mixing tubs](http://farm4.staticflickr.com/3745/9337878942_9602530c31.jpg)](http://www.flickr.com/photos/maco_nix/9337878942/) -After taking that photo, I put some egg shells (since I hardboiled some eggs today for pickling) in the dirt around them and added stakes. +After taking that photo, I put some egg shells (since I hardboiled some eggs +today for pickling) in the dirt around them and added stakes. -I noticed a couple of days ago on the way to work that there's a place near home called Country Boy Market. Fresh locally grown produce (cheap berries, nom nom), mulch, top soil, compost, and straw bales are all available. Also they deliver mulch & soil. Well then. I know what's happening next spring when I try to build up the rest of the garden. +I noticed a couple of days ago on the way to work that there's a place near +home called Country Boy Market. Fresh locally grown produce (cheap berries, nom nom), +mulch, top soil, compost, and straw bales are all available. Also they deliver mulch +& soil. Well then. I know what's happening next spring when I try to build up the +rest of the garden. [apple](crop) " end @@ -130,7 +150,10 @@ I noticed a couple of days ago on the way to work that there's a place near home # a garden garden = FactoryBot.create :garden, name: 'paradise', owner: member # with some lettuce (finished) - FactoryBot.create :planting, crop: FactoryBot.create(:crop, name: 'lettuce'), garden: garden, owner: member, finished_at: 2.weeks.ago + FactoryBot.create( + :planting, crop: FactoryBot.create(:crop, name: 'lettuce'), + garden: garden, owner: member, finished_at: 2.weeks.ago + ) # tomato still growing tomato_planting = FactoryBot.create :planting, garden: garden, owner: member, crop: tomato tomato_photo.plantings << tomato_planting From c4534c28deeae9babc5e4b8d811a81e80edf5595 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 24 Jun 2019 19:59:17 +1200 Subject: [PATCH 411/549] Update planting finished from quick menus --- spec/features/gardens/gardens_spec.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/spec/features/gardens/gardens_spec.rb b/spec/features/gardens/gardens_spec.rb index 3ca3a26c3..b76d8e4fb 100644 --- a/spec/features/gardens/gardens_spec.rb +++ b/spec/features/gardens/gardens_spec.rb @@ -105,14 +105,13 @@ describe "Planting a crop", js: true do end describe "Making a planting inactive from garden show" do - let(:path) { garden_path garden } - let(:link_text) { "Mark as finished" } - before do - within '.planting-quick-actions' do - click_link(aclass: 'planting-menu') - end + it do + visit garden_path(garden) + click_link(class: 'planting-menu') + click_link "Mark as finished" + find(".datepicker-days td.day", text: "21").click + expect(page).to have_content 'Finished' end - it_behaves_like "append date" end it "List only active plantings on a garden" do From 4443ce9d8b237d7f27e7d72591d590ba7795ee58 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 24 Jun 2019 20:08:02 +1200 Subject: [PATCH 412/549] Update spec to find first garden actions link --- spec/features/gardens/gardens_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/gardens/gardens_spec.rb b/spec/features/gardens/gardens_spec.rb index b76d8e4fb..f39c210f6 100644 --- a/spec/features/gardens/gardens_spec.rb +++ b/spec/features/gardens/gardens_spec.rb @@ -71,7 +71,7 @@ describe "Planting a crop", js: true do end it "button on index to edit garden" do - click_link 'Actions' + first('a#garden-actions-button').click click_link href: edit_garden_path(garden) expect(page).to have_content 'Edit garden' end From 47c5e3669203c7ceedb200631ee33c14090d546f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 24 Jun 2019 21:30:06 +1200 Subject: [PATCH 413/549] Updating forum specs --- spec/features/admin/forums_spec.rb | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/spec/features/admin/forums_spec.rb b/spec/features/admin/forums_spec.rb index 75acbbbd3..d13cc13fb 100644 --- a/spec/features/admin/forums_spec.rb +++ b/spec/features/admin/forums_spec.rb @@ -9,27 +9,13 @@ describe "forums", js: true do login_as member end - it "navigating to forum admin without js", js: false do - visit root_path - click_link "Admin" - expect(current_path).to eq admin_path - within 'ul#site_admin' do - click_link "Forums" - end - expect(current_path).to eq forums_path - expect(page).to have_content "New forum" - end - it "navigating to forum admin with js" do - visit root_path - click_link member.login_name - click_link "Admin" - expect(current_path).to eq admin_path + visit admin_path within 'ul#site_admin' do click_link "Forums" end expect(current_path).to eq forums_path - expect(page).to have_content "New forum" + expect(page).to have_link "New forum" end it "adding a forum" do @@ -56,7 +42,9 @@ describe "forums", js: true do it 'deleting forum' do visit forum_path forum - click_link 'Delete' + accept_confirm do + click_link 'Delete' + end expect(current_path).to eq forums_path expect(page).to have_content 'Forum was successfully deleted' end From 723c312412097a991fbb7a4746195cca51dad9a5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 24 Jun 2019 21:35:01 +1200 Subject: [PATCH 414/549] Updating forum pages to match specs --- app/views/forums/_form.html.haml | 2 +- app/views/forums/show.html.haml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/forums/_form.html.haml b/app/views/forums/_form.html.haml index d7685b724..ba4382749 100644 --- a/app/views/forums/_form.html.haml +++ b/app/views/forums/_form.html.haml @@ -18,4 +18,4 @@ = f.text_area :description, rows: 6 = f.select(:owner_id, Member.all.order(:login_name).pluck(:login_name, :id)) .card-footer - .text-right= f.submit 'save' + .text-right= f.submit 'Save' diff --git a/app/views/forums/show.html.haml b/app/views/forums/show.html.haml index 69ae5b59a..898ca3240 100644 --- a/app/views/forums/show.html.haml +++ b/app/views/forums/show.html.haml @@ -7,6 +7,8 @@ = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) +%h1= @forum.name + %p#notice= notice %p.forum-meta From 1747f810e30d343b2bb8de94b9c299ce56a2ee67 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 08:54:40 +1200 Subject: [PATCH 415/549] Match to existing specs --- app/views/devise/unlocks/new.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/devise/unlocks/new.html.haml b/app/views/devise/unlocks/new.html.haml index b8efdf0ac..5d1023a6a 100644 --- a/app/views/devise/unlocks/new.html.haml +++ b/app/views/devise/unlocks/new.html.haml @@ -9,7 +9,7 @@ %h2 Resend unlock instructions = devise_error_messages! - = f.email_field :email, class: 'form-control', placeholder: 'email' + = f.email_field :email, class: 'form-control', placeholder: 'Email' = f.submit "Resend unlock instructions", class: 'btn btn-block my-4 btn-primary' = render "devise/shared/links" From 5dc4c4fcde3eb4874ca39381445f8a50a803b0f6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 08:54:53 +1200 Subject: [PATCH 416/549] update from should rspec syntax --- spec/views/devise/unlocks/new_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/views/devise/unlocks/new_spec.rb b/spec/views/devise/unlocks/new_spec.rb index ba1e11215..c9b5d401d 100644 --- a/spec/views/devise/unlocks/new_spec.rb +++ b/spec/views/devise/unlocks/new_spec.rb @@ -11,7 +11,7 @@ describe 'devise/unlocks/new.html.haml', type: "view" do end it 'has some fields' do - rendered.should have_content 'Email' + expect(rendered).to have_content 'Email' end end end From 191a3940d71c35ef13b5fdffb7a6bfa2cdc2359e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 08:57:37 +1200 Subject: [PATCH 417/549] update unlock spec --- spec/views/devise/unlocks/new_spec.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/views/devise/unlocks/new_spec.rb b/spec/views/devise/unlocks/new_spec.rb index c9b5d401d..68666532f 100644 --- a/spec/views/devise/unlocks/new_spec.rb +++ b/spec/views/devise/unlocks/new_spec.rb @@ -10,8 +10,7 @@ describe 'devise/unlocks/new.html.haml', type: "view" do render end - it 'has some fields' do - expect(rendered).to have_content 'Email' - end + it { expect(rendered).to have_field 'Email' } + it { expect(rendered).to have_content 'Resend unlock instructions' } end end From 3e0f6c476f74cbffd8c8489183bbf0f0fb748465 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 09:01:37 +1200 Subject: [PATCH 418/549] set body on post in spec, so we know what to look for and we don't trip on whitespace changes --- spec/views/comments/new.html.haml_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/views/comments/new.html.haml_spec.rb b/spec/views/comments/new.html.haml_spec.rb index 5892fce0b..c2d7b7e86 100644 --- a/spec/views/comments/new.html.haml_spec.rb +++ b/spec/views/comments/new.html.haml_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe "comments/new" do before do controller.stub(:current_user) { nil } - @post = FactoryBot.create(:post) + @post = FactoryBot.create(:post, body: 'tena koutou ki te ao') @comment = FactoryBot.create(:comment, post: @post) assign(:comment, @comment) assign(:comments, [@comment]) From f7406de7dc2afc3ca915b1d7dfcdbcd96203e579 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2019 07:58:10 +0000 Subject: [PATCH 419/549] Bump scout_apm from 2.4.24 to 2.5.0 Bumps [scout_apm](https://github.com/scoutapp/scout_apm_ruby) from 2.4.24 to 2.5.0. - [Release notes](https://github.com/scoutapp/scout_apm_ruby/releases) - [Changelog](https://github.com/scoutapp/scout_apm_ruby/blob/master/CHANGELOG.markdown) - [Commits](https://github.com/scoutapp/scout_apm_ruby/compare/v2.4.24...v2.5.0) Signed-off-by: dependabot-preview[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 578f0b411..ce29b4a99 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -454,7 +454,7 @@ GEM sprockets (> 3.0) sprockets-rails tilt - scout_apm (2.4.24) + scout_apm (2.5.0) searchkick (4.0.2) activemodel (>= 5) elasticsearch (>= 6) From 64864bfcd5df07cc48c9d0bd72d166d21c12522e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 09:09:28 +1200 Subject: [PATCH 420/549] Remove phantom directory mention from travis config --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5918161a0..b7c5d3bf7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: ruby cache: bundler: true directories: - - travis_phantomjs - tmp/cache/assets/test/sprockets addons: apt: From 5de269c097529fd490d22c23773810be174f0d6a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 10:12:12 +1200 Subject: [PATCH 421/549] Move header into partial, to match what specs expect --- .travis.yml | 1 + Gemfile | 1 - Gemfile.lock | 13 ++++++------- app/views/home/_seeds.html.haml | 1 + app/views/home/index.html.haml | 1 - 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index b7c5d3bf7..5918161a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: ruby cache: bundler: true directories: + - travis_phantomjs - tmp/cache/assets/test/sprockets addons: apt: diff --git a/Gemfile b/Gemfile index 7449bd499..331630639 100644 --- a/Gemfile +++ b/Gemfile @@ -95,7 +95,6 @@ gem 'omniauth-twitter' gem "chartkick" # clever elastic search -gem 'elasticsearch', '< 7.0.0' gem 'searchkick' gem "hashie", ">= 3.5.3" diff --git a/Gemfile.lock b/Gemfile.lock index fc2738609..3ba20aff0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -147,17 +147,17 @@ GEM warden (~> 1.2.3) diff-lcs (1.3) docile (1.1.5) - elasticsearch (6.8.0) - elasticsearch-api (= 6.8.0) - elasticsearch-transport (= 6.8.0) - elasticsearch-api (6.8.0) + elasticsearch (7.1.0) + elasticsearch-api (= 7.1.0) + elasticsearch-transport (= 7.1.0) + elasticsearch-api (7.1.0) multi_json elasticsearch-model (6.0.0) activesupport (> 3) elasticsearch (> 1) hashie elasticsearch-rails (6.0.0) - elasticsearch-transport (6.8.0) + elasticsearch-transport (7.1.0) faraday multi_json erubi (1.8.0) @@ -461,7 +461,7 @@ GEM sprockets (> 3.0) sprockets-rails tilt - scout_apm (2.5.0) + scout_apm (2.4.24) searchkick (4.0.2) activemodel (>= 5) elasticsearch (>= 6) @@ -558,7 +558,6 @@ DEPENDENCIES dalli database_cleaner devise - elasticsearch (< 7.0.0) factory_bot_rails faker figaro diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml index 98d1e5f6f..1f5b9ab4a 100644 --- a/app/views/home/_seeds.html.haml +++ b/app/views/home/_seeds.html.haml @@ -1,4 +1,5 @@ - cache cache_key_for(Seed) do + %h2.text-center= t('.seeds_available_to_trade') .homepage-cards - Seed.current.tradable.includes(:owner, :crop).order(created_at: :desc).limit(3).each do |seed| = render 'seeds/card', seed: seed diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 1910e83aa..8e9ec3a6f 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -29,7 +29,6 @@ %p.text-right= link_to "#{t('home.harvests.view_all')} »", harvests_path, class: 'btn btn-block' %section.seeds.mx-auto - %h2.text-center= t('.seeds_available_to_trade') = render 'seeds' .align-bottom %p.text-right= link_to "#{t('home.seeds.view_all')} »", seeds_path, class: 'btn btn-block' From d7e4863f0266e6104afb84825c85f5da8235cca7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 10:12:34 +1200 Subject: [PATCH 422/549] bundle install results --- Gemfile | 1 + Gemfile.lock | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 331630639..7449bd499 100644 --- a/Gemfile +++ b/Gemfile @@ -95,6 +95,7 @@ gem 'omniauth-twitter' gem "chartkick" # clever elastic search +gem 'elasticsearch', '< 7.0.0' gem 'searchkick' gem "hashie", ">= 3.5.3" diff --git a/Gemfile.lock b/Gemfile.lock index 3ba20aff0..fc2738609 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -147,17 +147,17 @@ GEM warden (~> 1.2.3) diff-lcs (1.3) docile (1.1.5) - elasticsearch (7.1.0) - elasticsearch-api (= 7.1.0) - elasticsearch-transport (= 7.1.0) - elasticsearch-api (7.1.0) + elasticsearch (6.8.0) + elasticsearch-api (= 6.8.0) + elasticsearch-transport (= 6.8.0) + elasticsearch-api (6.8.0) multi_json elasticsearch-model (6.0.0) activesupport (> 3) elasticsearch (> 1) hashie elasticsearch-rails (6.0.0) - elasticsearch-transport (7.1.0) + elasticsearch-transport (6.8.0) faraday multi_json erubi (1.8.0) @@ -461,7 +461,7 @@ GEM sprockets (> 3.0) sprockets-rails tilt - scout_apm (2.4.24) + scout_apm (2.5.0) searchkick (4.0.2) activemodel (>= 5) elasticsearch (>= 6) @@ -558,6 +558,7 @@ DEPENDENCIES dalli database_cleaner devise + elasticsearch (< 7.0.0) factory_bot_rails faker figaro From 8af856f99001643c616ec097d51bd48353de440a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 11:36:23 +1200 Subject: [PATCH 423/549] Updating specs --- spec/features/crops/alternate_name_spec.rb | 4 +--- spec/views/home/_seeds.html.haml_spec.rb | 16 ++++++---------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb index 497713cc8..cfb4bf3e3 100644 --- a/spec/features/crops/alternate_name_spec.rb +++ b/spec/features/crops/alternate_name_spec.rb @@ -42,12 +42,10 @@ describe "Alternate names", js: true do it "Crop wranglers can delete alternate names" do visit crop_path(alternate_eggplant.crop) - click_link 'aubergine' - expect(page).to have_link "Delete", href: alternate_name_path(alternate_eggplant) + click_link('aubergine', href: '#') accept_confirm do click_link 'Delete' end - expect(pending_alt_name.status_code).to equal 200 expect(page).not_to have_content alternate_eggplant.name expect(page).to have_content 'Alternate name was successfully deleted' end diff --git a/spec/views/home/_seeds.html.haml_spec.rb b/spec/views/home/_seeds.html.haml_spec.rb index baacfc37e..e0b2c54be 100644 --- a/spec/views/home/_seeds.html.haml_spec.rb +++ b/spec/views/home/_seeds.html.haml_spec.rb @@ -1,19 +1,15 @@ require 'rails_helper' describe 'home/_seeds.html.haml', type: "view" do - before do - @owner = FactoryBot.create(:london_member) - @seed = FactoryBot.create(:tradable_seed, owner: @owner) - render - end + let!(:seed) { FactoryBot.create(:tradable_seed, owner: owner) } + let(:owner) { FactoryBot.create(:london_member) } + before { render } it 'has a heading' do assert_select 'h2', 'Seeds available to trade' end - it 'lists seeds' do - rendered.should have_content @seed.tradable_to - rendered.should have_content @seed.owner.location - assert_select 'a', href: seed_path(@seed) - end + it { expect(rendered).to have_content seed.tradable_to } + it { expect(rendered).to have_content seed.owner.location } + it { expect(rendered).to have_link(href: seed_path(seed)) } end From 4fc7e0d0b2d0626f934895194a3ea74f0b3e3bd6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 13:28:08 +1200 Subject: [PATCH 424/549] fix up home spec --- spec/features/home/home_spec.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/features/home/home_spec.rb b/spec/features/home/home_spec.rb index 6ef612af0..89dbacdc5 100644 --- a/spec/features/home/home_spec.rb +++ b/spec/features/home/home_spec.rb @@ -36,19 +36,19 @@ describe "home page" do expect(subject).not_to have_link href: seed_path(untradable_seed) end - it { is_expected.to have_text 'View all seeds' } + it { is_expected.to have_link 'View all seeds »' } end shared_examples 'show plantings' do - it 'shows plantings section' do - expect(subject).to have_text 'Recently Planted' - expect(subject).to have_link href: planting_path(planting) + describe 'shows plantings section' do + it { expect(subject).to have_text 'Recently Planted' } + it { expect(subject).to have_link href: planting_path(planting) } end end shared_examples 'show harvests' do - it 'shows harvests section' do - expect(subject).to have_text 'Recently Harvested' - expect(subject).to have_link href: harvest_path(harvest) + describe 'shows harvests section' do + it { expect(subject).to have_text 'Recently Harvested' } + it { expect(subject).to have_link href: harvest_path(harvest) } end end From 5150e8e2a74d3608b01254a28d8ee2642035fb48 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 13:43:30 +1200 Subject: [PATCH 425/549] Plant part is a radio button now. updating spec --- spec/views/harvests/edit.html.haml_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/views/harvests/edit.html.haml_spec.rb b/spec/views/harvests/edit.html.haml_spec.rb index 90df77ebe..33b1bfdea 100644 --- a/spec/views/harvests/edit.html.haml_spec.rb +++ b/spec/views/harvests/edit.html.haml_spec.rb @@ -10,7 +10,7 @@ describe "harvests/edit" do assert_select "form", action: harvests_path, method: "post" do assert_select "input#crop", class: "ui-autocomplete-input" assert_select "input#harvest_crop_id", name: "harvest[crop_id]" - assert_select "select#harvest_plant_part_id", name: "harvest[plant_part_id]" + assert_select "input#harvest_plant_part_id_1", name: "harvest[plant_part_id]" assert_select "input#harvest_quantity", name: "harvest[quantity]" assert_select "input#harvest_weight_quantity", name: "harvest[quantity]" assert_select "select#harvest_unit", name: "harvest[unit]" From aab2f75caada36166aafb6e5f526ec95873a09da Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 15:15:16 +1200 Subject: [PATCH 426/549] use console.log instead of alert so our headless chrome doesn't get stuck on the alert --- spec/views/layouts/application_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/views/layouts/application_spec.rb b/spec/views/layouts/application_spec.rb index 49d6d70f4..f2b23d910 100644 --- a/spec/views/layouts/application_spec.rb +++ b/spec/views/layouts/application_spec.rb @@ -6,9 +6,9 @@ describe 'layouts/application.html.haml', type: "view" do end it 'includes the analytics code' do - Rails.application.config.analytics_code = '' + Rails.application.config.analytics_code = '' render - assert_select "script", text: 'alert("foo!")' + assert_select "script", text: 'console.log("foo!");' rendered.should_not have_content 'script' end end From e2a764e8bc6f1bc568573d24e43af8e4d5d98e84 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 15:18:31 +1200 Subject: [PATCH 427/549] call search:reindex on ci runs --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5918161a0..eedc6e9a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: ruby cache: bundler: true directories: - - travis_phantomjs - tmp/cache/assets/test/sprockets addons: apt: @@ -39,7 +38,7 @@ script: ./script/check_static.rb else set +e; - RAILS_ENV=test bundle exec rake db:create db:migrate search:create; + RAILS_ENV=test bundle exec rake db:create db:migrate search:reindex; bundle exec rake assets:precompile; bundle exec rspec --tag $RSPEC_TAG spec/; fi; @@ -65,8 +64,6 @@ deploy: app: dev: growstuff-staging master: growstuff-prod - travis_deploy: tranquil-basin-3130 - travis_containers: tranquil-basin-3130 run: - "rake db:migrate" - "script/deploy-tasks.sh" From dce1ab6239eaf23e521db505fe9ed99c7ae46b40 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 15:24:53 +1200 Subject: [PATCH 428/549] Format the output from rspec --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index eedc6e9a6..aa8eceb7a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,7 +40,7 @@ script: set +e; RAILS_ENV=test bundle exec rake db:create db:migrate search:reindex; bundle exec rake assets:precompile; - bundle exec rspec --tag $RSPEC_TAG spec/; + bundle exec rspec -fd --tag $RSPEC_TAG spec/; fi; - set +e after_script: From 3dab7b89f9c56aa945bac0b5d4a1fb5bb8e104e9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 15:36:08 +1200 Subject: [PATCH 429/549] update planting specs --- .travis.yml | 7 +++++-- spec/controllers/plantings_controller_spec.rb | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index aa8eceb7a..5918161a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: ruby cache: bundler: true directories: + - travis_phantomjs - tmp/cache/assets/test/sprockets addons: apt: @@ -38,9 +39,9 @@ script: ./script/check_static.rb else set +e; - RAILS_ENV=test bundle exec rake db:create db:migrate search:reindex; + RAILS_ENV=test bundle exec rake db:create db:migrate search:create; bundle exec rake assets:precompile; - bundle exec rspec -fd --tag $RSPEC_TAG spec/; + bundle exec rspec --tag $RSPEC_TAG spec/; fi; - set +e after_script: @@ -64,6 +65,8 @@ deploy: app: dev: growstuff-staging master: growstuff-prod + travis_deploy: tranquil-basin-3130 + travis_containers: tranquil-basin-3130 run: - "rake db:migrate" - "script/deploy-tasks.sh" diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index 5438b109b..4562be128 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -59,7 +59,7 @@ describe PlantingsController do before { get :new, params: { garden_id: garden.id } } - it { expect(assigns(:garden)).to eq(garden) } + it { expect(assigns(:planting).garden).to eq(garden) } end describe "Doesn't display another member's garden on planting form" do @@ -68,7 +68,7 @@ describe PlantingsController do before { get :new, params: { garden_id: garden.id } } - it { expect(assigns(:garden)).not_to eq(garden) } + it { expect(assigns(:planting).garden).not_to eq(garden) } end describe "Doesn't display un-approved crops on planting form" do @@ -92,7 +92,7 @@ describe PlantingsController do describe "doesn't die if no garden specified" do before { get :new, params: {} } - it { expect(assigns(:garden)).to be_a_new(Garden) } + it { expect(assigns(:planting)).to be_a_new(Planting) } end describe "sets the date of the planting to today" do From 3d065c72ba1a82a0420c8952e98c11d611560485 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 15:54:50 +1200 Subject: [PATCH 430/549] update new planting view spec --- spec/views/plantings/new.html.haml_spec.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/spec/views/plantings/new.html.haml_spec.rb b/spec/views/plantings/new.html.haml_spec.rb index 418860c86..53b356e08 100644 --- a/spec/views/plantings/new.html.haml_spec.rb +++ b/spec/views/plantings/new.html.haml_spec.rb @@ -20,15 +20,16 @@ describe "plantings/new" do context "logged in" do before do sign_in @member - assign(:planting, Planting.new) + planting = Planting.new(garden: @garden_z) + assign(:planting, planting) assign(:crop, @crop2) - assign(:garden, @garden_z) + assign(:gardens, [@garden_z]) render end it "renders new planting form" do assert_select "form", action: plantings_path, method: "post" do - assert_select "select#planting_garden_id", name: "planting[garden_id]" + assert_select "input#planting_garden_id_#{@garden_z.id}", name: "planting[garden_id]" assert_select "input#crop", class: "ui-autocomplete-input" assert_select "input#planting_crop_id", name: "planting[crop_id]" assert_select "input#planting_quantity", name: "planting[quantity]" @@ -43,8 +44,8 @@ describe "plantings/new" do end it "selects a garden given in a param" do - assert_select "select#planting_garden_id", - html: /option selected value="#{@garden_z.id}"/ + assert_select "input", id: "planting_garden_id_#{@garden_z.id}", + type: 'radio', value: @garden_z.id, checked: "checked" end end end From b1b6de0aae567df2e893957dea5bc4310a05165a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 15:55:06 +1200 Subject: [PATCH 431/549] set @gardens for plantings controller and spec --- app/controllers/plantings_controller.rb | 4 ++-- app/views/plantings/_form.html.haml | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index a5570062f..39f159e55 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -47,7 +47,7 @@ class PlantingsController < ApplicationController garden: current_member.gardens.first ) @seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id] - + @gardens = @planting.owner.gardens.active.order_by_name @crop = Crop.approved.find_by(id: params[:crop_id]) || Crop.new if params[:garden_id] @planting.garden = Garden.find_by( @@ -62,7 +62,7 @@ class PlantingsController < ApplicationController def edit # the following are needed to display the form but aren't used @crop = Crop.new - @garden = Garden.new + @gardens = @planting.owner.gardens.active.order_by_name end def create diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml index 220a9599f..aac5e5d52 100644 --- a/app/views/plantings/_form.html.haml +++ b/app/views/plantings/_form.html.haml @@ -28,10 +28,8 @@ .row .col-md-8 - = f.collection_radio_buttons(:garden_id, - @planting.owner.gardens.active.order_by_name, - :id, :name, - required: true, + = f.collection_radio_buttons(:garden_id, @gardens, + :id, :name, required: true, label: 'Where did you plant it?') = link_to "Add a garden.", new_garden_path .col-md-4 From 1dd9a1028e378ae1f09bdfca15f02efee1a8d636 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 16:17:43 +1200 Subject: [PATCH 432/549] Updating the way we look for the plantparts radio buttons in specs --- spec/views/harvests/edit.html.haml_spec.rb | 3 ++- spec/views/harvests/new.html.haml_spec.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/views/harvests/edit.html.haml_spec.rb b/spec/views/harvests/edit.html.haml_spec.rb index 33b1bfdea..2d7398289 100644 --- a/spec/views/harvests/edit.html.haml_spec.rb +++ b/spec/views/harvests/edit.html.haml_spec.rb @@ -10,7 +10,8 @@ describe "harvests/edit" do assert_select "form", action: harvests_path, method: "post" do assert_select "input#crop", class: "ui-autocomplete-input" assert_select "input#harvest_crop_id", name: "harvest[crop_id]" - assert_select "input#harvest_plant_part_id_1", name: "harvest[plant_part_id]" + assert_select 'input', id: "harvest_plant_part_id_#{PlantPart.first.id}", + name: "harvest[plant_part_id]" assert_select "input#harvest_quantity", name: "harvest[quantity]" assert_select "input#harvest_weight_quantity", name: "harvest[quantity]" assert_select "select#harvest_unit", name: "harvest[unit]" diff --git a/spec/views/harvests/new.html.haml_spec.rb b/spec/views/harvests/new.html.haml_spec.rb index ee8e80a74..8d9ab0b88 100644 --- a/spec/views/harvests/new.html.haml_spec.rb +++ b/spec/views/harvests/new.html.haml_spec.rb @@ -10,7 +10,8 @@ describe "harvests/new" do assert_select "form", action: harvests_path, method: "post" do assert_select "input#crop", class: "ui-autocomplete-input" assert_select "input#harvest_crop_id", name: "harvest[crop_id]" - assert_select "select#harvest_plant_part_id", name: "harvest[plant_part_id]" + assert_select 'input', id: "harvest_plant_part_id_#{PlantPart.first.id}", + name: "harvest[plant_part_id]" # some browsers interpret without a step as "integer" assert_select "input#harvest_quantity[step=any]", name: "harvest[quantity]" assert_select "input#harvest_weight_quantity[step=any]", name: "harvest[quantity]" From 4f04d843a3889c74f486401e0e8f2b3cdaaeaf63 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 16:18:15 +1200 Subject: [PATCH 433/549] Move the subquerys in members#show to private --- app/controllers/members_controller.rb | 134 +++++++++++++------------- 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 4c65a65ca..4c8414894 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -12,73 +12,6 @@ class MembersController < ApplicationController end end - # Queries for the show view/action - def plantings_for_show - Planting.select( - :id, - "'planting' as event_type", - 'planted_at as event_at', - :owner_id, - :crop_id, - :slug - ) - end - - def harvests_for_show - Harvest.select( - :id, - "'harvest' as event_type", - 'harvested_at as event_at', - :owner_id, - :crop_id, - :slug - ) - end - - def posts_for_show - Post.select( - :id, - "'post' as event_type", - 'posts.created_at as event_at', - 'author_id as owner_id', - 'null as crop_id', - :slug - ) - end - - def comments_for_show - Comment.select( - :id, - "'comment' as event_type", - 'comments.created_at as event_at', - 'author_id as owner_id', - 'null as crop_id', - 'null as slug' - ) - end - - def photos_for_show - Photo.select( - :id, - "'photo' as event_type", - "photos.created_at as event_at", - 'photos.owner_id', - 'null as crop_id', - 'null as slug' - ) - end - - def seeds_for_show - Seed.select( - :id, - "'seed' as event_type", - "seeds.created_at as event_at", - 'seeds.owner_id', - 'crop_id', - 'slug' - ) - end - def show @member = Member.confirmed.find_by!(slug: params[:slug]) @twitter_auth = @member.auth('twitter') @@ -167,4 +100,71 @@ class MembersController < ApplicationController Member.order(:login_name) end.confirmed.paginate(page: params[:page]) end + + # Queries for the show view/action + def plantings_for_show + Planting.select( + :id, + "'planting' as event_type", + 'planted_at as event_at', + :owner_id, + :crop_id, + :slug + ) + end + + def harvests_for_show + Harvest.select( + :id, + "'harvest' as event_type", + 'harvested_at as event_at', + :owner_id, + :crop_id, + :slug + ) + end + + def posts_for_show + Post.select( + :id, + "'post' as event_type", + 'posts.created_at as event_at', + 'author_id as owner_id', + 'null as crop_id', + :slug + ) + end + + def comments_for_show + Comment.select( + :id, + "'comment' as event_type", + 'comments.created_at as event_at', + 'author_id as owner_id', + 'null as crop_id', + 'null as slug' + ) + end + + def photos_for_show + Photo.select( + :id, + "'photo' as event_type", + "photos.created_at as event_at", + 'photos.owner_id', + 'null as crop_id', + 'null as slug' + ) + end + + def seeds_for_show + Seed.select( + :id, + "'seed' as event_type", + "seeds.created_at as event_at", + 'seeds.owner_id', + 'crop_id', + 'slug' + ) + end end From 72a0c07a9370f12b97789f06ea83c016d32bfb3c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 16:29:52 +1200 Subject: [PATCH 434/549] Added member location back to match specs --- app/views/members/_member.haml | 5 +++++ app/views/members/show.html.haml | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/views/members/_member.haml b/app/views/members/_member.haml index 30bfd197e..6b9f6e262 100644 --- a/app/views/members/_member.haml +++ b/app/views/members/_member.haml @@ -10,6 +10,11 @@ Joined = distance_of_time_in_words(member.created_at, Time.zone.now) ago. + - if member.location.present? + %span.badge.badge-success + = icon 'fas', 'map-marker' + = member.location + %p %ul.nav.nav-justified.small %li.nav-item.border-right diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 4fbf3ba37..999b90f22 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -22,8 +22,10 @@ %p - @member.roles.each do |role| %span.badge.badge-info= role.name.titleize - %p - = @member.location + - if @member.location.present? + %p.badge.badge-success + = icon 'fas', 'map-marker' + = @member.location %p %strong Member since = @member.created_at.to_s(:date) From 20e236fb4bc27e2a83d4704e22eb45119967a730 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 20:31:15 +1200 Subject: [PATCH 435/549] more spec updates --- spec/views/home/_members.html.haml_spec.rb | 10 +++++----- spec/views/plantings/_form.html.haml_spec.rb | 1 + spec/views/posts/index.html.haml_spec.rb | 3 +-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/views/home/_members.html.haml_spec.rb b/spec/views/home/_members.html.haml_spec.rb index 946622d56..14357ebae 100644 --- a/spec/views/home/_members.html.haml_spec.rb +++ b/spec/views/home/_members.html.haml_spec.rb @@ -11,12 +11,12 @@ describe 'home/_members.html.haml', type: "view" do end it 'Has a heading' do - rendered.should have_content "Some of our members" + expect(rendered).to have_content "Some of our members" end - it 'Shows members' do - rendered.should have_content @member.login_name - rendered.should have_content @member.location - rendered.should have_content @planting.crop_name + describe 'Shows members' do + it { expect(rendered).to have_content @member.login_name } + it { expect(rendered).to have_content @member.location } + it { expect(rendered).to have_content @planting.crop_name } end end diff --git a/spec/views/plantings/_form.html.haml_spec.rb b/spec/views/plantings/_form.html.haml_spec.rb index c4f6247b0..e6eb07563 100644 --- a/spec/views/plantings/_form.html.haml_spec.rb +++ b/spec/views/plantings/_form.html.haml_spec.rb @@ -14,6 +14,7 @@ describe "plantings/_form" do owner: @member, planted_at: Date.new(2013, 3, 1)) + @gardens = @member.gardens sign_in @member render end diff --git a/spec/views/posts/index.html.haml_spec.rb b/spec/views/posts/index.html.haml_spec.rb index 44508846d..ee3d2fb86 100644 --- a/spec/views/posts/index.html.haml_spec.rb +++ b/spec/views/posts/index.html.haml_spec.rb @@ -20,8 +20,7 @@ describe "posts/index" do it "renders a list of posts" do assert_select "div.post", count: 2 assert_select "h3", text: "A Post".to_s, count: 2 - assert_select "div.post-body", - text: "This is some text.".to_s, count: 2 + assert_select "div.post-body", text: "This is some text.".to_s, count: 2 end it "contains two gravatar icons" do From 4a093944857cdd8e16de9e2eadd35fb0cb23f8ae Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 20:33:18 +1200 Subject: [PATCH 436/549] Remove crop name test from homepage members list --- spec/views/home/_members.html.haml_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/views/home/_members.html.haml_spec.rb b/spec/views/home/_members.html.haml_spec.rb index 14357ebae..332af1d22 100644 --- a/spec/views/home/_members.html.haml_spec.rb +++ b/spec/views/home/_members.html.haml_spec.rb @@ -17,6 +17,5 @@ describe 'home/_members.html.haml', type: "view" do describe 'Shows members' do it { expect(rendered).to have_content @member.login_name } it { expect(rendered).to have_content @member.location } - it { expect(rendered).to have_content @planting.crop_name } end end From 58d08ceb5a5c307a977caf541c52d08b110c1196 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 20:35:40 +1200 Subject: [PATCH 437/549] fix look up of translation for homepage --- app/views/home/_seeds.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml index 1f5b9ab4a..2bcf0eadb 100644 --- a/app/views/home/_seeds.html.haml +++ b/app/views/home/_seeds.html.haml @@ -1,5 +1,5 @@ - cache cache_key_for(Seed) do - %h2.text-center= t('.seeds_available_to_trade') + %h2.text-center= t('home.seeds.title') .homepage-cards - Seed.current.tradable.includes(:owner, :crop).order(created_at: :desc).limit(3).each do |seed| = render 'seeds/card', seed: seed From 103d1ce2eb8248041cde369f4cfe501414fead84 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 20:39:50 +1200 Subject: [PATCH 438/549] rubocop lint --- app/controllers/plantings_controller.rb | 2 +- spec/views/harvests/edit.html.haml_spec.rb | 4 ++-- spec/views/harvests/new.html.haml_spec.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 39f159e55..71a9c6b57 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -61,7 +61,7 @@ class PlantingsController < ApplicationController def edit # the following are needed to display the form but aren't used - @crop = Crop.new + @crop = Crop.new @gardens = @planting.owner.gardens.active.order_by_name end diff --git a/spec/views/harvests/edit.html.haml_spec.rb b/spec/views/harvests/edit.html.haml_spec.rb index 2d7398289..7733e28f4 100644 --- a/spec/views/harvests/edit.html.haml_spec.rb +++ b/spec/views/harvests/edit.html.haml_spec.rb @@ -10,8 +10,8 @@ describe "harvests/edit" do assert_select "form", action: harvests_path, method: "post" do assert_select "input#crop", class: "ui-autocomplete-input" assert_select "input#harvest_crop_id", name: "harvest[crop_id]" - assert_select 'input', id: "harvest_plant_part_id_#{PlantPart.first.id}", - name: "harvest[plant_part_id]" + assert_select 'input', id: "harvest_plant_part_id_#{PlantPart.first.id}", + name: "harvest[plant_part_id]" assert_select "input#harvest_quantity", name: "harvest[quantity]" assert_select "input#harvest_weight_quantity", name: "harvest[quantity]" assert_select "select#harvest_unit", name: "harvest[unit]" diff --git a/spec/views/harvests/new.html.haml_spec.rb b/spec/views/harvests/new.html.haml_spec.rb index 8d9ab0b88..37ce3388a 100644 --- a/spec/views/harvests/new.html.haml_spec.rb +++ b/spec/views/harvests/new.html.haml_spec.rb @@ -10,8 +10,8 @@ describe "harvests/new" do assert_select "form", action: harvests_path, method: "post" do assert_select "input#crop", class: "ui-autocomplete-input" assert_select "input#harvest_crop_id", name: "harvest[crop_id]" - assert_select 'input', id: "harvest_plant_part_id_#{PlantPart.first.id}", - name: "harvest[plant_part_id]" + assert_select 'input', id: "harvest_plant_part_id_#{PlantPart.first.id}", + name: "harvest[plant_part_id]" # some browsers interpret without a step as "integer" assert_select "input#harvest_quantity[step=any]", name: "harvest[quantity]" assert_select "input#harvest_weight_quantity[step=any]", name: "harvest[quantity]" From 702a66dea993ee20382571ddfcf97b24f9f6f943 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 20:45:54 +1200 Subject: [PATCH 439/549] Update spec for editing gardens --- spec/views/plantings/edit.html.haml_spec.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/spec/views/plantings/edit.html.haml_spec.rb b/spec/views/plantings/edit.html.haml_spec.rb index 768434f16..7870d1ac0 100644 --- a/spec/views/plantings/edit.html.haml_spec.rb +++ b/spec/views/plantings/edit.html.haml_spec.rb @@ -14,6 +14,7 @@ describe "plantings/edit" do # and likewise for gardens @garden = FactoryBot.create(:garden_z, owner: @member) @garden2 = FactoryBot.create(:garden_a, owner: @member) + @gardens = @member.gardens @planting = assign(:planting, FactoryBot.create(:planting, garden: @garden, crop: @tomato, owner: @member)) @@ -35,17 +36,12 @@ describe "plantings/edit" do end end - it 'includes helpful links for crops and gardens' do - assert_select "a[href='#{new_garden_path}']", text: "Add a garden." - end - it "chooses the right crop" do assert_select "input#crop[value=?]", "tomato" end it "chooses the right garden" do - assert_select "select#planting_garden_id", - html: /option selected value="#{@garden.id}"/ + assert_select "input", id: "planting_garden_id_#{@garden.id}", checked: "checked" end end end From ec1824fd4f11dc6bc329d17b1179870143ea8e46 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 20:56:57 +1200 Subject: [PATCH 440/549] Remove comment specs, they're on another view now --- spec/views/posts/_single.html.haml_spec.rb | 61 ---------------------- 1 file changed, 61 deletions(-) diff --git a/spec/views/posts/_single.html.haml_spec.rb b/spec/views/posts/_single.html.haml_spec.rb index 524e1ae9c..90c15af78 100644 --- a/spec/views/posts/_single.html.haml_spec.rb +++ b/spec/views/posts/_single.html.haml_spec.rb @@ -49,67 +49,6 @@ describe "posts/_single" do @post = FactoryBot.create(:post, author: @member) render_post end - - it "contains an edit link" do - assert_select "a[href='#{edit_post_path(@post)}']", "Edit" - end - end - - context "when there are no comments" do - before do - render_post - end - - it "renders the number of comments" do - assert_select "a[href='#{post_path(@post)}\#comments']", "0 comments" - end - end - - context "when there is 1 comment" do - before do - @comment = FactoryBot.create(:comment, post: @post) - render_post - end - - it "renders the number of comments" do - assert_select "a[href='#{post_path(@post)}\#comments']", "1 comment" - end - end - - context "when there are 2 comments" do - before do - @comment = FactoryBot.create(:comment, post: @post) - @comment2 = FactoryBot.create(:comment, post: @post) - render_post - end - - it "renders the number of comments" do - assert_select "a[href='#{post_path(@post)}\#comments']", "2 comments" - end - end - - context "when comments should be hidden" do - before do - @member = FactoryBot.create(:member) - sign_in @member - controller.stub(:current_user) { @member } - @comment = FactoryBot.create(:comment, post: @post) - render partial: "single", locals: { - post: @post, hide_comments: true - } - end - - it "renders no value of comments" do - rendered.should_not have_content "1 comment" - end - - it "does not contain link to post" do - assert_select "a[href='#{post_path @post}']", false - end - - it "does not contain link to new comment" do - assert_select "a[href='#{new_comment_path(post_id: @post.id)}']", false - end end context "when post has been edited" do From 7f00a5063b32ad8f210d6ea23f9dfa11a8bfb933 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 21:06:32 +1200 Subject: [PATCH 441/549] view spec updates --- app/views/posts/_single.html.haml | 30 +++------------------ spec/views/members/show.rss.haml_spec.rb | 2 +- spec/views/plantings/show.html.haml_spec.rb | 2 +- 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/app/views/posts/_single.html.haml b/app/views/posts/_single.html.haml index e06a1a80e..0057e7367 100644 --- a/app/views/posts/_single.html.haml +++ b/app/views/posts/_single.html.haml @@ -12,6 +12,9 @@ - if @post.updated_at > @post.created_at and edited at = @post.updated_at + += link_to "Permalink", post + :growstuff_markdown #{ strip_tags @post.body } @@ -43,30 +46,3 @@ -# .post-body -# :growstuff_markdown -# #{ strip_tags post.body } - --# - unless defined?(hide_comments) --# .post-comments --# %ul.list-inline --# %li.first --# = link_to localize_plural(post.comments, Comment), --# post_path(post, anchor: 'comments') --# - if can? :create, Comment --# %li= link_to "Reply", new_comment_path(post_id: post.id) --# %li= link_to "Permalink", post --# - if can? :edit, post --# %li= link_to "Edit", edit_post_path(post) - --# .like-count --# = pluralize(post.likes.count, "like") unless post.likes.empty? --# - if member_signed_in? --# - if !post.members.include? current_member --# - if can?(:new, Like) --# = link_to 'Like', likes_path(post_id: post.id, format: :json), --# method: :post, remote: true, class: 'post-like' --# - else --# - like = post.likes.find_by(member: current_member) --# - if like && can?(:destroy, like) --# = link_to 'Unlike', like_path(id: like.id, format: :json), --# method: :delete, remote: true, class: 'post-like' - - diff --git a/spec/views/members/show.rss.haml_spec.rb b/spec/views/members/show.rss.haml_spec.rb index 8ad64ab95..ce4dc4c52 100644 --- a/spec/views/members/show.rss.haml_spec.rb +++ b/spec/views/members/show.rss.haml_spec.rb @@ -5,7 +5,7 @@ describe 'members/show.rss.haml', type: "view" do before do @member = assign(:member, FactoryBot.create(:member, login_name: 'callum')) - @post1 = FactoryBot.create(:post, id: 1, author: @member) + @post1 = FactoryBot.create(:post, id: 1, author: @member, body: "This is some text.") @post2 = FactoryBot.create(:markdown_post, id: 2, author: @member) assign(:posts, [@post1, @post2]) render diff --git a/spec/views/plantings/show.html.haml_spec.rb b/spec/views/plantings/show.html.haml_spec.rb index 97f58e940..efb3482ed 100644 --- a/spec/views/plantings/show.html.haml_spec.rb +++ b/spec/views/plantings/show.html.haml_spec.rb @@ -51,7 +51,7 @@ describe "plantings/show" do planting.photos << photo2 render assert_select "img[src='#{photo1.fullsize_url}']" - assert_select "img[src='#{photo2.thumbnail_url}']" + assert_select "img[src='#{photo2.fullsize_url}']" end describe "shows a link to add photos" do From 5f3a180f9cdfa84da88e1f82946e1b10a20363c6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 25 Jun 2019 21:12:09 +1200 Subject: [PATCH 442/549] restore on harvests#index --- app/views/harvests/index.html.haml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index 1b2fb4645..d2b4f06ce 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -1,3 +1,6 @@ +- content_for(:title) do + = title('harvests', @owner, @crop, @planting) + %h1 = harvest_icon = title('harvests', @owner, @crop, @planting) From ea4d48184b90af5921dbcfdfef2ccab3603ffc3f Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Tue, 25 Jun 2019 21:13:09 +1200 Subject: [PATCH 443/549] Delete trailing spaces --- app/views/harvests/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index d2b4f06ce..3434f4e92 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -1,6 +1,6 @@ - content_for(:title) do = title('harvests', @owner, @crop, @planting) - + %h1 = harvest_icon = title('harvests', @owner, @crop, @planting) From b77693c82f8e65aa22019634ad11a2437e53a957 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Tue, 25 Jun 2019 21:29:13 +1200 Subject: [PATCH 444/549] Imported partial bootstrap/variables.scss should be written as bootstrap/variables --- app/assets/stylesheets/application.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 6ed435d3c..d5a4e4879 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -2,7 +2,7 @@ @import 'variables'; @import 'material'; -@import 'bootstrap/variables.scss'; +@import 'bootstrap/variables'; @import 'jquery-ui/autocomplete'; @import 'bootstrap-datepicker'; From c6b76965581a3dd6ef08f9988deb256e23d38c63 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Tue, 25 Jun 2019 21:29:30 +1200 Subject: [PATCH 445/549] Files should end with a trailing newline --- app/assets/stylesheets/application.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index d5a4e4879..1c9cbbbda 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -25,4 +25,4 @@ @import 'material_icons'; @import 'rails_bootstrap_forms'; -@import 'overrides'; \ No newline at end of file +@import 'overrides'; From 56bae532959bb2a6074891e11549ceacc2fa1a64 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Tue, 25 Jun 2019 21:29:50 +1200 Subject: [PATCH 446/549] 0.1 should be written without a leading zero as .1 --- app/assets/stylesheets/crops.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/crops.scss b/app/assets/stylesheets/crops.scss index 73ce0f1de..26fb947e6 100644 --- a/app/assets/stylesheets/crops.scss +++ b/app/assets/stylesheets/crops.scss @@ -1,7 +1,7 @@ .planting { .crop-card { height: 100%; - margin: 0.1em; + margin: .1em; min-height: 300px; width: 100px; } From c6bb21cdfa4b1e22f6cfe357c960f44c5e2cca35 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Tue, 25 Jun 2019 21:30:25 +1200 Subject: [PATCH 447/549] 0.5 should be written without a leading zero as .5 --- app/assets/stylesheets/homepage.scss | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/homepage.scss b/app/assets/stylesheets/homepage.scss index d8e8c8fdb..01adc5728 100644 --- a/app/assets/stylesheets/homepage.scss +++ b/app/assets/stylesheets/homepage.scss @@ -12,12 +12,12 @@ display: flex; flex: none; flex-wrap: wrap; - margin: 0.5em; - // left: -0.5em; + margin: .5em; + // left: -.5em; .card { - left: -0.5em; - margin: 0.5em; + left: -.5em; + margin: .5em; min-height: 100px; padding: 0; @@ -31,7 +31,7 @@ } .thumbnail { - margin: 0.5em; + margin: .5em; } .img-card { height: 150px; From 92f0453d25bb66dd8e55d2a3b8228778f7c2afa4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Tue, 25 Jun 2019 21:30:55 +1200 Subject: [PATCH 448/549] Alpha ordered css --- app/assets/stylesheets/homepage.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/homepage.scss b/app/assets/stylesheets/homepage.scss index 01adc5728..7f4d853a3 100644 --- a/app/assets/stylesheets/homepage.scss +++ b/app/assets/stylesheets/homepage.scss @@ -26,8 +26,8 @@ } } .crop-card { - width: 120px; min-height: 80px; + width: 120px; } .thumbnail { From ee2d169c1d8f8b9633a6554907a4293359d0544b Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Tue, 25 Jun 2019 21:31:24 +1200 Subject: [PATCH 449/549] Unknown property align --- app/assets/stylesheets/homepage.scss | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/assets/stylesheets/homepage.scss b/app/assets/stylesheets/homepage.scss index 7f4d853a3..6b2ffda32 100644 --- a/app/assets/stylesheets/homepage.scss +++ b/app/assets/stylesheets/homepage.scss @@ -54,12 +54,10 @@ @include media-breakpoint-down(sm) { .homepage-cards { .seed-card { - align: center; min-height: 80px; width: 100%; } .member-card { - align: center; min-height: 80px; width: 150px; } From 30728d8146635eaaa3044525ae4073070fd84ff2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Tue, 25 Jun 2019 21:31:38 +1200 Subject: [PATCH 450/549] Rule declaration should be followed by an empty line --- app/assets/stylesheets/homepage.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/homepage.scss b/app/assets/stylesheets/homepage.scss index 6b2ffda32..25fe72ea7 100644 --- a/app/assets/stylesheets/homepage.scss +++ b/app/assets/stylesheets/homepage.scss @@ -57,6 +57,7 @@ min-height: 80px; width: 100%; } + .member-card { min-height: 80px; width: 150px; From 73f7e695b469715392f83c7902906fb4e7755725 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Tue, 25 Jun 2019 21:32:13 +1200 Subject: [PATCH 451/549] Ignore leaflet --- .codeclimate.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.codeclimate.yml b/.codeclimate.yml index 60b03e58c..c5dec1683 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -44,3 +44,4 @@ exclude_paths: - public/ - app/assets/stylesheets/bootstrap-accessibility.css - app/assets/javascripts/bootstrap* +- app/assets/stylesheets/leaflet_overrides.scss From a598214a60a5f290f263381bd0a1dc9c313a3e17 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Tue, 25 Jun 2019 21:34:52 +1200 Subject: [PATCH 452/549] renamed scss files --- app/assets/stylesheets/{crops.scss => _crops.scss} | 0 app/assets/stylesheets/{harvests.scss => _harvests.scss} | 0 app/assets/stylesheets/{homepage.scss => _homepage.scss} | 0 app/assets/stylesheets/{members.scss => _members.scss} | 6 +++--- app/assets/stylesheets/{photos.scss => _photos.scss} | 0 app/assets/stylesheets/{plantings.scss => _plantings.scss} | 0 .../stylesheets/{predictions.scss => _predictions.scss} | 0 app/assets/stylesheets/{seeds.scss => _seeds.scss} | 0 app/assets/stylesheets/{variables.scss => _variables.scss} | 0 9 files changed, 3 insertions(+), 3 deletions(-) rename app/assets/stylesheets/{crops.scss => _crops.scss} (100%) rename app/assets/stylesheets/{harvests.scss => _harvests.scss} (100%) rename app/assets/stylesheets/{homepage.scss => _homepage.scss} (100%) rename app/assets/stylesheets/{members.scss => _members.scss} (100%) rename app/assets/stylesheets/{photos.scss => _photos.scss} (100%) rename app/assets/stylesheets/{plantings.scss => _plantings.scss} (100%) rename app/assets/stylesheets/{predictions.scss => _predictions.scss} (100%) rename app/assets/stylesheets/{seeds.scss => _seeds.scss} (100%) rename app/assets/stylesheets/{variables.scss => _variables.scss} (100%) diff --git a/app/assets/stylesheets/crops.scss b/app/assets/stylesheets/_crops.scss similarity index 100% rename from app/assets/stylesheets/crops.scss rename to app/assets/stylesheets/_crops.scss diff --git a/app/assets/stylesheets/harvests.scss b/app/assets/stylesheets/_harvests.scss similarity index 100% rename from app/assets/stylesheets/harvests.scss rename to app/assets/stylesheets/_harvests.scss diff --git a/app/assets/stylesheets/homepage.scss b/app/assets/stylesheets/_homepage.scss similarity index 100% rename from app/assets/stylesheets/homepage.scss rename to app/assets/stylesheets/_homepage.scss diff --git a/app/assets/stylesheets/members.scss b/app/assets/stylesheets/_members.scss similarity index 100% rename from app/assets/stylesheets/members.scss rename to app/assets/stylesheets/_members.scss index 9cb92bee8..309c4f1d5 100644 --- a/app/assets/stylesheets/members.scss +++ b/app/assets/stylesheets/_members.scss @@ -1,13 +1,13 @@ .member-thumbnail { - padding: 0.25em; - margin: 1em; border-radius: 12px; height: 200px; + margin: 1em; + padding: 0.25em; div { - width: 5em; display: inline-block; vertical-align: top; + width: 5em; } } diff --git a/app/assets/stylesheets/photos.scss b/app/assets/stylesheets/_photos.scss similarity index 100% rename from app/assets/stylesheets/photos.scss rename to app/assets/stylesheets/_photos.scss diff --git a/app/assets/stylesheets/plantings.scss b/app/assets/stylesheets/_plantings.scss similarity index 100% rename from app/assets/stylesheets/plantings.scss rename to app/assets/stylesheets/_plantings.scss diff --git a/app/assets/stylesheets/predictions.scss b/app/assets/stylesheets/_predictions.scss similarity index 100% rename from app/assets/stylesheets/predictions.scss rename to app/assets/stylesheets/_predictions.scss diff --git a/app/assets/stylesheets/seeds.scss b/app/assets/stylesheets/_seeds.scss similarity index 100% rename from app/assets/stylesheets/seeds.scss rename to app/assets/stylesheets/_seeds.scss diff --git a/app/assets/stylesheets/variables.scss b/app/assets/stylesheets/_variables.scss similarity index 100% rename from app/assets/stylesheets/variables.scss rename to app/assets/stylesheets/_variables.scss From a69e4020d72cc70b987d407416a9316af1a79e82 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 08:09:49 +1200 Subject: [PATCH 453/549] back to reading gardens from the plantings --- app/controllers/plantings_controller.rb | 1 - app/views/plantings/_form.html.haml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 71a9c6b57..d6d3a164e 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -47,7 +47,6 @@ class PlantingsController < ApplicationController garden: current_member.gardens.first ) @seed = Seed.find_by(slug: params[:seed_id]) if params[:seed_id] - @gardens = @planting.owner.gardens.active.order_by_name @crop = Crop.approved.find_by(id: params[:crop_id]) || Crop.new if params[:garden_id] @planting.garden = Garden.find_by( diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml index aac5e5d52..6b0057a73 100644 --- a/app/views/plantings/_form.html.haml +++ b/app/views/plantings/_form.html.haml @@ -28,7 +28,7 @@ .row .col-md-8 - = f.collection_radio_buttons(:garden_id, @gardens, + = f.collection_radio_buttons(:garden_id, @planting.owner.gardens, :id, :name, required: true, label: 'Where did you plant it?') = link_to "Add a garden.", new_garden_path From 5b977964e88ac0daa97e26d0709d847ca3d09f8a Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:04:38 +1200 Subject: [PATCH 454/549] Fixing deprecation warning by devise --- app/views/devise/sessions/new.html.haml | 1 - app/views/devise/shared/_error_messages.html.haml | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 app/views/devise/shared/_error_messages.html.haml diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 00f47cbc5..e4d9c3688 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -5,7 +5,6 @@ = bootstrap_form_for(resource, as: resource_name, url: session_path(resource_name), html: { class: "text-center border border-light p-5" }) do |f| - = devise_error_messages! = f.text_field :login, label: 'Login', required: true = f.password_field :password, type: "password" - if devise_mapping.rememberable? diff --git a/app/views/devise/shared/_error_messages.html.haml b/app/views/devise/shared/_error_messages.html.haml new file mode 100644 index 000000000..a921fd612 --- /dev/null +++ b/app/views/devise/shared/_error_messages.html.haml @@ -0,0 +1,9 @@ +- if resource.errors.any? + #error_explanation + %h2 + = I18n.t("errors.messages.not_saved", | + count: resource.errors.count, | + resource: resource.class.model_name.human.downcase) | + %ul + - resource.errors.full_messages.each do |message| + %li= message From 474732f909ab4b69eda21a2aa09fc4e9f5d847ad Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:05:14 +1200 Subject: [PATCH 455/549] Fix sql warning in logs --- app/models/crop.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/crop.rb b/app/models/crop.rb index ebd23f150..4e56d4645 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -27,7 +27,7 @@ class Crop < ApplicationRecord ## Scopes scope :recent, -> { approved.order(created_at: :desc) } scope :toplevel, -> { approved.where(parent_id: nil) } - scope :popular, -> { approved.order("plantings_count desc, lower(name) asc") } + scope :popular, -> { approved.order(Arel.sql("plantings_count desc, lower(name) asc")) } scope :pending_approval, -> { where(approval_status: "pending") } scope :approved, -> { where(approval_status: "approved") } scope :rejected, -> { where(approval_status: "rejected") } From 73f2fd2323453b9dde09564a89542a0b02a1aec6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:07:03 +1200 Subject: [PATCH 456/549] fix another deprecation warning about rails 6 --- app/models/garden.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/garden.rb b/app/models/garden.rb index b45c5ed54..6c8318f42 100644 --- a/app/models/garden.rb +++ b/app/models/garden.rb @@ -19,7 +19,7 @@ class Garden < ApplicationRecord default_scope { joins(:owner) } # Ensures owner exists scope :active, -> { where(active: true) } scope :inactive, -> { where(active: false) } - scope :order_by_name, -> { order("lower(name) asc") } + scope :order_by_name, -> { order(Arel.sql("lower(name) asc")) } validates :location, length: { maximum: 255 } validates :slug, uniqueness: true From 06ae5ecd6fae8cf010809f2909258fe1a018dba6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:12:39 +1200 Subject: [PATCH 457/549] DRY buttons --- app/helpers/buttons_helper.rb | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 685cb2438..cbcab26a3 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -30,18 +30,22 @@ module ButtonsHelper end def crop_plant_button(crop) - return unless can? :create, Planting - - link_to new_planting_path(params: { crop_id: crop.id }), class: 'btn btn-sm' do - planting_icon + ' ' + t('buttons.plant') - end + create_button(Planting, + new_planting_path(params: { crop_id: crop.id }), + planting_icon, t('buttons.plant')) end def crop_save_seeds_button(crop) - return unless can?(:create, Seed) + create_button(Seed, + new_seed_path(params: { crop_id: crop.id }), + seed_icon, t('buttons.save_seeds')) + end - link_to new_seed_path(params: { crop_id: crop.id }), class: "btn btn-sm" do - seed_icon + ' ' + t('buttons.save_seeds') + def create_button(model_to_create, path, icon, label) + return unless can?(:create, model_to_create) + + link_to path, class: "btn btn-sm" do + icon + ' ' + label end end From 1df19ead927bff9b7bcafc7aaef46c714d07630d Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:12:57 +1200 Subject: [PATCH 458/549] removed phantom --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5918161a0..b7c5d3bf7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: ruby cache: bundler: true directories: - - travis_phantomjs - tmp/cache/assets/test/sprockets addons: apt: From e020db7eefd66563308c69c37d3b03e410221b6a Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:13:12 +1200 Subject: [PATCH 459/549] travici needs to call search:reindex --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b7c5d3bf7..26620876f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,9 +38,9 @@ script: ./script/check_static.rb else set +e; - RAILS_ENV=test bundle exec rake db:create db:migrate search:create; + RAILS_ENV=test bundle exec rake db:create db:migrate search:reindex; bundle exec rake assets:precompile; - bundle exec rspec --tag $RSPEC_TAG spec/; + bundle exec rspec -fd --tag $RSPEC_TAG spec/; fi; - set +e after_script: From d50ae708245066b1ed4b88cf5c910c53180547cd Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:14:01 +1200 Subject: [PATCH 460/549] in the spec, visit the path, not the full url --- spec/features/unsubscribing_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/unsubscribing_spec.rb b/spec/features/unsubscribing_spec.rb index 18af5296b..f53a45c4f 100644 --- a/spec/features/unsubscribing_spec.rb +++ b/spec/features/unsubscribing_spec.rb @@ -50,7 +50,7 @@ describe "unsubscribe" do expect(member.send_notification_email).to eq(true) # visit /members/unsubscribe/somestring ie.parameter to the URL is a random string - visit unsubscribe_member_url("type=send_planting_reminder&member_id=#{member.id}") + visit unsubscribe_member_path("type=send_planting_reminder&member_id=#{member.id}") expect(page).to have_content "We're sorry, there was an error" expect(member.send_planting_reminder).to eq(true) expect(member.send_notification_email).to eq(true) From 5e15912371b811fc99edb660f4557906b3562f19 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:23:22 +1200 Subject: [PATCH 461/549] Adding owner to planting in spec, so it passes --- spec/views/plantings/new.html.haml_spec.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/spec/views/plantings/new.html.haml_spec.rb b/spec/views/plantings/new.html.haml_spec.rb index 53b356e08..01f83680d 100644 --- a/spec/views/plantings/new.html.haml_spec.rb +++ b/spec/views/plantings/new.html.haml_spec.rb @@ -10,20 +10,18 @@ describe "plantings/new" do @garden_z = FactoryBot.create(:garden, owner: @member) @crop1 = FactoryBot.create(:tomato) @crop2 = FactoryBot.create(:maize) + @planting = FactoryBot.create(:planting, + garden: @garden_a, crop: @crop2, owner: @member) - assign(:planting, FactoryBot.create(:planting, - garden: @garden_a, - crop: @crop2, - owner: @member)) + assign(:planting, @planting) end context "logged in" do before do sign_in @member - planting = Planting.new(garden: @garden_z) + planting = Planting.new(garden: @garden_z, owner: @member) assign(:planting, planting) assign(:crop, @crop2) - assign(:gardens, [@garden_z]) render end From b21b95bbc2a28a6e1057be5de53621d9c9f81f04 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:31:19 +1200 Subject: [PATCH 462/549] scss lint fixes --- app/assets/stylesheets/_homepage.scss | 4 +- app/assets/stylesheets/overrides.scss | 56 +++++++++++++-------------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/app/assets/stylesheets/_homepage.scss b/app/assets/stylesheets/_homepage.scss index 25fe72ea7..17243ba8b 100644 --- a/app/assets/stylesheets/_homepage.scss +++ b/app/assets/stylesheets/_homepage.scss @@ -25,6 +25,7 @@ font-size: 2em; } } + .crop-card { min-height: 80px; width: 120px; @@ -33,6 +34,7 @@ .thumbnail { margin: .5em; } + .img-card { height: 150px; } @@ -45,8 +47,8 @@ flex-wrap: wrap; .card { - width: 150px; margin: 1em; + width: 150px; } } diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index d6c9d6c65..252f7fcf1 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -14,9 +14,9 @@ section { } .ellipsis { - overflow:hidden; - white-space: nowrap; - text-overflow: ellipsis; + overflow:hidden; + text-overflow: ellipsis; + white-space: nowrap; } a { @@ -24,13 +24,13 @@ a { } a:hover { - text-decoration: none; color: $brown; + text-decoration: none; } .card a:hover { - color: $blue; background-color: $beige; + color: $blue; } span.badge { @@ -74,7 +74,6 @@ h3 { } } .navbar .navbar-form { - // padding-top: 0; // padding-bottom: 0; // margin-right: 0; @@ -90,8 +89,8 @@ h3 { flex-wrap: wrap; .card { - width: 200px; margin: 1em; + width: 200px; } } @@ -100,14 +99,14 @@ img.img-icon { } .img-square { - object-fit: cover; height: 150px; + object-fit: cover; width: 150px; } .img-card { - object-fit: cover; height: 180px; + object-fit: cover; width: 100%; } @@ -117,9 +116,9 @@ img.img-icon { .avatar { border-radius: 50%; - z-index: 2; - position: relative; padding: 1em; + position: relative; + z-index: 2; } .profile-sidebar { @@ -144,8 +143,8 @@ img.img-icon { } .three-across:nth-child(3n+1) { - margin-left: 0; clear: both; + margin-left: 0; } // let's condense the hero unit a little @@ -166,8 +165,8 @@ img.img-icon { // signup widget on homepage .jumbotron .signup { background-color: lighten($green, 40%); - border: 1px solid lighten($green, 20%); border-radius: 6px; + border: 1px solid lighten($green, 20%); line-height: 200%; padding: 15px; text-align: center; @@ -180,9 +179,9 @@ p.stats { .card-row { display: grid; - grid-template-columns: 50% 50%; grid-gap: 25px; grid-row-gap: 5px; + grid-template-columns: 50% 50%; } .card { margin-bottom: 1em @@ -208,11 +207,11 @@ p.stats { } .location-not-set { + background-image: image-url("location-not-set.en.png"); + background-position: center; + background-repeat: no-repeat; height: 250px; width: 100%; - background-image: image-url("location-not-set.en.png"); - background-repeat: no-repeat; - background-position: center; } .member-location { @@ -249,15 +248,15 @@ li.crop-hierarchy { // footer footer { #footer1, #footer2, #footer3 { - text-align: left; - padding-top: 1em; padding-bottom: 2em; + padding-top: 1em; + text-align: left; ul { - list-style-type: none; list-style-position: outside; - padding-left: 0; + list-style-type: none; margin-left: 0; + padding-left: 0; } a { @@ -391,14 +390,11 @@ ul.thumbnail-buttons { } dd { - padding-left: 120px; margin-left: auto; + padding-left: 120px; } } } - - //.navbar .navbar-form - // width: 250px } @@ -406,11 +402,13 @@ ul.thumbnail-buttons { text-align: center; .form-card { - max-width: 500px; - text-align: center; display: inline-block; + margin-top: 0.5em; + max-width: 800px; padding: 1em; + text-align: center; } + .crop-card { width: 100px; } @@ -422,6 +420,7 @@ ul.thumbnail-buttons { #maincontainer { width: 100%; } + .sidebar { margin-left: 0; border-left: none; @@ -437,7 +436,6 @@ ul.thumbnail-buttons { } .navbar .navbar-form { - // width: 185px; padding-left: 0; padding-right: 0; @@ -449,11 +447,13 @@ ul.thumbnail-buttons { #maincontainer { padding: 10px; } + .homepage-cards { .crop-card { width: 50px; } } + .index-cards { .card { width: 100%; From b2c6a85aa9f26581caf06da0edfcdb0177b6b591 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:35:21 +1200 Subject: [PATCH 463/549] use variable for colour --- app/assets/stylesheets/_photos.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/_photos.scss b/app/assets/stylesheets/_photos.scss index 074548cf5..f2cfe071e 100644 --- a/app/assets/stylesheets/_photos.scss +++ b/app/assets/stylesheets/_photos.scss @@ -1,5 +1,5 @@ .photo-grid { - background: #DDD; + background: $beige; } .photo-grid-item { From 5efdf80bc2f7ba7df2d8013e0f9216c807609176 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:35:35 +1200 Subject: [PATCH 464/549] lint --- app/assets/stylesheets/_members.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/_members.scss b/app/assets/stylesheets/_members.scss index 309c4f1d5..aef8571ed 100644 --- a/app/assets/stylesheets/_members.scss +++ b/app/assets/stylesheets/_members.scss @@ -2,7 +2,7 @@ border-radius: 12px; height: 200px; margin: 1em; - padding: 0.25em; + padding: .25em; div { display: inline-block; From 3f59fe6bc7ce0a67a228ff8fe1b3089e2de8befc Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:35:50 +1200 Subject: [PATCH 465/549] style login buttons as buttons --- app/views/devise/shared/_links.haml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/devise/shared/_links.haml b/app/views/devise/shared/_links.haml index b36c31bf3..497d207de 100644 --- a/app/views/devise/shared/_links.haml +++ b/app/views/devise/shared/_links.haml @@ -2,7 +2,7 @@ -# = link_to "Forgot password?", new_password_path(resource_name) -# %br - +%hr/ - if devise_mapping.confirmable? && controller_name != 'confirmations' %p %small= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) @@ -14,10 +14,10 @@ - if devise_mapping.omniauthable? - resource_class.omniauth_providers.each do |provider| %p - = link_to omniauth_authorize_path(resource_name, provider) do + = link_to omniauth_authorize_path(resource_name, provider), class: 'btn' do = icon 'fab', provider Sign in with #{provider.to_s.titleize} %p Not a member? - =link_to 'Register', new_member_registration_path \ No newline at end of file + %strong= link_to 'Register', new_member_registration_path \ No newline at end of file From a729a61f4022f917d36220c65b683e70a5e6bd3c Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:37:54 +1200 Subject: [PATCH 466/549] remove comments out styles --- app/assets/stylesheets/overrides.scss | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index 252f7fcf1..8e32ed277 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -1,11 +1,6 @@ -//@import "bootstrap-sprockets" -//@import "bootstrap" -// this padding needs to be done before the responsive stuff is imported body { background-color: $beige; font-family: $font-family-sans-serif; - - // padding-top: $navbar-height } section { From cc219a8aa26865751eec4110c1b7e9c5a4ba604d Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:39:01 +1200 Subject: [PATCH 467/549] remove commented out code --- app/assets/stylesheets/_photos.scss | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/app/assets/stylesheets/_photos.scss b/app/assets/stylesheets/_photos.scss index f2cfe071e..aa455378f 100644 --- a/app/assets/stylesheets/_photos.scss +++ b/app/assets/stylesheets/_photos.scss @@ -3,25 +3,15 @@ } .photo-grid-item { - //background: #e6e5e4 - //border: 2px solid #b6b5b4 - //height: 100px } -/* clear fix */ +// clear fix .photo-grid:after { content: ""; display: block; clear: both; } -/* ---- .photo-grid-item ---- */ - -.photo-grid-sizer, -.photo-grid-item { - //width: 33.333% -} - .photo-grid-item { float: left; } From db55432d31b7b8417e6a323a9eff0f717ace4d7e Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:39:50 +1200 Subject: [PATCH 468/549] SCSS lint fixes --- app/assets/stylesheets/_photos.scss | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/assets/stylesheets/_photos.scss b/app/assets/stylesheets/_photos.scss index aa455378f..24a68b95f 100644 --- a/app/assets/stylesheets/_photos.scss +++ b/app/assets/stylesheets/_photos.scss @@ -7,9 +7,9 @@ // clear fix .photo-grid:after { + clear: both; content: ""; display: block; - clear: both; } .photo-grid-item { @@ -26,8 +26,8 @@ } .photo-thumbnail { - margin-right: 1em; margin-bottom: 1em; + margin-right: 1em; max-width: 150px; padding: 0; position: relative; @@ -37,19 +37,19 @@ } .text { - display: none; - color: #000; - position: absolute; - bottom: 0; background: rgba(0, 0, 0, 0.8); - width: 100%; + bottom: 0; + color: #000; + display: none; margin: 0; + position: absolute; + width: 100%; } p { - padding: 5px; - margin: 0; color: #fff; + margin: 0; + padding: 5px; } &:hover { From 3488b29142d2da8e0395e4b47b9ce97c87ea5b04 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:43:57 +1200 Subject: [PATCH 469/549] Removed empty rule --- app/assets/stylesheets/_photos.scss | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/assets/stylesheets/_photos.scss b/app/assets/stylesheets/_photos.scss index 24a68b95f..f30659614 100644 --- a/app/assets/stylesheets/_photos.scss +++ b/app/assets/stylesheets/_photos.scss @@ -2,9 +2,6 @@ background: $beige; } -.photo-grid-item { -} - // clear fix .photo-grid:after { clear: both; From 6accfee8112108ef54d13a6b5f59b997537a0c11 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:44:26 +1200 Subject: [PATCH 470/549] Removed unnecsary colouring --- app/assets/stylesheets/_photos.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/stylesheets/_photos.scss b/app/assets/stylesheets/_photos.scss index f30659614..66dc7be71 100644 --- a/app/assets/stylesheets/_photos.scss +++ b/app/assets/stylesheets/_photos.scss @@ -34,7 +34,6 @@ } .text { - background: rgba(0, 0, 0, 0.8); bottom: 0; color: #000; display: none; From 389b48d918ff10978e0d00f41c64a7242059ec0c Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:44:46 +1200 Subject: [PATCH 471/549] Use variables for scss colours --- app/assets/stylesheets/_photos.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/_photos.scss b/app/assets/stylesheets/_photos.scss index 66dc7be71..9d83db07f 100644 --- a/app/assets/stylesheets/_photos.scss +++ b/app/assets/stylesheets/_photos.scss @@ -35,7 +35,7 @@ .text { bottom: 0; - color: #000; + color: $black; display: none; margin: 0; position: absolute; From faefc0b293ffed9e42a6c70412f1a8eded3fe88b Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 09:46:31 +1200 Subject: [PATCH 472/549] the --rails flag isn't needed for rubocop anymore --- .overcommit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.overcommit.yml b/.overcommit.yml index a9ee0ed8c..2d7ed3b8d 100644 --- a/.overcommit.yml +++ b/.overcommit.yml @@ -22,7 +22,7 @@ PreCommit: problem_on_unmodified_line: warn RuboCop: enabled: true - command: ['bundle', 'exec', 'rubocop', '-D', '--rails'] + command: ['bundle', 'exec', 'rubocop', '-D'] TrailingWhitespace: enabled: true exclude: From c12f39d5d1b6f6cc15f5912cb5a416c2e3a9fbf0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 10:03:19 +1200 Subject: [PATCH 473/549] set ID on crop search form --- app/views/crops/search.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/crops/search.html.haml b/app/views/crops/search.html.haml index 2fc65a06e..1312f5d50 100644 --- a/app/views/crops/search.html.haml +++ b/app/views/crops/search.html.haml @@ -14,7 +14,7 @@ %h1 Crop search - = bootstrap_form_tag(url: search_crops_path, method: :get, id: 'crop-search', layout: :inline) do |f| + = bootstrap_form_tag(url: search_crops_path, method: :get, html: { id: 'crop-search'}, layout: :inline) do |f| = f.label :term, "Search crops:", class: 'sr-only' = f.text_field 'term', class: 'search-query input-medium', placeholder: 'Search crops', From a3f25a4526042e2b1f4734f714c6c7283ab63ba7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 10:08:19 +1200 Subject: [PATCH 474/549] use another variable in scss --- app/assets/stylesheets/_photos.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/_photos.scss b/app/assets/stylesheets/_photos.scss index 9d83db07f..881290081 100644 --- a/app/assets/stylesheets/_photos.scss +++ b/app/assets/stylesheets/_photos.scss @@ -43,7 +43,7 @@ } p { - color: #fff; + color: $white; margin: 0; padding: 5px; } From 38a0b76eaaf92c63aa1120c3908fe44a7517c0c0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 10:08:34 +1200 Subject: [PATCH 475/549] add id to header search for input, so specs pass --- app/views/crops/_search_bar.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/crops/_search_bar.haml b/app/views/crops/_search_bar.haml index 1c33eae3a..f042b28f4 100644 --- a/app/views/crops/_search_bar.haml +++ b/app/views/crops/_search_bar.haml @@ -1,6 +1,6 @@ = form_tag search_crops_path, method: :get, class: 'form-inline', id: 'navbar-search' do .input-group - %input.form-control{name: 'term', "aria-label" => "Search crops", placeholder: "Search crops", type: "search"}/ + %input.form-control{name: 'term', "aria-label" => "Search crops", placeholder: "Search crops", type: "search", id: 'term' }/ %button.btn.btn-default.text-white{type: "submit"} = icon 'fas', 'search' .sr-only Search From 6383bd73d6de8ce7834c3336943a8a48613fad5d Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 10:22:24 +1200 Subject: [PATCH 476/549] Tidy up display of member avatar on seeds --- app/views/seeds/_card.html.haml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index 53857a724..3d3fe897f 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -7,8 +7,5 @@ %span.badge.badge-pill.badge-secondary Will trade #{seed.tradable_to} = link_to seed.owner do .card-footer - %ul.nav.nav-justified.small - %li.nav-item - %span.badge.badge-pill.badge-secondary=seed.owner.location - %li.nav-item - = render 'members/tiny', member: seed.owner \ No newline at end of file + %span.badge.badge-pill.badge-secondary=seed.owner.location + = render 'members/tiny', member: seed.owner \ No newline at end of file From c540bd88fcd3396eb721a170f51751479fe4dc72 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 10:51:10 +1200 Subject: [PATCH 477/549] add back a div the specs look for --- app/views/posts/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index 62ffed5ce..4611b19ed 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -11,7 +11,7 @@ .card-deck - @posts.each do |post| .col-12.col-md-6 - .card + .card.post .card-body .row .col-2.text-right From ef43399ffd34ce36d2751676e8dcf4e5df7f911b Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 11:12:09 +1200 Subject: [PATCH 478/549] Match spec to page. h3 -> h5 --- spec/views/posts/index.html.haml_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/views/posts/index.html.haml_spec.rb b/spec/views/posts/index.html.haml_spec.rb index ee3d2fb86..9cbd147ee 100644 --- a/spec/views/posts/index.html.haml_spec.rb +++ b/spec/views/posts/index.html.haml_spec.rb @@ -19,7 +19,7 @@ describe "posts/index" do it "renders a list of posts" do assert_select "div.post", count: 2 - assert_select "h3", text: "A Post".to_s, count: 2 + assert_select "h5", text: "A Post".to_s, count: 2 assert_select "div.post-body", text: "This is some text.".to_s, count: 2 end From 382169b19c38f0c62280d6caac52e9dbbca9222a Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 11:13:21 +1200 Subject: [PATCH 479/549] MAtch button label in spec --- app/views/crops/index.html.haml | 2 +- spec/views/crops/index.html.haml_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml index f26a7801b..e0eb151e1 100644 --- a/app/views/crops/index.html.haml +++ b/app/views/crops/index.html.haml @@ -4,7 +4,7 @@ - if can? :wrangle, Crop = link_to 'Wrangle Crops', wrangle_crops_path, class: 'btn btn-secondary' - if can? :create, Crop - = link_to 'Add new Crop', new_crop_path, class: 'btn btn-primary' + = link_to 'Add New Crop', new_crop_path, class: 'btn btn-primary' - content_for :breadcrumbs do %li.breadcrumb-item.active= link_to 'Crops', crops_path diff --git a/spec/views/crops/index.html.haml_spec.rb b/spec/views/crops/index.html.haml_spec.rb index 7d86653de..0cbede012 100644 --- a/spec/views/crops/index.html.haml_spec.rb +++ b/spec/views/crops/index.html.haml_spec.rb @@ -37,7 +37,7 @@ describe "crops/index" do end it "shows a new crop link" do - rendered.should have_content "New Crop" + rendered.should have_content "Add New Crop" end end From 264506ef383ec4c506f4e59570c6047e4e1e022a Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 11:16:41 +1200 Subject: [PATCH 480/549] Move crop wrangling view test to feature spec --- spec/features/crops/browse_crops_spec.rb | 11 +++++++++++ spec/views/crops/index.html.haml_spec.rb | 13 ------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/spec/features/crops/browse_crops_spec.rb b/spec/features/crops/browse_crops_spec.rb index d3386dc40..821ae01c4 100644 --- a/spec/features/crops/browse_crops_spec.rb +++ b/spec/features/crops/browse_crops_spec.rb @@ -26,4 +26,15 @@ describe "browse crops" do visit crops_path expect(page).not_to have_content rejected_crop.name end + + context "logged in and crop wrangler" do + before do + login_as FactoryBot.create(:crop_wrangling_member) + visit crops_path + end + + it "shows a new crop link" do + expect(page).to have_link "Add New Crop" + end + end end diff --git a/spec/views/crops/index.html.haml_spec.rb b/spec/views/crops/index.html.haml_spec.rb index 0cbede012..9c1c16805 100644 --- a/spec/views/crops/index.html.haml_spec.rb +++ b/spec/views/crops/index.html.haml_spec.rb @@ -28,19 +28,6 @@ describe "crops/index" do assert_select "img", src: :tomato end - context "logged in and crop wrangler" do - before do - @member = FactoryBot.create(:crop_wrangling_member) - sign_in @member - controller.stub(:current_user) { @member } - render - end - - it "shows a new crop link" do - rendered.should have_content "Add New Crop" - end - end - context "downloads" do it "offers data downloads" do render From b176ba59dc16c9011cb896f71d7647a1a2fc4208 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 11:19:15 +1200 Subject: [PATCH 481/549] removed byline method avoiding use of htmlseafe --- app/helpers/posts_helper.rb | 21 --------------------- app/views/posts/index.html.haml | 13 ++++++++++++- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index b4d9161f4..c2beeec1a 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -4,25 +4,4 @@ module PostsHelper truncate(strip_tags(post.body), length: length, separator: ' ', omission: '... ') { link_to "Read more", post_path(post) } end - - def post_byline(post) - byline = 'Posted by ' - - byline += if post.author - link_to post.author.login_name, member_path(post.author) - else - 'Member Deleted' - end - - if post.forum - byline += ' in ' - byline += link_to post.forum, post.forum - end - - byline += " on #{post.created_at}" - - byline += " and edited at #{post.updated_at}" if post.updated_at > post.created_at - - byline.html_safe - end end diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index 4611b19ed..d6c034c65 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -23,7 +23,18 @@ %span.badge.badge-pill.badge-info.float-right = icon 'fas', 'comment' = post.comments.size - %p.text-muted= post_byline(post) + %p.text-muted + Posted by + - if post.author + = link_to post.author.login_name, member_path(post.author) + - else + Member Deleted + + - if post.forum + in #{link_to post.forum, post.forum} + on #{post.created_at}" + - if post.updated_at > post.created_at + and edited at #{post.updated_at} %p.card-text= display_post_truncated(post) - post.crops.each do |crop| %span.badge.badge-pill.badge-primary= link_to crop, crop From 7a613b5dccb0369090edc1d9fa6bf5b21b59ac0a Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 11:25:10 +1200 Subject: [PATCH 482/549] Merge scss --- app/assets/stylesheets/_photos.scss | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/_photos.scss b/app/assets/stylesheets/_photos.scss index 881290081..691cdda2a 100644 --- a/app/assets/stylesheets/_photos.scss +++ b/app/assets/stylesheets/_photos.scss @@ -11,11 +11,10 @@ .photo-grid-item { float: left; -} - -.photo-grid-item img { - display: block; - max-width: 100%; + img { + display: block; + max-width: 100%; + } } .hero-photo { From 6634465c1faafbab9cd44df093abf92040c4f29f Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 11:25:27 +1200 Subject: [PATCH 483/549] new line at end --- app/assets/stylesheets/_photos.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/_photos.scss b/app/assets/stylesheets/_photos.scss index 691cdda2a..eb98e0fd3 100644 --- a/app/assets/stylesheets/_photos.scss +++ b/app/assets/stylesheets/_photos.scss @@ -52,4 +52,4 @@ display: block; } } -} \ No newline at end of file +} From d5e22d3285dbd1397f46f1a5d4d7fbee2dbb04fc Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 11:26:14 +1200 Subject: [PATCH 484/549] scss lint --- app/assets/stylesheets/_plantings.scss | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/assets/stylesheets/_plantings.scss b/app/assets/stylesheets/_plantings.scss index 6a776aef6..14b7c366e 100755 --- a/app/assets/stylesheets/_plantings.scss +++ b/app/assets/stylesheets/_plantings.scss @@ -13,8 +13,8 @@ } .planting-thumbnail { - width: 150px; padding: 0; + width: 150px; .badge { font-size: 100%; @@ -42,10 +42,10 @@ } .planting-quick-actions { + background-color: $white; + left: 0; position: absolute; top: 0; - left: 0; - background-color: $white; } .planting-thumbnail-photo { @@ -65,24 +65,24 @@ .planting-facts { display: flex; - flex: none; flex-wrap: wrap; + flex: none; margin: 0.5em; .fact { - text-align: center; - height: 160px; - width: 160px; - border: 1px solid lighten($green, 20%); - border-radius: 5%; background: $white; - padding: 1em; - margin: 0.5em; + border-radius: 5%; + border: 1px solid lighten($green, 20%); + height: 160px; left: -0.5em; + margin: 0.5em; + padding: 1em; + text-align: center; + width: 160px; strong { - font-size: 3em; font-align: center; + font-size: 3em; } h3 { From d955dea240583788d5e267dc879e32a84e4405ff Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 11:26:36 +1200 Subject: [PATCH 485/549] scss lint --- app/assets/stylesheets/_predictions.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/_predictions.scss b/app/assets/stylesheets/_predictions.scss index 82a69ee56..b851f0d57 100644 --- a/app/assets/stylesheets/_predictions.scss +++ b/app/assets/stylesheets/_predictions.scss @@ -8,8 +8,8 @@ margin: 1em; strong { - font-size: 4em; font-align: center; + font-size: 4em; } h3 {} From db57432fee0bf360b0994a013500e4e02bd5bb32 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 11:26:52 +1200 Subject: [PATCH 486/549] scss lint --- app/assets/stylesheets/_variables.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/_variables.scss b/app/assets/stylesheets/_variables.scss index f2342de28..19f671da8 100644 --- a/app/assets/stylesheets/_variables.scss +++ b/app/assets/stylesheets/_variables.scss @@ -9,7 +9,7 @@ $blue: #2f4365; $red: #ff4d43; $orange: #ffa500; $yellow: #b2935c; -$white: #ffffff; +$white: #fff; $body-bg: $beige; From a361e804eeb11552d39090ee72d1550cd31b5c85 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 11:27:19 +1200 Subject: [PATCH 487/549] scss lint --- app/assets/stylesheets/overrides.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index 8e32ed277..0e05b1d1e 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -9,7 +9,7 @@ section { } .ellipsis { - overflow:hidden; + overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } From aa3297f4dac24fc8d9c69f850fe5b8e5150b88c8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 11:29:41 +1200 Subject: [PATCH 488/549] scss lint --- app/assets/stylesheets/overrides.scss | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index 0e05b1d1e..a0f434385 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -63,6 +63,7 @@ h3 { background-color: $white; color: $black; } + input::placeholder { color: $navbar-default-link-color; } @@ -121,9 +122,9 @@ img.img-icon { } .profile-activity { - background: white; - padding: 2em; + background: $white; margin-top: 2em; + padding: 2em; } .sidebar { @@ -145,9 +146,17 @@ img.img-icon { // let's condense the hero unit a little .jumbotron { background-color: darken($beige, 10%); - text-color: $white; padding-top: 30px; padding-bottom: 30px; + // signup widget on homepage + .signup { + background-color: lighten($green, 40%); + border-radius: 6px; + border: 1px solid lighten($green, 20%); + line-height: 200%; + padding: 15px; + text-align: center; + } } // info under the main heading on homepage @@ -157,15 +166,6 @@ img.img-icon { text-align: center; } -// signup widget on homepage -.jumbotron .signup { - background-color: lighten($green, 40%); - border-radius: 6px; - border: 1px solid lighten($green, 20%); - line-height: 200%; - padding: 15px; - text-align: center; -} // stats shown on homepage. eg. "999 members..." p.stats { @@ -289,7 +289,7 @@ html, body { // Autosuggest .ui-autocomplete { - background: white; + background: $white; z-index: $zindex-tooltip } From 3dac09968dfd509318c4e60412c95c789bb4fe7c Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 11:30:30 +1200 Subject: [PATCH 489/549] Remove empty rule --- app/assets/stylesheets/overrides.scss | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index a0f434385..672e17f2e 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -190,8 +190,6 @@ p.stats { } } -.layout-actions {} - #placesmap, #cropmap { height: 500px; } From 0324e515e09c8c3f3f18d8cb6ee23c5cd9a06d94 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 11:30:47 +1200 Subject: [PATCH 490/549] scss lint --- app/assets/stylesheets/overrides.scss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index 672e17f2e..3e8492c13 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -190,7 +190,8 @@ p.stats { } } -#placesmap, #cropmap { +#placesmap, +#cropmap { height: 500px; } From c702623c4f5cd596f781e7d4d760e1a23cea60a1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 11:31:10 +1200 Subject: [PATCH 491/549] Prefer single quoted strings --- app/assets/stylesheets/overrides.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index 3e8492c13..e59a1e777 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -201,7 +201,7 @@ p.stats { } .location-not-set { - background-image: image-url("location-not-set.en.png"); + background-image: image-url('location-not-set.en.png'); background-position: center; background-repeat: no-repeat; height: 250px; From c60162e415180a9fa3137e44df64e60b640a1e09 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 11:31:37 +1200 Subject: [PATCH 492/549] scss lint --- app/assets/stylesheets/overrides.scss | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index e59a1e777..6744466f9 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -241,7 +241,9 @@ li.crop-hierarchy { // footer footer { - #footer1, #footer2, #footer3 { + #footer1, + #footer2, + #footer3 { padding-bottom: 2em; padding-top: 1em; text-align: left; From 88025b8a2154823e53f236c90567c8a3564fbf1c Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 11:32:02 +1200 Subject: [PATCH 493/549] scss lint --- app/assets/stylesheets/overrides.scss | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index 6744466f9..b0e9c7021 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -280,7 +280,8 @@ footer { padding-top: 10px; } -html, body { +html, +body { height: 100%; } @@ -314,7 +315,10 @@ $state-success-bg: lighten($green, 50%); display: none; } -#add-sci_name-row, #remove-sci_name-row, #add-alt_name-row, #remove-alt_name-row { +#add-sci_name-row, +#remove-sci_name-row, +#add-alt_name-row, +#remove-alt_name-row { display: none; } From 1d98668ac4728b8c7a65634ff3e5d31ecdeeb8f5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 16:21:59 +1200 Subject: [PATCH 494/549] scss lint --- app/assets/stylesheets/_photos.scss | 1 + app/views/posts/index.html.haml | 3 ++- spec/views/posts/index.html.haml_spec.rb | 8 +++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/_photos.scss b/app/assets/stylesheets/_photos.scss index eb98e0fd3..5127f2336 100644 --- a/app/assets/stylesheets/_photos.scss +++ b/app/assets/stylesheets/_photos.scss @@ -11,6 +11,7 @@ .photo-grid-item { float: left; + img { display: block; max-width: 100%; diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index d6c034c65..fd987aeac 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -35,7 +35,8 @@ on #{post.created_at}" - if post.updated_at > post.created_at and edited at #{post.updated_at} - %p.card-text= display_post_truncated(post) + .card-text + .post-body= display_post_truncated(post) - post.crops.each do |crop| %span.badge.badge-pill.badge-primary= link_to crop, crop diff --git a/spec/views/posts/index.html.haml_spec.rb b/spec/views/posts/index.html.haml_spec.rb index 9cbd147ee..b8e8b5ba5 100644 --- a/spec/views/posts/index.html.haml_spec.rb +++ b/spec/views/posts/index.html.haml_spec.rb @@ -9,8 +9,10 @@ describe "posts/index" do total_entries = 2 posts = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| pager.replace([ - FactoryBot.create(:post, author: @author), - FactoryBot.create(:post, author: @author) + FactoryBot.create(:post, author: @author, + subject: 'A Post', body: 'This is some text.'), + FactoryBot.create(:post, author: @author, + subject: 'A Post', body: 'This is some text.') ]) end assign(:posts, posts) @@ -19,7 +21,7 @@ describe "posts/index" do it "renders a list of posts" do assert_select "div.post", count: 2 - assert_select "h5", text: "A Post".to_s, count: 2 + assert_select "h5", text: "A Post", count: 2 assert_select "div.post-body", text: "This is some text.".to_s, count: 2 end From 3bcfc8885641b68ff7db320e58d90e7564b16c8b Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 26 Jun 2019 16:30:55 +1200 Subject: [PATCH 495/549] Add title to page --- app/views/members/unsubscribe.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/members/unsubscribe.html.haml b/app/views/members/unsubscribe.html.haml index b11a52a50..adabafb17 100644 --- a/app/views/members/unsubscribe.html.haml +++ b/app/views/members/unsubscribe.html.haml @@ -1,5 +1,5 @@ - content_for :title, "Unsubscribe #{@member}" - +%h1 Unsubscribe #{@member} %p If you wish to unsubscribe from other Growstuff emails, you may do so via = link_to "your settings page", edit_member_registration_url From 53636dc47ab1e76b091abd5832d23cc0dba17217 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 26 Jun 2019 07:19:25 +0000 Subject: [PATCH 496/549] Bump rubocop from 0.71.0 to 0.72.0 Bumps [rubocop](https://github.com/rubocop-hq/rubocop) from 0.71.0 to 0.72.0. - [Release notes](https://github.com/rubocop-hq/rubocop/releases) - [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop-hq/rubocop/compare/v0.71.0...v0.72.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ce29b4a99..6f645f75a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -236,7 +236,7 @@ GEM isotope-rails (2.2.2) jquery-rails rails (>= 4.0) - jaro_winkler (1.5.2) + jaro_winkler (1.5.3) jquery-rails (4.3.5) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -419,7 +419,7 @@ GEM rspec-mocks (~> 3.8.0) rspec-support (~> 3.8.0) rspec-support (3.8.0) - rubocop (0.71.0) + rubocop (0.72.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.6) From f2c6f27c10c9b8e0221de1519ec4dc4d43b82c75 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 26 Jun 2019 19:09:08 +0000 Subject: [PATCH 497/549] Bump scout_apm from 2.5.0 to 2.5.1 Bumps [scout_apm](https://github.com/scoutapp/scout_apm_ruby) from 2.5.0 to 2.5.1. - [Release notes](https://github.com/scoutapp/scout_apm_ruby/releases) - [Changelog](https://github.com/scoutapp/scout_apm_ruby/blob/master/CHANGELOG.markdown) - [Commits](https://github.com/scoutapp/scout_apm_ruby/compare/v2.5.0...v2.5.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6f645f75a..1127454de 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -454,7 +454,7 @@ GEM sprockets (> 3.0) sprockets-rails tilt - scout_apm (2.5.0) + scout_apm (2.5.1) searchkick (4.0.2) activemodel (>= 5) elasticsearch (>= 6) From 9dada23e42d0635dc157dc5fc82be61190550324 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <shiny@cpan.org> Date: Thu, 27 Jun 2019 14:31:22 +1200 Subject: [PATCH 498/549] Marking the tests that fail as pending Until we fix in chrome head less --- spec/features/unsubscribing_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/features/unsubscribing_spec.rb b/spec/features/unsubscribing_spec.rb index f53a45c4f..e056bedeb 100644 --- a/spec/features/unsubscribing_spec.rb +++ b/spec/features/unsubscribing_spec.rb @@ -5,11 +5,10 @@ describe "unsubscribe" do let(:member) { create :member } let(:notification) { create :notification } - before do - clear_emails - end + before { clear_emails } - it "from planting reminder mailing list" do + # TODO get these working again with chrome headless + pending "from planting reminder mailing list" do # verifying the initial subscription status of the member expect(member.send_planting_reminder).to eq(true) expect(member.send_notification_email).to eq(true) @@ -26,7 +25,8 @@ describe "unsubscribe" do expect(updated_member.send_notification_email).to eq(true) end - it "from inbox notification mailing list" do + # TODO get these working again with chrome headless + pending "from inbox notification mailing list" do # verifying the initial subscription status of the member expect(member.send_planting_reminder).to eq(true) expect(member.send_notification_email).to eq(true) From 99f97f51dc1e7d690dada8d4edd8e8df68dba983 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Thu, 27 Jun 2019 14:43:38 +1200 Subject: [PATCH 499/549] Update app/assets/stylesheets/_variables.scss --- app/assets/stylesheets/_variables.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/stylesheets/_variables.scss b/app/assets/stylesheets/_variables.scss index 19f671da8..da8811e64 100644 --- a/app/assets/stylesheets/_variables.scss +++ b/app/assets/stylesheets/_variables.scss @@ -72,7 +72,6 @@ $navbar-default-brand-color: lighten($green, 20%); // // Top nav collapse threshold // //$grid-float-breakpoint: $screen-md-min -// $dropdown-bg: lighten($beige, 10%); // $dropdown-link-color: $brown; // $dropdown-link-hover-color: $brown; // $dropdown-link-hover-bg: lighten($green, 50%); From ea2e0697a76e046aa56af16a3da77ac81c46392c Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Thu, 27 Jun 2019 14:44:30 +1200 Subject: [PATCH 500/549] Update Gemfile --- Gemfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile b/Gemfile index 7449bd499..afb4a5efd 100644 --- a/Gemfile +++ b/Gemfile @@ -145,7 +145,6 @@ group :development, :test do gem 'haml-rails' # HTML templating language gem 'haml_lint', '>= 0.25.1' # Checks haml files for goodness gem 'i18n-tasks' # adds tests for finding missing and unused translations - # gem 'poltergeist' # for headless JS testing gem 'rspec-activemodel-mocks' gem 'rspec-rails' # unit testing framework gem 'rubocop', '~> 0.70' From dc6034c01b2b88fed7857d3bf7f78729e4c2aefe Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Thu, 27 Jun 2019 14:45:06 +1200 Subject: [PATCH 501/549] Update app/assets/stylesheets/_variables.scss --- app/assets/stylesheets/_variables.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/stylesheets/_variables.scss b/app/assets/stylesheets/_variables.scss index da8811e64..60c7d6096 100644 --- a/app/assets/stylesheets/_variables.scss +++ b/app/assets/stylesheets/_variables.scss @@ -70,7 +70,6 @@ $navbar-default-link-active-color: darken($beige, 80%); $navbar-default-brand-color: lighten($green, 20%); // // Top nav collapse threshold -// //$grid-float-breakpoint: $screen-md-min // $dropdown-link-color: $brown; // $dropdown-link-hover-color: $brown; From 7f2afa718dff763387e311bbbccd15d9feccfe45 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Thu, 27 Jun 2019 14:45:22 +1200 Subject: [PATCH 502/549] Update app/assets/stylesheets/_predictions.scss --- app/assets/stylesheets/_predictions.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/stylesheets/_predictions.scss b/app/assets/stylesheets/_predictions.scss index b851f0d57..f5c1d498b 100644 --- a/app/assets/stylesheets/_predictions.scss +++ b/app/assets/stylesheets/_predictions.scss @@ -13,7 +13,6 @@ } h3 {} - span { display: block; } From 70a69e7220926fb00982e36e5a8e4e669c6c4e40 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Thu, 27 Jun 2019 14:45:42 +1200 Subject: [PATCH 503/549] Update app/assets/stylesheets/_predictions.scss --- app/assets/stylesheets/_predictions.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/stylesheets/_predictions.scss b/app/assets/stylesheets/_predictions.scss index f5c1d498b..b02203530 100644 --- a/app/assets/stylesheets/_predictions.scss +++ b/app/assets/stylesheets/_predictions.scss @@ -12,7 +12,6 @@ font-size: 4em; } - h3 {} span { display: block; } From 1ae0558e4c348ed051838f52cf711e9e21b4d4d5 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 26 Jun 2019 19:27:23 +0000 Subject: [PATCH 504/549] Bump puma from 3.12.1 to 4.0.0 Bumps [puma](https://github.com/puma/puma) from 3.12.1 to 4.0.0. - [Release notes](https://github.com/puma/puma/releases) - [Changelog](https://github.com/puma/puma/blob/master/History.md) - [Commits](https://github.com/puma/puma/compare/v3.12.1...v4.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> --- Gemfile.lock | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1127454de..4e40af3ad 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -342,7 +342,8 @@ GEM cliver (~> 0.3.1) websocket-driver (>= 0.2.0) public_suffix (3.1.0) - puma (3.12.1) + puma (4.0.0) + nio4r (~> 2.0) rack (2.0.7) rack-protection (2.0.5) rack From 8b3adcf7a7537ff6f05a0143c78dd02109ea750d Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Thu, 27 Jun 2019 21:26:35 +1200 Subject: [PATCH 505/549] Rubocop fix up --- spec/features/unsubscribing_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/unsubscribing_spec.rb b/spec/features/unsubscribing_spec.rb index e056bedeb..039b536b6 100644 --- a/spec/features/unsubscribing_spec.rb +++ b/spec/features/unsubscribing_spec.rb @@ -7,7 +7,7 @@ describe "unsubscribe" do before { clear_emails } - # TODO get these working again with chrome headless + # TODO: get these working again with chrome headless pending "from planting reminder mailing list" do # verifying the initial subscription status of the member expect(member.send_planting_reminder).to eq(true) @@ -25,7 +25,7 @@ describe "unsubscribe" do expect(updated_member.send_notification_email).to eq(true) end - # TODO get these working again with chrome headless + # TODO: get these working again with chrome headless pending "from inbox notification mailing list" do # verifying the initial subscription status of the member expect(member.send_planting_reminder).to eq(true) From c94b026c587afe21ad37c6cc454d666eabd7dff3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Thu, 27 Jun 2019 21:33:25 +1200 Subject: [PATCH 506/549] solving rubocop dependencies errors --- Gemfile.lock | 131 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 83 insertions(+), 48 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e66ef9241..461c418cb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,9 +57,9 @@ GEM public_suffix (>= 2.0.2, < 4.0) arel (9.0.0) ast (2.4.0) - autoprefixer-rails (9.4.7) + autoprefixer-rails (9.6.0) execjs - bcrypt (3.1.12) + bcrypt (3.1.13) better_errors (2.5.1) coderay (>= 1.0.0) erubi (>= 1.0.0) @@ -81,7 +81,7 @@ GEM actionpack (>= 5.0) activemodel (>= 5.0) builder (3.2.3) - bullet (6.0.0) + bullet (6.0.1) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) byebug (11.0.1) @@ -128,12 +128,12 @@ GEM rails (>= 5.0.0) concurrent-ruby (1.1.5) connection_pool (2.2.2) - coveralls (0.8.19) - json (>= 1.8, < 3) - simplecov (~> 0.12.0) - term-ansicolor (~> 1.3) - thor (~> 0.19.1) - tins (~> 1.6) + coveralls (0.7.1) + multi_json (~> 1.3) + rest-client + simplecov (>= 0.7) + term-ansicolor + thor crass (1.0.4) csv_shaper (1.3.0) activesupport (>= 3.0.0) @@ -147,6 +147,8 @@ GEM warden (~> 1.2.3) diff-lcs (1.3) docile (1.1.5) + domain_name (0.5.20180417) + unf (>= 0.0.5, < 1.0.0) elasticsearch (6.8.0) elasticsearch-api (= 6.8.0) elasticsearch-transport (= 6.8.0) @@ -160,20 +162,26 @@ GEM elasticsearch-transport (6.8.0) faraday multi_json + equatable (0.6.1) erubi (1.8.0) erubis (2.7.0) - excon (0.62.0) + excon (0.64.0) execjs (2.7.0) - factory_bot (4.11.1) - activesupport (>= 3.0.0) - factory_bot_rails (4.11.1) - factory_bot (~> 4.11.1) - railties (>= 3.0.0) - faker (1.9.3) + factory_bot (5.0.2) + activesupport (>= 4.2.0) + factory_bot_rails (5.0.2) + factory_bot (~> 5.0.2) + railties (>= 4.2.0) + faker (1.9.4) i18n (>= 0.7) + pastel (~> 0.7.2) + thor (~> 0.20.0) + tty-pager (~> 0.12.0) + tty-screen (~> 0.6.5) + tty-tree (~> 0.3.0) faraday (0.15.4) multipart-post (>= 1.2, < 3) - ffi (1.10.0) + ffi (1.11.1) figaro (1.1.1) thor (~> 0.14) flickraw (0.9.10) @@ -217,13 +225,15 @@ GEM excon moneta multi_json (>= 1.9.2) - highline (2.0.1) + highline (2.0.2) html2haml (2.2.0) erubis (~> 2.7.0) haml (>= 4.0, < 6) nokogiri (>= 1.6.0) ruby_parser (~> 3.5) - httparty (0.16.3) + http-cookie (1.0.3) + domain_name (~> 0.5) + httparty (0.17.0) mime-types (~> 3.0) multi_xml (>= 0.5.2) i18n (1.6.0) @@ -245,15 +255,15 @@ GEM thor (>= 0.14, < 2.0) jquery-ui-rails (6.0.1) railties (>= 3.2.16) - js-routes (1.4.6) + js-routes (1.4.7) railties (>= 4) sprockets-rails - json (2.1.0) - jsonapi-resources (0.9.8) + json (2.2.0) + jsonapi-resources (0.9.9) activerecord (>= 4.1) concurrent-ruby railties (>= 4.1) - jwt (2.1.0) + jwt (2.2.1) kaminari (1.1.1) activesupport (>= 4.1.0) kaminari-actionview (= 1.1.1) @@ -270,7 +280,7 @@ GEM kramdown (2.1.0) launchy (2.4.3) addressable (~> 2.3) - leaflet-rails (1.4.0) + leaflet-rails (1.5.1) rails (>= 4.2.0) letter_opener (1.7.0) launchy (~> 2.2) @@ -294,7 +304,7 @@ GEM method_source (0.9.2) mime-types (3.2.2) mime-types-data (~> 3.2015) - mime-types-data (3.2018.0812) + mime-types-data (3.2019.0331) mimemagic (0.3.3) mini_magick (4.9.3) mini_mime (1.0.1) @@ -304,7 +314,8 @@ GEM multi_json (1.11.3) multi_xml (0.6.0) multipart-post (2.1.1) - newrelic_rpm (6.4.0.356) + netrc (0.11.0) + newrelic_rpm (6.5.0.357) nio4r (2.3.1) nokogiri (1.10.3) mini_portile2 (~> 2.4.0) @@ -339,13 +350,16 @@ GEM activerecord (>= 4.0, < 6.1) parser (2.6.3.0) ast (~> 2.4.0) + pastel (0.7.3) + equatable (~> 0.6) + tty-color (~> 0.5) percy-capybara (4.0.1) pg (0.21.0) platform-api (2.2.0) heroics (~> 0.0.25) moneta (~> 1.0.0) popper_js (1.14.5) - public_suffix (3.1.0) + public_suffix (3.1.1) puma (4.0.0) nio4r (~> 2.0) rack (2.0.7) @@ -366,7 +380,7 @@ GEM bundler (>= 1.3.0) railties (= 5.2.2.1) sprockets-rails (>= 2.0.0) - rails-assets-leaflet (1.3.4) + rails-assets-leaflet (1.5.1) rails-assets-leaflet.markercluster (1.4.1) rails-assets-leaflet (>= 1.3.1) rails-controller-testing (1.0.4) @@ -398,21 +412,25 @@ GEM rb-fsevent (0.10.3) rb-inotify (0.10.0) ffi (~> 1.0) - redis (4.1.0) + redis (4.1.2) regexp_parser (1.5.1) - responders (2.4.1) - actionpack (>= 4.2.0, < 6.0) - railties (>= 4.2.0, < 6.0) + responders (3.0.0) + actionpack (>= 5.0) + railties (>= 5.0) + rest-client (2.0.2) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) rspec-activemodel-mocks (1.1.0) activemodel (>= 3.0) activesupport (>= 3.0) rspec-mocks (>= 2.99, < 4.0) - rspec-core (3.8.0) + rspec-core (3.8.1) rspec-support (~> 3.8.0) - rspec-expectations (3.8.2) + rspec-expectations (3.8.4) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.8.0) - rspec-mocks (3.8.0) + rspec-mocks (3.8.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.8.0) rspec-rails (3.8.2) @@ -423,7 +441,7 @@ GEM rspec-expectations (~> 3.8.0) rspec-mocks (~> 3.8.0) rspec-support (~> 3.8.0) - rspec-support (3.8.0) + rspec-support (3.8.2) rubocop (0.72.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) @@ -431,9 +449,9 @@ GEM rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 1.7) - rubocop-rails (2.0.1) + rubocop-rails (2.1.0) rack (>= 1.1) - rubocop (>= 0.70.0) + rubocop (>= 0.72.0) rubocop-rspec (1.33.0) rubocop (>= 0.60.0) ruby-progressbar (1.10.1) @@ -441,8 +459,8 @@ GEM ruby_dep (1.5.0) ruby_parser (3.13.1) sexp_processor (~> 4.9) - rubyzip (1.2.2) - sass (3.7.3) + rubyzip (1.2.3) + sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) @@ -456,7 +474,7 @@ GEM sassc (2.0.1) ffi (~> 1.9) rake - sassc-rails (2.1.0) + sassc-rails (2.1.2) railties (>= 4.0.0) sassc (>= 2.0) sprockets (> 3.0) @@ -470,13 +488,13 @@ GEM selenium-webdriver (3.142.3) childprocess (>= 0.5, < 2.0) rubyzip (~> 1.2, >= 1.2.2) - sexp_processor (4.12.0) + sexp_processor (4.12.1) sidekiq (5.2.7) connection_pool (~> 2.2, >= 2.2.2) rack (>= 1.5.0) rack-protection (>= 1.5.0) redis (>= 3.3.5, < 5) - simplecov (0.12.0) + simplecov (0.13.0) docile (~> 1.1.0) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) @@ -488,23 +506,40 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) + strings (0.1.5) + strings-ansi (~> 0.1) + unicode-display_width (~> 1.5) + unicode_utils (~> 1.4) + strings-ansi (0.1.0) sysexits (1.2.0) temple (0.8.1) - term-ansicolor (1.7.0) + term-ansicolor (1.7.1) tins (~> 1.0) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) - thor (0.19.4) + thor (0.20.3) thread_safe (0.3.6) tilt (2.0.9) timecop (0.9.1) - tins (1.20.2) + tins (1.20.3) trollop (1.16.2) + tty-color (0.5.0) + tty-pager (0.12.1) + strings (~> 0.1.4) + tty-screen (~> 0.6) + tty-which (~> 0.4) + tty-screen (0.6.5) + tty-tree (0.3.0) + tty-which (0.4.1) tzinfo (1.2.5) thread_safe (~> 0.1) uglifier (4.1.20) execjs (>= 0.3.0, < 3) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.6) unicode-display_width (1.6.0) + unicode_utils (1.4.0) unicorn (5.5.1) kgio (~> 2.6) raindrops (~> 0.7) @@ -519,9 +554,9 @@ GEM nokogiri (>= 1.2.0) rack (>= 1.0) rack-test (>= 0.5.3) - websocket-driver (0.7.0) + websocket-driver (0.7.1) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.3) + websocket-extensions (0.1.4) will_paginate (3.1.7) will_paginate-bootstrap4 (0.2.2) will_paginate (~> 3.0, >= 3.0.0) From d1e7ba701b503b4b558e152de7537d85c62b4685 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Thu, 27 Jun 2019 21:48:48 +1200 Subject: [PATCH 507/549] fixing mobile display --- app/assets/stylesheets/_plantings.scss | 20 +++++++++------- app/assets/stylesheets/_predictions.scss | 8 +++---- app/views/plantings/_facts.haml | 30 ++++++++++++------------ 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/app/assets/stylesheets/_plantings.scss b/app/assets/stylesheets/_plantings.scss index 14b7c366e..8d5d3cbe0 100755 --- a/app/assets/stylesheets/_plantings.scss +++ b/app/assets/stylesheets/_plantings.scss @@ -63,30 +63,34 @@ } } + + .planting-facts { display: flex; flex-wrap: wrap; flex: none; - margin: 0.5em; - .fact { + .planting-fact-card { + background: $white; background: $white; border-radius: 5%; border: 1px solid lighten($green, 20%); - height: 160px; - left: -0.5em; - margin: 0.5em; + margin: 1em; padding: 1em; text-align: center; - width: 160px; + width: 120px; strong { font-align: center; - font-size: 3em; + font-size: 4em; + } + + span { + display: block; } h3 { - padding-top: 1em; + // padding-top: 1em; } span { diff --git a/app/assets/stylesheets/_predictions.scss b/app/assets/stylesheets/_predictions.scss index b02203530..f16c6ee8f 100644 --- a/app/assets/stylesheets/_predictions.scss +++ b/app/assets/stylesheets/_predictions.scss @@ -1,11 +1,11 @@ .predictions { .predictions-card { - text-align: center; - max-width: 250px; - border: 1px solid lighten($green, 20%); - border-radius: 5%; background: $white; + border-radius: 5%; + border: 1px solid lighten($green, 20%); margin: 1em; + max-width: 250px; + text-align: center; strong { font-align: center; diff --git a/app/views/plantings/_facts.haml b/app/views/plantings/_facts.haml index d63a56162..15eeb303a 100644 --- a/app/views/plantings/_facts.haml +++ b/app/views/plantings/_facts.haml @@ -1,6 +1,6 @@ -.planting-facts +.card-deck.mx-auto.planting-facts - if planting.parent_seed - .fact.card + .card.planting-fact-card %h3 Parent seed %strong = link_to seed_path(planting.parent_seed) do @@ -9,19 +9,19 @@ - if planting.finished - .fact.card + .card.planting-fact-card %h3 Planted %strong=planting_icon - if planting.quantity.present? %span= planting.quantity - if planting.planted_at.present? && !planting.finished? - .fact.card + .card.planting-fact-card %h3 Planted %strong #{planting.days_since_planted} %span days ago - if planting.quantity.to_i.positive? - .fact.card + .card.planting-fact-card %h3 Quantity %strong= planting.quantity %span @@ -29,14 +29,14 @@ #{pluralize((planting.quantity.to_i), planting.planted_from)} - unless planting.finished? - .fact.card.grid-sizer + .card.planting-fact-card.grid-sizer %h3 Growing %strong= seedling_icon - if planting.planted_at.present? %span= planting.planted_at.to_formatted_s(:rfc822) - if planting.percentage_grown - .fact.card + .card.planting-fact-card %h3 Progress %strong #{sprintf '%.0f', planting.percentage_grown}% .progress @@ -47,16 +47,16 @@ - if planting.planted_from.present? - .fact.card + .card.planting-fact-card %h3 Grown from %span=planting.planted_from - .fact.card + .card.planting-fact-card %h3 Grown in %strong= sunniness_icon(planting.sunniness) %span= planting.sunniness.blank? ? "not specified" : planting.sunniness - -# .fact.card + -# .card.planting-fact-card -# %h3 Garden -# = link_to planting.garden do -# - if planting.garden.default_photo.present? @@ -65,7 +65,7 @@ -# %strong= garden_icon -# %span= planting.garden.name - .fact.card + .card.planting-fact-card %h3 = planting.finished? ? "Harvests" : "Harvesting" %strong @@ -74,12 +74,12 @@ %span= planting.first_harvest_date&.to_formatted_s(:rfc822) || planting&.first_harvest_predicted_at&.to_formatted_s(:rfc822) || 'unknown' - if planting.crop.perennial - .fact.card + .card.planting-fact-card %h3 Perennial %strong=perennial_icon - else - if !planting.finished? && planting.finish_is_predicatable? - .fact.card + .card.planting-fact-card - days = days_from_now_to_finished(planting) - if days.positive? %h3 Prediction @@ -92,7 +92,7 @@ %span= planting.finish_predicted_at&.to_formatted_s(:rfc822) - if planting.child_seeds.size.positive? - .fact.card + .card.planting-fact-card %h3 Seeds saved %strong = link_to planting_seeds_path(planting) do @@ -100,7 +100,7 @@ %span #{pluralize(planting.child_seeds.size, 'packet')} of seed - if planting.finished? - .fact.card + .card.planting-fact-card %h3 Finished %strong=finished_icon %span=planting.finished_at&.to_formatted_s(:rfc822) From 19085ed2372e3cee6bdeda8ae49fc4746dd7b502 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Thu, 27 Jun 2019 21:54:29 +1200 Subject: [PATCH 508/549] fixed link to harvest or plantings photos --- app/views/harvests/show.html.haml | 3 ++- app/views/plantings/_photos.haml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/harvests/show.html.haml b/app/views/harvests/show.html.haml index 2e8ec3260..89587294b 100644 --- a/app/views/harvests/show.html.haml +++ b/app/views/harvests/show.html.haml @@ -49,7 +49,8 @@ .row .col-md-6= render @harvest.default_photo .col-md-6 - = link_to 'View all photos >>', planting_photos_path(@harvest), class: 'text-right' + %p.text-right + = link_to 'View all photos >>', harvest_photos_path(@harvest), class: 'btn' .row - @harvest.photos.order(date_taken: :desc).limit(3).each do |photo| .col-md-3= render('photos/thumbnail', photo: photo) \ No newline at end of file diff --git a/app/views/plantings/_photos.haml b/app/views/plantings/_photos.haml index 00141c76f..f27f2864d 100644 --- a/app/views/plantings/_photos.haml +++ b/app/views/plantings/_photos.haml @@ -3,7 +3,8 @@ = render 'photos/gallery', photos: photos - if can?(:edit, planting) && can?(:create, Photo) %p.text-right= add_photo_button(planting) - %p.text-right= link_to 'more photos', planting_photos_path(@planting), class: 'btn' + %p.text-right + = link_to 'more photos', planting_photos_path(planting), class: 'btn' - else %p No photos. - if can?(:edit, planting) && can?(:create, Photo) From d4a4d61f6b180cd059102fe3c0c908fc636b7936 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Thu, 27 Jun 2019 21:59:15 +1200 Subject: [PATCH 509/549] tidy up photo display --- app/views/photos/index.html.haml | 13 +++++++------ app/views/photos/new.html.haml | 13 ++++++++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/views/photos/index.html.haml b/app/views/photos/index.html.haml index 3ebb3de2d..1f9896377 100644 --- a/app/views/photos/index.html.haml +++ b/app/views/photos/index.html.haml @@ -15,12 +15,13 @@ .row - @photos.each do |p| .col-md-2.six-across - .thumbnail{ style: 'height: 220px' } - = link_to image_tag(p.thumbnail_url, alt: p.title, class: 'img'), p - %p - = link_to p.title, p - by - = link_to p.owner, p.owner + = render 'photos/card', photo: p + -# .thumbnail{ style: 'height: 220px' } + -# = link_to image_tag(p.thumbnail_url, alt: p.title, class: 'img'), p + -# %p + -# = link_to p.title, p + -# by + -# = link_to p.owner, p.owner .pagination = page_entries_info @photos diff --git a/app/views/photos/new.html.haml b/app/views/photos/new.html.haml index ea35ecddd..9daefaac3 100644 --- a/app/views/photos/new.html.haml +++ b/app/views/photos/new.html.haml @@ -27,13 +27,16 @@ .col-md-12= will_paginate @photos .row - - @photos.each do |p| + - @photos.each do |photo| .col-md-2.col-6 - .thumbnail{ style: 'height: 220px' } - = link_to image_tag(FlickRaw.url_q(p), alt: '', class: 'img', width: 150, height: 150), - photos_path(photo: { flickr_photo_id: p.id }, type: @type, id: @id), + .card + = link_to image_tag(FlickRaw.url_z(photo), alt: '', class: 'img img-card', + width: 150, height: 150), + photos_path(photo: { flickr_photo_id: photo.id }, type: @type, id: @id), method: :post - %p.photo-title= p.title + .card-body + %p.photo-title= photo.title + .row.pagination .col-md-12= will_paginate @photos - else From 9e69f0aae34efd4937566c02994575b22ad35544 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Thu, 27 Jun 2019 22:00:46 +1200 Subject: [PATCH 510/549] photos as cards --- app/views/harvests/show.html.haml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/harvests/show.html.haml b/app/views/harvests/show.html.haml index 89587294b..5909f1d55 100644 --- a/app/views/harvests/show.html.haml +++ b/app/views/harvests/show.html.haml @@ -51,6 +51,5 @@ .col-md-6 %p.text-right = link_to 'View all photos >>', harvest_photos_path(@harvest), class: 'btn' - .row - - @harvest.photos.order(date_taken: :desc).limit(3).each do |photo| - .col-md-3= render('photos/thumbnail', photo: photo) \ No newline at end of file + - @harvest.photos.order(date_taken: :desc).limit(3).each do |photo| + .col-md-3= render('photos/card', photo: photo) \ No newline at end of file From 952c1b9a2abaf57d857b4922a99c2813d335c678 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Thu, 27 Jun 2019 22:04:54 +1200 Subject: [PATCH 511/549] styled and moved the signin/signup prompts --- app/views/layouts/_nav.haml | 4 ++-- app/views/shared/_signin_signup.html.haml | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/views/layouts/_nav.haml b/app/views/layouts/_nav.haml index df6caba1c..6af1aaa10 100644 --- a/app/views/layouts/_nav.haml +++ b/app/views/layouts/_nav.haml @@ -10,5 +10,5 @@ = link_to url_for([model, action: :new]), class: 'btn' do Add a #{model.model_name.human} - - unless current_member - = render 'shared/signin_signup', to: "add a new #{model.to_s.downcase}" +- unless current_member + = render 'shared/signin_signup', to: "add a new #{model.to_s.downcase}" diff --git a/app/views/shared/_signin_signup.html.haml b/app/views/shared/_signin_signup.html.haml index 46f1e480f..5fae2b0bd 100644 --- a/app/views/shared/_signin_signup.html.haml +++ b/app/views/shared/_signin_signup.html.haml @@ -1,6 +1,7 @@ -= link_to 'Sign in', new_member_session_path -or -= link_to 'sign up', new_member_registration_path -to -= succeed "." do - = to +%p + = link_to 'Sign in', new_member_session_path, class: 'btn btn-success' + or + = link_to 'sign up', new_member_registration_path, class: 'btn btn-info' + to + = succeed "." do + = to From 66a0d8f2d0d3022418a6d4d012ad6b384364f662 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Thu, 27 Jun 2019 22:06:54 +1200 Subject: [PATCH 512/549] only show info+pagination if there are results to show --- app/views/seeds/index.html.haml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index 44f1b9b9c..adb64857b 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -19,16 +19,16 @@ - else %li.breadcrumb-item.active= link_to 'Seeds', seeds_path -.pagination - = page_entries_info @seeds - = will_paginate @seeds - unless @seeds.empty? + .pagination + = page_entries_info @seeds + = will_paginate @seeds .index-cards= render @seeds, full: true -.pagination - = page_entries_info @seeds - = will_paginate @seeds + .pagination + = page_entries_info @seeds + = will_paginate @seeds %ul.list-inline %li The data on this page is available in the following formats: From f1097e0f7c5911756215cd630a9751a7bacdeb89 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Thu, 27 Jun 2019 22:13:09 +1200 Subject: [PATCH 513/549] update photos spec --- app/views/photos/_card.html.haml | 2 +- spec/views/photos/index.html.haml_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/photos/_card.html.haml b/app/views/photos/_card.html.haml index 6855c15da..d69c0230b 100644 --- a/app/views/photos/_card.html.haml +++ b/app/views/photos/_card.html.haml @@ -1,4 +1,4 @@ -.card +.card.photo-card = link_to image_tag(photo.fullsize_url, alt: photo.title, class: 'img img-card'), photo .card-body %h3.ellipsis= link_to photo.title, photo diff --git a/spec/views/photos/index.html.haml_spec.rb b/spec/views/photos/index.html.haml_spec.rb index 5598de23a..f3eae4739 100644 --- a/spec/views/photos/index.html.haml_spec.rb +++ b/spec/views/photos/index.html.haml_spec.rb @@ -16,7 +16,7 @@ describe "photos/index" do it "renders a gallery of photos" do render - assert_select ".thumbnail", count: 2 + assert_select ".photo-card", count: 2 assert_select "img", count: 2 end end From fe7cb43c116a6c3a4e01044c3212b4d940e7cada Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Thu, 27 Jun 2019 22:13:23 +1200 Subject: [PATCH 514/549] prettier links --- app/views/seeds/index.html.haml | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index adb64857b..2b366b8c1 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -30,13 +30,21 @@ = page_entries_info @seeds = will_paginate @seeds -%ul.list-inline - %li The data on this page is available in the following formats: - - if @owner - %li= link_to "CSV", member_seeds_path(@owner, format: 'csv') - %li= link_to "JSON", member_seeds_path(@owner, format: 'json') - %li= link_to "RSS", member_seeds_path(@owner, format: 'rss') - - else - %li= link_to "CSV", seeds_path(format: 'csv') - %li= link_to "JSON", seeds_path(format: 'json') - %li= link_to "RSS", seeds_path(format: 'rss') + %ul.nav.justify-content-center + %li.nav-item + The data on this page is available in the following formats: + - if @owner + %li.nav-item + = link_to "CSV", member_seeds_path(@owner, format: 'csv'), class: 'nav-link' + %li.nav-item + = link_to "JSON", member_seeds_path(@owner, format: 'json'), class: 'nav-link' + %li.nav-item + = link_to "RSS", member_seeds_path(@owner, format: 'rss'), class: 'nav-link' + - else + %li.nav-item + = link_to "CSV", seeds_path(format: 'csv'), class: 'nav-link' + %li.nav-item + = link_to "JSON", seeds_path(format: 'json'), class: 'nav-link' + %li.nav-item + = link_to "RSS", seeds_path(format: 'rss'), class: 'nav-link' + From b65f2e858fdf9811eeb1741cd3ee2ee6a5c020b5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Thu, 27 Jun 2019 22:14:48 +1200 Subject: [PATCH 515/549] update rubocop to match codeclimate settings --- Gemfile | 2 +- Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index afb4a5efd..af27eae7c 100644 --- a/Gemfile +++ b/Gemfile @@ -147,7 +147,7 @@ group :development, :test do gem 'i18n-tasks' # adds tests for finding missing and unused translations gem 'rspec-activemodel-mocks' gem 'rspec-rails' # unit testing framework - gem 'rubocop', '~> 0.70' + gem 'rubocop', '~> 0.71' gem 'rubocop-rails' gem 'rubocop-rspec' gem 'webrat' # provides HTML matchers for view tests diff --git a/Gemfile.lock b/Gemfile.lock index 461c418cb..d349d91e6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -642,7 +642,7 @@ DEPENDENCIES responders rspec-activemodel-mocks rspec-rails - rubocop (~> 0.70) + rubocop (~> 0.71) rubocop-rails rubocop-rspec ruby-units From 8faa712e074d9255e2e1bcc0003ce69725fd8870 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Thu, 27 Jun 2019 22:23:47 +1200 Subject: [PATCH 516/549] be_success -> be_successfull fixes a deprecation warning --- .python-version | 1 + app/controllers/crops_controller.rb | 3 ++- spec/controllers/admin_controller_spec.rb | 2 +- spec/controllers/charts/crops_controller_spec.rb | 6 +++--- spec/controllers/comments_controller_spec.rb | 10 +++++----- spec/controllers/crops_controller_spec.rb | 10 +++++----- spec/controllers/member_controller_spec.rb | 6 +++--- spec/controllers/posts_controller_spec.rb | 4 ++-- spec/controllers/robots_controller_spec.rb | 8 ++++---- spec/controllers/seeds_controller_spec.rb | 2 +- 10 files changed, 27 insertions(+), 25 deletions(-) create mode 100644 .python-version diff --git a/.python-version b/.python-version new file mode 100644 index 000000000..47b6be3fa --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.7.2 \ No newline at end of file diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index c4e2fcdfb..89e45a163 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -197,7 +197,8 @@ class CropsController < ApplicationController def crops q = Crop.approved.includes(:scientific_names, plantings: :photos) q = q.popular unless @sort == 'alpha' - q.order("LOWER(crops.name)").includes(:photos).paginate(page: params[:page]) + q.order(Arel.sql("LOWER(crops.name)")) + .includes(:photos).paginate(page: params[:page]) end def requested_crops diff --git a/spec/controllers/admin_controller_spec.rb b/spec/controllers/admin_controller_spec.rb index ad6cba550..7f0e56206 100644 --- a/spec/controllers/admin_controller_spec.rb +++ b/spec/controllers/admin_controller_spec.rb @@ -7,7 +7,7 @@ describe AdminController do before { get :newsletter } describe 'fetches the admin newsletter page' do - it { expect(response).to be_success } + it { expect(response).to be_successful } it { expect(response).to render_template("admin/newsletter") } end diff --git a/spec/controllers/charts/crops_controller_spec.rb b/spec/controllers/charts/crops_controller_spec.rb index 120179c78..3a6a40bb4 100644 --- a/spec/controllers/charts/crops_controller_spec.rb +++ b/spec/controllers/charts/crops_controller_spec.rb @@ -7,19 +7,19 @@ describe Charts::CropsController do describe 'sunniness' do before { get :sunniness, params: { crop_slug: crop.to_param } } - it { expect(response).to be_success } + it { expect(response).to be_successful } end describe 'planted_from' do before { get :planted_from, params: { crop_slug: crop.to_param } } - it { expect(response).to be_success } + it { expect(response).to be_successful } end describe 'harvested_for' do before { get :harvested_for, params: { crop_slug: crop.to_param } } - it { expect(response).to be_success } + it { expect(response).to be_successful } end end end diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index ed5b8ad86..741b19ff3 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -22,7 +22,7 @@ describe CommentsController do describe "returns an RSS feed" do before { get :index, format: "rss" } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template("comments/index") } it { expect(response.content_type).to eq("application/rss+xml") } it { expect(assigns(:comments)).to eq([last_comment, first_comment]) } @@ -48,7 +48,7 @@ describe CommentsController do it "dies if no post specified" do get :new - expect(response).not_to be_success + expect(response).not_to be_successful end end @@ -69,7 +69,7 @@ describe CommentsController do describe "not my comment" do let(:comment) { FactoryBot.create :comment, post: post } - it { expect(response).not_to be_success } + it { expect(response).not_to be_successful } end end @@ -87,7 +87,7 @@ describe CommentsController do describe "not my comment" do let(:comment) { FactoryBot.create :comment } - it { expect(response).not_to be_success } + it { expect(response).not_to be_successful } end describe "attempting to change post_id" do @@ -117,7 +117,7 @@ describe CommentsController do describe "not my comment" do let(:comment) { FactoryBot.create :comment } - it { expect(response).not_to be_success } + it { expect(response).not_to be_successful } end end end diff --git a/spec/controllers/crops_controller_spec.rb b/spec/controllers/crops_controller_spec.rb index 34fe59eec..7efc1a9ba 100644 --- a/spec/controllers/crops_controller_spec.rb +++ b/spec/controllers/crops_controller_spec.rb @@ -12,14 +12,14 @@ describe CropsController do context 'anonymous' do before { get :wrangle } - it { is_expected.not_to be_success } + it { is_expected.not_to be_successful } end context 'wrangler' do include_context 'login as wrangler' before { get :wrangle } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template("crops/wrangle") } it { expect(assigns[:crop_wranglers]).to eq(Role.crop_wranglers) } end @@ -32,7 +32,7 @@ describe CropsController do include_context 'login as wrangler' before { get :hierarchy } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template("crops/hierarchy") } end end @@ -46,7 +46,7 @@ describe CropsController do describe 'search form page' do before { get :search } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template("crops/search") } end @@ -62,7 +62,7 @@ describe CropsController do describe "returns an RSS feed" do before { get :index, format: "rss" } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template("crops/index") } it { expect(response.content_type).to eq("application/rss+xml") } end diff --git a/spec/controllers/member_controller_spec.rb b/spec/controllers/member_controller_spec.rb index f6d01207f..173b0ff0e 100644 --- a/spec/controllers/member_controller_spec.rb +++ b/spec/controllers/member_controller_spec.rb @@ -18,14 +18,14 @@ describe MembersController do describe "GET JSON index" do it "provides JSON for members" do get :index, format: 'json' - response.should be_success + response.should be_successful end end describe "GET show" do it "provides JSON for member profile" do get :show, params: { slug: @member.to_param }, format: 'json' - response.should be_success + response.should be_successful end it "assigns @posts with the member's posts" do @@ -59,7 +59,7 @@ describe MembersController do describe "returns an RSS feed" do before { get :show, params: { slug: @member.to_param }, format: "rss" } - it { response.should be_success } + it { response.should be_successful } it { response.should render_template("members/show") } it { response.content_type.should eq("application/rss+xml") } end diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index e490d2ff5..0842e4a5b 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -27,7 +27,7 @@ describe PostsController do describe "GET RSS feed" do it "returns an RSS feed" do get :index, format: "rss" - expect(response).to be_success + expect(response).to be_successful expect(response).to render_template("posts/index") expect(response.content_type).to eq("application/rss+xml") end @@ -37,7 +37,7 @@ describe PostsController do it "returns an RSS feed" do post = Post.create! valid_attributes get :show, format: "rss", params: { id: post.slug } - expect(response).to be_success + expect(response).to be_successful expect(response).to render_template("posts/show") expect(response.content_type).to eq("application/rss+xml") end diff --git a/spec/controllers/robots_controller_spec.rb b/spec/controllers/robots_controller_spec.rb index 15ab05d82..b45a8b235 100644 --- a/spec/controllers/robots_controller_spec.rb +++ b/spec/controllers/robots_controller_spec.rb @@ -15,7 +15,7 @@ describe RobotsController do it 'loads the staging robots.txt file' do get :robots - expect(response).to be_success + expect(response).to be_successful expect(response.body).to eq(File.read(staging_filename)) end end @@ -26,7 +26,7 @@ describe RobotsController do it 'loads the production robots.txt file' do get :robots - expect(response).to be_success + expect(response).to be_successful expect(response.body).to eq(File.read(production_filename)) end end @@ -37,7 +37,7 @@ describe RobotsController do it 'loads the production robots.txt file' do get :robots - expect(response).to be_success + expect(response).to be_successful expect(response.body).to eq(File.read(production_filename)) end end @@ -48,7 +48,7 @@ describe RobotsController do it 'loads the production robots.txt file' do get :robots - expect(response).to be_success + expect(response).to be_successful expect(response.body).to eq(File.read(production_filename)) end end diff --git a/spec/controllers/seeds_controller_spec.rb b/spec/controllers/seeds_controller_spec.rb index eefaa1c36..1c6e89bb3 100644 --- a/spec/controllers/seeds_controller_spec.rb +++ b/spec/controllers/seeds_controller_spec.rb @@ -16,7 +16,7 @@ describe SeedsController do describe 'GET new' do before { sign_in owner } - it { expect(response).to be_success } + it { expect(response).to be_successful } context 'no parent planting' do before { get :new } From fec37368ae7be62909799d553fdd63cd244a820e Mon Sep 17 00:00:00 2001 From: Brenda Wallace <shiny@cpan.org> Date: Fri, 28 Jun 2019 09:53:23 +1200 Subject: [PATCH 517/549] Remove pyenv --- .python-version | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .python-version diff --git a/.python-version b/.python-version deleted file mode 100644 index 47b6be3fa..000000000 --- a/.python-version +++ /dev/null @@ -1 +0,0 @@ -3.7.2 \ No newline at end of file From 087034287144988d2ffdc33186f75ec92bbc170a Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 28 Jun 2019 07:19:57 +0000 Subject: [PATCH 518/549] Bump capybara from 3.24.0 to 3.25.0 Bumps [capybara](https://github.com/teamcapybara/capybara) from 3.24.0 to 3.25.0. - [Release notes](https://github.com/teamcapybara/capybara/releases) - [Changelog](https://github.com/teamcapybara/capybara/blob/master/History.md) - [Commits](https://github.com/teamcapybara/capybara/compare/3.24.0...3.25.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index d349d91e6..2298b6deb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -86,7 +86,7 @@ GEM uniform_notifier (~> 1.11) byebug (11.0.1) cancancan (3.0.1) - capybara (3.24.0) + capybara (3.25.0) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) From ce60d6bb0c679e5f44c4ec358dc2a88ef841a1f4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Sun, 30 Jun 2019 13:55:53 +1200 Subject: [PATCH 519/549] Remove stray \n in translation --- config/locales/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 80dfbee70..84fdc92a9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -132,7 +132,7 @@ en: already_html: Or %{sign_in} if you already have an account intro: > %{site_name} is a community of food gardeners. We're building an open source platform to help you learn about growing food, - track what you plant and harvest, and swap seeds and produce with other gardeners near you.\n" + track what you plant and harvest, and swap seeds and produce with other gardeners near you. perks: Join now for your free garden journal, harvest predictions, forums, and more. sign_in_linktext: sign in sign_up: Sign up From 97028bdf1d7adf085b9cd9e08ac4d12918a0ce86 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Sun, 30 Jun 2019 13:34:08 +1200 Subject: [PATCH 520/549] Refactoring member profile spec to use shared example so we can test the page both signed in and not signed in --- spec/features/members/profile_spec.rb | 91 +++++++++++---------------- 1 file changed, 37 insertions(+), 54 deletions(-) diff --git a/spec/features/members/profile_spec.rb b/spec/features/members/profile_spec.rb index 057e96925..0f4cf4087 100644 --- a/spec/features/members/profile_spec.rb +++ b/spec/features/members/profile_spec.rb @@ -1,9 +1,12 @@ require 'rails_helper' describe "member profile", js: true do - context "signed out member" do - let(:member) { create :member } + let(:member) { create :member } + let(:other_member) { create :member } + let(:admin_member) { create :admin_member } + let(:crop_wrangler) { create :crop_wrangling_member } + shared_examples 'member details' do it "basic details on member profile page" do visit member_path(member) expect(page).to have_content("All about #{member.login_name}") @@ -11,13 +14,6 @@ describe "member profile", js: true do expect(page).to have_content "Member since #{member.created_at.to_s(:date)}" end - it "no bio" do - member.bio = nil - member.save - visit member_path(member) - expect(page).to have_content "hasn't written a bio yet" - end - it "gravatar" do visit member_path(member) expect(page).to have_css "img.avatar" @@ -52,18 +48,6 @@ describe "member profile", js: true do end end - context "email privacy" do - it "public email address" do - public_member = create :public_member - visit member_path(public_member) - expect(page).to have_content public_member.email - end - it "private email address" do - visit member_path(member) - expect(page).not_to have_content member.email - end - end - context "activity stats" do it "with no activity" do visit member_path(member) @@ -98,31 +82,41 @@ describe "member profile", js: true do visit member_path(member) expect(page).to have_link flickr_auth.name, href: "http://flickr.com/photos/#{flickr_auth.uid}" end + + describe 'user role labels' do + describe "admin user's page" do + before { visit member_path(admin_member) } + it { expect(page).to have_text "Admin" } + end + + it "crop wrangler's page" do + visit member_path(crop_wrangler) + expect(page).to have_text "Crop Wrangler" + end + + it "ordinary user's page" do + visit member_path(other_member) + expect(page).not_to have_text "Crop Wrangler" + expect(page).not_to have_text "Admin" + end + end + end + + context "not signed in" do + include_examples 'member details' + + it "no bio" do + member.update! bio: nil + visit member_path(member) + expect(page).to have_content "hasn't written a bio yet" + end end context "signed in member" do - let(:member) { create :member } - let(:other_member) { create :member } - let(:admin_member) { create :admin_member } - let(:crop_wrangler) { create :crop_wrangling_member } - before { login_as(member) } - it "admin user's page" do - visit member_path(admin_member) - expect(page).to have_text "Admin" - end - - it "crop wrangler's page" do - visit member_path(crop_wrangler) - expect(page).to have_text "Crop Wrangler" - end - - it "ordinary user's page" do - visit member_path(other_member) - expect(page).not_to have_text "Crop Wrangler" - expect(page).not_to have_text "Admin" - end + include_examples 'member details' + include_examples 'member activity' context "your own profile page" do before { visit member_path(member) } @@ -133,23 +127,12 @@ describe "member profile", js: true do end context "someone else's profile page" do - before do - visit member_path(other_member) - end + before { visit member_path(other_member) } it "has a private message button" do expect(page).to have_link "Send message", href: new_notification_path(recipient_id: other_member.id) end - end - - context "home page" do - before do - visit root_path - end - - it "does not have a button to edit profile" do - expect(page).not_to have_link "Edit profile", href: edit_member_registration_path - end + it { expect(page).not_to have_link "Edit profile", href: edit_member_registration_path } end end end From bf6cb5352d7f37dbc49ad6281f68cb41fc9612af Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Sun, 30 Jun 2019 13:35:41 +1200 Subject: [PATCH 521/549] Test for displaying plantings on profile page --- spec/features/members/profile_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/features/members/profile_spec.rb b/spec/features/members/profile_spec.rb index 0f4cf4087..6bb0901aa 100644 --- a/spec/features/members/profile_spec.rb +++ b/spec/features/members/profile_spec.rb @@ -102,8 +102,23 @@ describe "member profile", js: true do end end + shared_examples 'member activity' do + context 'member has plantings' do + let!(:new_planting) { FactoryBot.create :planting, owner: member, planted_at: Time.zone.now } + let!(:old_planting) { FactoryBot.create :planting, owner: member, planted_at: 3.years.ago } + let!(:finished_planting) { FactoryBot.create :finished_planting, owner: member } + let!(:no_planted_at_planting) { FactoryBot.create :planting, owner: member, planted_at: nil } + before { visit member_path(member) } + it { expect(page).to have_link href: planting_path(new_planting) } + it { expect(page).to have_link href: planting_path(old_planting) } + it { expect(page).to have_link href: planting_path(finished_planting) } + it { expect(page).to have_link href: planting_path(no_planted_at_planting) } + end + end + context "not signed in" do include_examples 'member details' + include_examples 'member activity' it "no bio" do member.update! bio: nil From d37c4139a638c134c74a20a481f6c13cd27b9846 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Sun, 30 Jun 2019 13:39:14 +1200 Subject: [PATCH 522/549] Fixes error displaying plantings with no planted_at date --- app/views/members/show.html.haml | 6 +++++- spec/features/members/profile_spec.rb | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 999b90f22..eb6867759 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -122,4 +122,8 @@ - else = link_to event.event_type, event - %small #{time_ago_in_words(event.event_at)} ago + %small + - if event.event_at.present? + #{time_ago_in_words(event.event_at)} ago + - else + unknown date diff --git a/spec/features/members/profile_spec.rb b/spec/features/members/profile_spec.rb index 6bb0901aa..ca07b3312 100644 --- a/spec/features/members/profile_spec.rb +++ b/spec/features/members/profile_spec.rb @@ -113,6 +113,7 @@ describe "member profile", js: true do it { expect(page).to have_link href: planting_path(old_planting) } it { expect(page).to have_link href: planting_path(finished_planting) } it { expect(page).to have_link href: planting_path(no_planted_at_planting) } + it { expect(page).to have_text 'unknown date'} end end From 4f59ef2e4314694e49aae7612ee861ac5274c6aa Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Sun, 30 Jun 2019 13:44:21 +1200 Subject: [PATCH 523/549] more profile page specs --- spec/features/members/profile_spec.rb | 28 ++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/spec/features/members/profile_spec.rb b/spec/features/members/profile_spec.rb index ca07b3312..2a1d4eff3 100644 --- a/spec/features/members/profile_spec.rb +++ b/spec/features/members/profile_spec.rb @@ -113,7 +113,33 @@ describe "member profile", js: true do it { expect(page).to have_link href: planting_path(old_planting) } it { expect(page).to have_link href: planting_path(finished_planting) } it { expect(page).to have_link href: planting_path(no_planted_at_planting) } - it { expect(page).to have_text 'unknown date'} + it { expect(page).to have_text 'unknown date' } + end + + context 'member has seeds' do + let!(:seed) { FactoryBot.create :seed, owner: member } + before { visit member_path(member) } + it { expect(page).to have_link href: seed_path(seed) } + end + + context 'member has harvests' do + let!(:harvest) { FactoryBot.create :harvest, owner: member } + before { visit member_path(member) } + it { expect(page).to have_link href: harvest_path(harvest) } + end + + context 'member has posts' do + let!(:post) { FactoryBot.create :post, author: member } + before { visit member_path(member) } + it { expect(page).to have_link href: post_path(post) } + end + + context 'photos' do + let(:planting) { FactoryBot.create :planting, owner: member } + let!(:photo) { FactoryBot.create :photo, owner: member, plantings: [planting] } + before { visit member_path(member) } + it { expect(page).to have_link href: photo_path(photo) } + it { expect(page).to have_link href: planting_path(planting) } end end From b56771f9b70ec2c681a70538ee6563df4e2bd823 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Sun, 30 Jun 2019 13:50:10 +1200 Subject: [PATCH 524/549] specs for comments on profile pages --- spec/features/members/profile_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/features/members/profile_spec.rb b/spec/features/members/profile_spec.rb index 2a1d4eff3..573b0398a 100644 --- a/spec/features/members/profile_spec.rb +++ b/spec/features/members/profile_spec.rb @@ -134,6 +134,14 @@ describe "member profile", js: true do it { expect(page).to have_link href: post_path(post) } end + context 'member has comments' do + let(:post) { FactoryBot.create :post } + let!(:comment) { FactoryBot.create :comment, post: post, author: member } + before { visit member_path(member) } + it { expect(page).to have_link href: post_path(post) } + it { expect(page).to have_link href: comment_path(comment) } + end + context 'photos' do let(:planting) { FactoryBot.create :planting, owner: member } let!(:photo) { FactoryBot.create :photo, owner: member, plantings: [planting] } From fda4d88e5aeb787c8ab0e4554dbb920f4a4c27bf Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Tue, 2 Jul 2019 16:23:21 +1200 Subject: [PATCH 525/549] Fix up locale spec --- app/views/home/index.html.haml | 2 +- config/locales/en.yml | 1 - spec/features/locale_spec.rb | 4 ++++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 8e9ec3a6f..180753ca5 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -12,7 +12,7 @@ .row .col-xl-8.col-md-12 %section.crops - %h2= t('home.blurb.some_of_our_crops') + %h2= t('home.crop.our_crops') .homepage-cards= render 'crops' .align-bottom %p.text-right= link_to "#{t('home.crops.view_all')} »", crops_path, class: 'btn btn-block' diff --git a/config/locales/en.yml b/config/locales/en.yml index 84fdc92a9..627762143 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -136,7 +136,6 @@ en: perks: Join now for your free garden journal, harvest predictions, forums, and more. sign_in_linktext: sign in sign_up: Sign up - some_of_our_crops: Some of our crops crops: our_crops: Some of our crops recently_added: Recently added crops diff --git a/spec/features/locale_spec.rb b/spec/features/locale_spec.rb index 863fac079..a5ab43208 100644 --- a/spec/features/locale_spec.rb +++ b/spec/features/locale_spec.rb @@ -3,8 +3,12 @@ require 'rails_helper' describe "Changing locales", js: true do after { I18n.locale = :en } + let(:member) { FactoryBot.create :member } it "Locale can be set with a query param" do + # Login then log out, to ensure we're now logged out + login_as member visit root_path + click_link 'Sign out' expect(page).to have_content("a community of food gardeners.") visit root_path(locale: 'ja') expect(page).to have_content("はガーデナーのコミュニティです。") From 67239ec8b1c4db009154c0b5640be97d6b2d292c Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Tue, 2 Jul 2019 16:31:26 +1200 Subject: [PATCH 526/549] rubocop fixup --- spec/features/locale_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/locale_spec.rb b/spec/features/locale_spec.rb index a5ab43208..dd912f5e8 100644 --- a/spec/features/locale_spec.rb +++ b/spec/features/locale_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe "Changing locales", js: true do after { I18n.locale = :en } - let(:member) { FactoryBot.create :member } + let(:member) { FactoryBot.create :member } it "Locale can be set with a query param" do # Login then log out, to ensure we're now logged out login_as member From 5ad298e43a7708a0ae2de2dedab80c5f2177e9f1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Tue, 2 Jul 2019 16:41:17 +1200 Subject: [PATCH 527/549] TYPO! --- app/views/home/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 180753ca5..00c544ade 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -12,7 +12,7 @@ .row .col-xl-8.col-md-12 %section.crops - %h2= t('home.crop.our_crops') + %h2= t('home.crops.our_crops') .homepage-cards= render 'crops' .align-bottom %p.text-right= link_to "#{t('home.crops.view_all')} »", crops_path, class: 'btn btn-block' From ad888575a5f5b9f219585cc08f9887073043718b Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Sun, 30 Jun 2019 14:05:15 +1200 Subject: [PATCH 528/549] Upgrade boostrap gem --- Gemfile | 2 +- Gemfile.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index af27eae7c..c16f8fcf9 100644 --- a/Gemfile +++ b/Gemfile @@ -16,7 +16,7 @@ gem 'sass-rails' gem 'jsonapi-resources' # CSS framework -gem 'bootstrap', '4.1.1' +gem "bootstrap", ">= 4.3.1" gem 'material-sass', '4.1.1' # Icons used by bootstrap/material-sass diff --git a/Gemfile.lock b/Gemfile.lock index 2298b6deb..685abdc0d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -68,10 +68,10 @@ GEM bonsai-elasticsearch-rails (7.0.1) elasticsearch-model (< 8) elasticsearch-rails (< 8) - bootstrap (4.1.1) - autoprefixer-rails (>= 6.0.3) - popper_js (>= 1.12.9, < 2) - sass (>= 3.5.2) + bootstrap (4.3.1) + autoprefixer-rails (>= 9.1.0) + popper_js (>= 1.14.3, < 2) + sassc-rails (>= 2.0.0) bootstrap-datepicker-rails (1.8.0.1) railties (>= 3.0) bootstrap-kaminari-views (0.0.5) @@ -574,7 +574,7 @@ DEPENDENCIES better_errors bluecloth bonsai-elasticsearch-rails - bootstrap (= 4.1.1) + bootstrap (>= 4.3.1) bootstrap-datepicker-rails bootstrap-kaminari-views bootstrap_form (>= 4.2.0) From 13450f64ed013f8982289b13b424634293a119d1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Tue, 2 Jul 2019 16:53:26 +1200 Subject: [PATCH 529/549] Squish a devise deprecation warning --- app/views/devise/confirmations/new.html.haml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/devise/confirmations/new.html.haml b/app/views/devise/confirmations/new.html.haml index a17ab86a9..c3e1867ac 100644 --- a/app/views/devise/confirmations/new.html.haml +++ b/app/views/devise/confirmations/new.html.haml @@ -5,8 +5,7 @@ = form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post, class: 'form-horizontal', role: 'form' }) do |f| - = devise_error_messages! - + = render 'devise/shared/error_messages', resource: resource %p Enter either your login name or your email address to resend the confirmation email. = f.text_field :login, class: 'form-control', placeholder: 'email or login name' From 036fea1c03f7a132293634b807cf688796e8f748 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 3 Jul 2019 08:16:46 +1200 Subject: [PATCH 530/549] Fix scss compile error, by using our own variable --- app/assets/stylesheets/_variables.scss | 2 ++ app/assets/stylesheets/application.scss | 1 - app/assets/stylesheets/overrides.scss | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/_variables.scss b/app/assets/stylesheets/_variables.scss index 60c7d6096..8638d8ba3 100644 --- a/app/assets/stylesheets/_variables.scss +++ b/app/assets/stylesheets/_variables.scss @@ -74,3 +74,5 @@ $navbar-default-brand-color: lighten($green, 20%); // $dropdown-link-color: $brown; // $dropdown-link-hover-color: $brown; // $dropdown-link-hover-bg: lighten($green, 50%); + +$highest-level: 1070; \ No newline at end of file diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 1c9cbbbda..818e0f4ca 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -2,7 +2,6 @@ @import 'variables'; @import 'material'; -@import 'bootstrap/variables'; @import 'jquery-ui/autocomplete'; @import 'bootstrap-datepicker'; diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index b0e9c7021..c858e6b09 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -292,7 +292,7 @@ body { // Autosuggest .ui-autocomplete { background: $white; - z-index: $zindex-tooltip + z-index: $highest-level; } .alert { From b90f6d5ff642127a846448e60cea52b25de123e9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 3 Jul 2019 08:20:58 +1200 Subject: [PATCH 531/549] Tidy up facts on plantings#show --- app/views/plantings/_facts.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/plantings/_facts.haml b/app/views/plantings/_facts.haml index 15eeb303a..480595bde 100644 --- a/app/views/plantings/_facts.haml +++ b/app/views/plantings/_facts.haml @@ -1,4 +1,4 @@ -.card-deck.mx-auto.planting-facts +.index-cards.planting-facts - if planting.parent_seed .card.planting-fact-card %h3 Parent seed From 8c02ea943a569dddc7e2c83bb7fc2e0d8021e4cf Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 3 Jul 2019 08:25:23 +1200 Subject: [PATCH 532/549] Tidy up photo display (line up) --- app/assets/stylesheets/overrides.scss | 2 +- app/views/crops/_photos.html.haml | 6 ++---- app/views/photos/_gallery.haml | 5 +++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index c858e6b09..514ecf53b 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -85,7 +85,7 @@ h3 { flex-wrap: wrap; .card { - margin: 1em; + margin: 1em 1em 1em 0; width: 200px; } } diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index 1151e330d..170867ed8 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -2,10 +2,8 @@ %h2 #{photo_icon} Photos - [Planting, Harvest, Seed].each do |model_name| - if photos.by_model(model_name).size.positive? - .crop-photos - %h3 #{@crop.name.capitalize} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} - .index-cards - = render 'photos/gallery', photos: photos.by_model(model_name).limit(8) + %h3 #{@crop.name.capitalize} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} + = render 'photos/gallery', photos: photos.by_model(model_name).limit(8) = link_to 'more photos »', crop_photos_path(@crop), class: 'btn' %hr/ diff --git a/app/views/photos/_gallery.haml b/app/views/photos/_gallery.haml index b61ebe7b1..98bed3450 100644 --- a/app/views/photos/_gallery.haml +++ b/app/views/photos/_gallery.haml @@ -1,3 +1,4 @@ -- photos.each do |photo| - .photo-grid-item= render 'photos/card', photo: photo +.index-cards + - photos.each do |photo| + .photo-grid-item= render 'photos/card', photo: photo From 50945c6f75b6c7bf61fe31c755ea2bcd0127c069 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 3 Jul 2019 08:41:23 +1200 Subject: [PATCH 533/549] Files should end with a trailing newline --- app/assets/stylesheets/_variables.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/_variables.scss b/app/assets/stylesheets/_variables.scss index 8638d8ba3..823aa54b8 100644 --- a/app/assets/stylesheets/_variables.scss +++ b/app/assets/stylesheets/_variables.scss @@ -75,4 +75,4 @@ $navbar-default-brand-color: lighten($green, 20%); // $dropdown-link-hover-color: $brown; // $dropdown-link-hover-bg: lighten($green, 50%); -$highest-level: 1070; \ No newline at end of file +$highest-level: 1070; From 4495d038996938014ea503c64a837ca7a60671e0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 3 Jul 2019 08:48:35 +1200 Subject: [PATCH 534/549] Move percy specs to static check run --- .travis.yml | 4 ++-- script/percy.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 26620876f..00965aafa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,9 +14,9 @@ addons: secure: "PfhLGBKRgNqhKuYCJsK+VPhdAzcgWFGeeOyxC/eS8gtlvIISVdgyZE+r30uIei0DFI6zEiN62eW4d+xtT4j7/e2ZcAcx7U52mza/SnQNuu3nCGQDJB8VOvV5NbnwXfi8vfr4e889Mt7k3ocd2c4gqB4UtRqrzhygj7HN+B/GfEk=" env: matrix: - - GROWSTUFF_ELASTICSEARCH=true RSPEC_TAG=elasticsearch COVERAGE=true PERCY_CHECKS=true + - GROWSTUFF_ELASTICSEARCH=true RSPEC_TAG=elasticsearch COVERAGE=true - GROWSTUFF_ELASTICSEARCH=false RSPEC_TAG=~elasticsearch COVERAGE=false - - STATIC_CHECKS=true + - STATIC_CHECKS=true PERCY_CHECKS=true global: - secure: "Z5TpM2jEX4UCvNePnk/LwltQX48U2u9BRc+Iypr1x9QW2o228QJhPIOH39a8RMUrepGnkQIq9q3ZRUn98RfrJz1yThtlNFL3NmzdQ57gKgjGwfpa0e4Dwj/ZJqV2D84tDGjvdVYLP7zzaYZxQcwk/cgNpzKf/jq97HLNP7CYuf4=" - GROWSTUFF_EMAIL="noreply@test.growstuff.org" diff --git a/script/percy.sh b/script/percy.sh index f2a6563b0..31ee472a1 100755 --- a/script/percy.sh +++ b/script/percy.sh @@ -1,3 +1,3 @@ #!/bin/bash bundle exec rails assets:precompile -PERCY_TARGET_BRANCH=dev npx percy exec -- bundle exec rspec spec/features/ +npx percy exec -- bundle exec rspec spec/features/percy/ From 9e1415deddc73c79aaeecfd126574355cf63005c Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 3 Jul 2019 08:54:08 +1200 Subject: [PATCH 535/549] fixes flex/wrap on home page members --- app/views/home/_members.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/home/_members.html.haml b/app/views/home/_members.html.haml index 5bc8b27b4..dca9fff72 100644 --- a/app/views/home/_members.html.haml +++ b/app/views/home/_members.html.haml @@ -3,7 +3,7 @@ - members = Member.includes(plantings: :crop).interesting.first(6) - if members.present? %h2.text-center= t('.title') - .member-cards + .member-cards.index-cards = render members %p.text-right From a18ff035998e726ec37df5e23713224500ec395c Mon Sep 17 00:00:00 2001 From: Miles Gould <miles@assyrian.org.uk> Date: Tue, 2 Jul 2019 10:49:09 +0100 Subject: [PATCH 536/549] Fix remaining uses of devise_error_messages! --- app/views/devise/passwords/edit.html.haml | 2 +- app/views/devise/passwords/new.html.haml | 2 +- app/views/devise/registrations/_delete.html.haml | 2 +- app/views/devise/registrations/_edit_apps.html.haml | 2 +- app/views/devise/registrations/_edit_email.html.haml | 2 +- app/views/devise/registrations/_edit_password.html.haml | 2 +- app/views/devise/registrations/_edit_profile.html.haml | 2 +- app/views/devise/registrations/new.html.haml | 2 +- app/views/devise/unlocks/new.html.haml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/devise/passwords/edit.html.haml b/app/views/devise/passwords/edit.html.haml index f1f73875c..70ed8b1b3 100644 --- a/app/views/devise/passwords/edit.html.haml +++ b/app/views/devise/passwords/edit.html.haml @@ -3,7 +3,7 @@ = form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put, class: 'form-horizontal', role: 'form' }) do |f| - = devise_error_messages! + = render 'devise/shared/error_messages', resource: resource = f.hidden_field :reset_password_token .form-group diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml index f7ee373db..1c2f57872 100644 --- a/app/views/devise/passwords/new.html.haml +++ b/app/views/devise/passwords/new.html.haml @@ -6,7 +6,7 @@ url: password_path(resource_name), html: { method: :post, class: 'text-center border border-light p-5', role: 'form' }) do |f| - = devise_error_messages! + = render 'devise/shared/error_messages', resource: resource = f.text_field :login, class: "form-control mb-4", placeholder: "E-mail", type: "email" = f.submit "Send me reset password instructions", class: 'btn btn-block my-4 btn-primary' diff --git a/app/views/devise/registrations/_delete.html.haml b/app/views/devise/registrations/_delete.html.haml index 4dbbf18b8..cbe5263c4 100644 --- a/app/views/devise/registrations/_delete.html.haml +++ b/app/views/devise/registrations/_delete.html.haml @@ -1,6 +1,6 @@ = form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :delete, class: 'form-horizontal' }) do |f| %br/ - = devise_error_messages! + = render 'devise/shared/error_messages', resource: resource .form-group = f.label :current_password, "Password required to delete", class: 'control-label col-md-2' diff --git a/app/views/devise/registrations/_edit_apps.html.haml b/app/views/devise/registrations/_edit_apps.html.haml index 924a0db8a..05e9546c2 100644 --- a/app/views/devise/registrations/_edit_apps.html.haml +++ b/app/views/devise/registrations/_edit_apps.html.haml @@ -2,7 +2,7 @@ url: registration_path(resource_name), html: { method: :put, class: 'form-horizontal' }) do |_f| %br/ - = devise_error_messages! + = render 'devise/shared/error_messages', resource: resource .row .col-md-12 diff --git a/app/views/devise/registrations/_edit_email.html.haml b/app/views/devise/registrations/_edit_email.html.haml index c72237693..204a558e1 100644 --- a/app/views/devise/registrations/_edit_email.html.haml +++ b/app/views/devise/registrations/_edit_email.html.haml @@ -2,7 +2,7 @@ url: registration_path(resource_name), html: { method: :put, class: 'form-horizontal' }) do |f| %br/ - = devise_error_messages! + = render 'devise/shared/error_messages', resource: resource .form-group = f.label :email, class: 'control-label col-md-2' diff --git a/app/views/devise/registrations/_edit_password.html.haml b/app/views/devise/registrations/_edit_password.html.haml index 61d608de4..ea2febb30 100644 --- a/app/views/devise/registrations/_edit_password.html.haml +++ b/app/views/devise/registrations/_edit_password.html.haml @@ -2,7 +2,7 @@ url: registration_path(resource_name), html: { method: :put, class: 'form-horizontal' }) do |f| %br/ - = devise_error_messages! + = render 'devise/shared/error_messages', resource: resource .form-group = f.label :current_password, class: 'control-label col-md-2' diff --git a/app/views/devise/registrations/_edit_profile.html.haml b/app/views/devise/registrations/_edit_profile.html.haml index 2550dc1ad..054570f66 100644 --- a/app/views/devise/registrations/_edit_profile.html.haml +++ b/app/views/devise/registrations/_edit_profile.html.haml @@ -2,7 +2,7 @@ url: registration_path(resource_name), html: { method: :put, class: 'form-horizontal' }) do |f| %br/ - = devise_error_messages! + = render 'devise/shared/error_messages', resource: resource .form-group = f.label :location, 'Your location', class: 'control-label col-md-2' diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index 9535996e7..dd8f93080 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -6,7 +6,7 @@ = bootstrap_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { class: "text-center border border-light p-5" }) do |f| - = devise_error_messages! + = render 'devise/shared/error_messages', resource: resource = f.text_field :login_name %span This is the name that will show on the website. diff --git a/app/views/devise/unlocks/new.html.haml b/app/views/devise/unlocks/new.html.haml index 5d1023a6a..fbc799e7a 100644 --- a/app/views/devise/unlocks/new.html.haml +++ b/app/views/devise/unlocks/new.html.haml @@ -8,7 +8,7 @@ role: 'form' }) do |f| %h2 Resend unlock instructions - = devise_error_messages! + = render 'devise/shared/error_messages', resource: resource = f.email_field :email, class: 'form-control', placeholder: 'Email' = f.submit "Resend unlock instructions", class: 'btn btn-block my-4 btn-primary' From 52b6ab393112da0a6ecec41f81239cb0ac5ecf7a Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 3 Jul 2019 12:04:13 +1200 Subject: [PATCH 537/549] Output and stop on error --- script/percy.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/script/percy.sh b/script/percy.sh index 31ee472a1..d305197f4 100755 --- a/script/percy.sh +++ b/script/percy.sh @@ -1,3 +1,4 @@ #!/bin/bash +set -euv bundle exec rails assets:precompile npx percy exec -- bundle exec rspec spec/features/percy/ From b0a47f1319af72b7c080b454f225432ed44992ff Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 3 Jul 2019 07:26:50 +0000 Subject: [PATCH 538/549] Bump webdrivers from 4.0.1 to 4.1.0 Bumps [webdrivers](https://github.com/titusfortner/webdrivers) from 4.0.1 to 4.1.0. - [Release notes](https://github.com/titusfortner/webdrivers/releases) - [Changelog](https://github.com/titusfortner/webdrivers/blob/master/CHANGELOG.md) - [Commits](https://github.com/titusfortner/webdrivers/compare/v4.0.1...v4.1.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2298b6deb..d21e4837a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -546,7 +546,7 @@ GEM uniform_notifier (1.12.1) warden (1.2.8) rack (>= 2.0.6) - webdrivers (4.0.1) + webdrivers (4.1.0) nokogiri (~> 1.6) rubyzip (~> 1.0) selenium-webdriver (>= 3.0, < 4.0) From ac914508272b9302e605deb3afe9a271c5ff8752 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 3 Jul 2019 13:03:16 +1200 Subject: [PATCH 539/549] Fixes count on members'cards --- app/helpers/application_helper.rb | 4 +--- app/views/members/_member.haml | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b86731d7e..97ca00136 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -60,9 +60,7 @@ module ApplicationHelper # Returns a string with the quantity and the right pluralization for a # given collection and model. def localize_plural(collection, model) - size = collection.size - model_name = model.model_name.human(count: size) - "#{size} #{model_name}" + pluralize(collection.size, model.model_name.to_s) end def show_inactive_tickbox_path(type, owner, show_all) diff --git a/app/views/members/_member.haml b/app/views/members/_member.haml index 6b9f6e262..2cb2b88e3 100644 --- a/app/views/members/_member.haml +++ b/app/views/members/_member.haml @@ -19,10 +19,10 @@ %ul.nav.nav-justified.small %li.nav-item.border-right = link_to member_plantings_path(member) do - = localize_plural(member.plantings.active.size, Planting) + = localize_plural(member.plantings.active, Planting) %li.nav-item.border-right = link_to member_harvests_path(member) do - = localize_plural(member.harvests.size, Harvest) + = localize_plural(member.harvests, Harvest) %li.nav-item = link_to member_seeds_path(member) do - = localize_plural(member.seeds.active.size, Seed) + = localize_plural(member.seeds.active, Seed) From ea18c722efdbb079eaaedca8664358f6cc456026 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 3 Jul 2019 18:10:08 +1200 Subject: [PATCH 540/549] lower caseon pluralizing --- app/helpers/application_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 97ca00136..8f2a971bc 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -60,7 +60,7 @@ module ApplicationHelper # Returns a string with the quantity and the right pluralization for a # given collection and model. def localize_plural(collection, model) - pluralize(collection.size, model.model_name.to_s) + pluralize(collection.size, model.model_name.downcase.to_s) end def show_inactive_tickbox_path(type, owner, show_all) From d53393b0cad3b8f98bc0f9a56c9b608fd6330409 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 3 Jul 2019 20:36:08 +1200 Subject: [PATCH 541/549] Fix downcase --- app/helpers/application_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8f2a971bc..29f0ab05b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -60,7 +60,7 @@ module ApplicationHelper # Returns a string with the quantity and the right pluralization for a # given collection and model. def localize_plural(collection, model) - pluralize(collection.size, model.model_name.downcase.to_s) + pluralize(collection.size, model.model_name.to_s.downcase) end def show_inactive_tickbox_path(type, owner, show_all) From 0fa6fa9e5a4597f90e77c743d7af64d3f13bc905 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jul 2019 10:51:41 +0000 Subject: [PATCH 542/549] Bump js-yaml from 3.12.1 to 3.13.1 Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 3.12.1 to 3.13.1. - [Release notes](https://github.com/nodeca/js-yaml/releases) - [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md) - [Commits](https://github.com/nodeca/js-yaml/compare/3.12.1...3.13.1) Signed-off-by: dependabot[bot] <support@github.com> --- yarn.lock | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/yarn.lock b/yarn.lock index 04a8423e3..6c633e033 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1349,7 +1349,7 @@ js-tokens@^3.0.2: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls= -js-yaml@^3.13.1: +js-yaml@^3.13.1, js-yaml@^3.9.1: version "3.13.1" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== @@ -1357,14 +1357,6 @@ js-yaml@^3.13.1: argparse "^1.0.7" esprima "^4.0.0" -js-yaml@^3.9.1: - version "3.12.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.1.tgz#295c8632a18a23e054cf5c9d3cecafe678167600" - integrity sha512-um46hB9wNOKlwkHgiuyEVAybXBjwFUV0Z/RaHJblRd9DXltue9FTYvzCr9ErQrK9Adz5MU4gHWVaNUfdmrC8qA== - dependencies: - argparse "^1.0.7" - esprima "^4.0.0" - jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" From 826c8845a2915962379d877c31814fc021a7670f Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 3 Jul 2019 13:05:53 +1200 Subject: [PATCH 543/549] Removing commented out cruft --- app/assets/stylesheets/_variables.scss | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/app/assets/stylesheets/_variables.scss b/app/assets/stylesheets/_variables.scss index 60c7d6096..8505a0e82 100644 --- a/app/assets/stylesheets/_variables.scss +++ b/app/assets/stylesheets/_variables.scss @@ -43,23 +43,6 @@ $dark: ( light: lighten($brown, 20%) ); - -// $font-family-sans-serif: "Helvetica Neue", Helvetica, Arial, sans-serif; -// $font-family-serif: Georgia, "Times New Roman", Times, serif; -// $font-family-mono: Monaco, Menlo, Consolas, "Courier New", monospace; - -// $font-size-base: 14px; -// $font-family-base: $font-family-sans-serif; -// $line-height-base: 1.5; -// $alt-font-family: $font-family-serif; - -// $headings-font-family: $font-family-sans-serif; -// $headings-font-weight: bold; -// $headings-color: inherit; - -// // Hero unit -// $jumbotron-bg: darken($body-bg, 10%); - // Nav bar $navbar-default-bg: $brown; $navbar-default-bg-highlight: $brown; @@ -68,9 +51,3 @@ $navbar-default-link-color: darken($beige, 20%); $navbar-default-link-hover-color: $beige; $navbar-default-link-active-color: darken($beige, 80%); $navbar-default-brand-color: lighten($green, 20%); - -// // Top nav collapse threshold - -// $dropdown-link-color: $brown; -// $dropdown-link-hover-color: $brown; -// $dropdown-link-hover-bg: lighten($green, 50%); From 136aff87ac0e8c6ca0149bc04958324b75859f79 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Wed, 3 Jul 2019 13:06:35 +1200 Subject: [PATCH 544/549] Removign empty class in scss --- app/assets/stylesheets/overrides.scss | 9 --------- 1 file changed, 9 deletions(-) diff --git a/app/assets/stylesheets/overrides.scss b/app/assets/stylesheets/overrides.scss index b0e9c7021..22c45fa52 100755 --- a/app/assets/stylesheets/overrides.scss +++ b/app/assets/stylesheets/overrides.scss @@ -69,15 +69,6 @@ h3 { } } } -.navbar .navbar-form { -// padding-top: 0; -// padding-bottom: 0; -// margin-right: 0; -// margin-left: 15px; -// border: 0; -// -webkit-box-shadow: none; -// box-shadow: none; -} .index-cards { display: flex; From b483c47258106b5813e628939b222a2d29eb1e4b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2019 07:16:52 +0000 Subject: [PATCH 545/549] Bump faker from 1.9.4 to 1.9.5 Bumps [faker](https://github.com/stympy/faker) from 1.9.4 to 1.9.5. - [Release notes](https://github.com/stympy/faker/releases) - [Changelog](https://github.com/stympy/faker/blob/master/CHANGELOG.md) - [Commits](https://github.com/stympy/faker/compare/1.9.4...v.1.9.5) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> --- Gemfile.lock | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e792aaf6f..2dfa37637 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -162,7 +162,6 @@ GEM elasticsearch-transport (6.8.0) faraday multi_json - equatable (0.6.1) erubi (1.8.0) erubis (2.7.0) excon (0.64.0) @@ -172,13 +171,8 @@ GEM factory_bot_rails (5.0.2) factory_bot (~> 5.0.2) railties (>= 4.2.0) - faker (1.9.4) + faker (1.9.5) i18n (>= 0.7) - pastel (~> 0.7.2) - thor (~> 0.20.0) - tty-pager (~> 0.12.0) - tty-screen (~> 0.6.5) - tty-tree (~> 0.3.0) faraday (0.15.4) multipart-post (>= 1.2, < 3) ffi (1.11.1) @@ -350,9 +344,6 @@ GEM activerecord (>= 4.0, < 6.1) parser (2.6.3.0) ast (~> 2.4.0) - pastel (0.7.3) - equatable (~> 0.6) - tty-color (~> 0.5) percy-capybara (4.0.1) pg (0.21.0) platform-api (2.2.0) @@ -506,11 +497,6 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - strings (0.1.5) - strings-ansi (~> 0.1) - unicode-display_width (~> 1.5) - unicode_utils (~> 1.4) - strings-ansi (0.1.0) sysexits (1.2.0) temple (0.8.1) term-ansicolor (1.7.1) @@ -523,14 +509,6 @@ GEM timecop (0.9.1) tins (1.20.3) trollop (1.16.2) - tty-color (0.5.0) - tty-pager (0.12.1) - strings (~> 0.1.4) - tty-screen (~> 0.6) - tty-which (~> 0.4) - tty-screen (0.6.5) - tty-tree (0.3.0) - tty-which (0.4.1) tzinfo (1.2.5) thread_safe (~> 0.1) uglifier (4.1.20) @@ -539,7 +517,6 @@ GEM unf_ext unf_ext (0.0.7.6) unicode-display_width (1.6.0) - unicode_utils (1.4.0) unicorn (5.5.1) kgio (~> 2.6) raindrops (~> 0.7) From ba1512a85aa432cf75015083b994ffb64544ccd7 Mon Sep 17 00:00:00 2001 From: Miles Gould <miles@assyrian.org.uk> Date: Fri, 5 Jul 2019 11:21:24 +0100 Subject: [PATCH 546/549] Delete duplicate `percentage_grown` attribute Fixes #2031 --- app/resources/api/v1/planting_resource.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/resources/api/v1/planting_resource.rb b/app/resources/api/v1/planting_resource.rb index dce3aaf7d..18f8f23a1 100644 --- a/app/resources/api/v1/planting_resource.rb +++ b/app/resources/api/v1/planting_resource.rb @@ -21,7 +21,6 @@ module Api # Predictions attribute :expected_lifespan attribute :finish_predicted_at - attribute :percentage_grown attribute :first_harvest_date attribute :last_harvest_date From 8528f80678690286a6fea155f88987f8b8921f55 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Fri, 5 Jul 2019 15:05:19 +1200 Subject: [PATCH 547/549] Layout fix up on hompage for large screens --- app/views/home/_discuss.html.haml | 2 +- app/views/home/_members.html.haml | 2 +- app/views/home/_seeds.html.haml | 2 +- app/views/home/index.html.haml | 13 ++++++------- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/views/home/_discuss.html.haml b/app/views/home/_discuss.html.haml index e94445f30..c5c430907 100644 --- a/app/views/home/_discuss.html.haml +++ b/app/views/home/_discuss.html.haml @@ -1,6 +1,6 @@ %h2.text-center= t('.discussion') .list-group - - Post.order(created_at: :desc).limit(3).each do |post| + - Post.order(created_at: :desc).limit(max).each do |post| = link_to post, class: 'list-group-item list-group-item-action flex-column align-items-start' do .d-flex.w-100.justify-content-between %h5.mb-2.h5= truncate(strip_tags(post.subject)) diff --git a/app/views/home/_members.html.haml b/app/views/home/_members.html.haml index dca9fff72..87bd563d9 100644 --- a/app/views/home/_members.html.haml +++ b/app/views/home/_members.html.haml @@ -1,6 +1,6 @@ - cache cache_key_for(Member) do .hidden-xs - - members = Member.includes(plantings: :crop).interesting.first(6) + - members = Member.includes(plantings: :crop).interesting.limit(max) - if members.present? %h2.text-center= t('.title') .member-cards.index-cards diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml index 2bcf0eadb..f01acb725 100644 --- a/app/views/home/_seeds.html.haml +++ b/app/views/home/_seeds.html.haml @@ -1,5 +1,5 @@ - cache cache_key_for(Seed) do %h2.text-center= t('home.seeds.title') .homepage-cards - - Seed.current.tradable.includes(:owner, :crop).order(created_at: :desc).limit(3).each do |seed| + - Seed.current.tradable.includes(:owner, :crop).order(created_at: :desc).limit(max).each do |seed| = render 'seeds/card', seed: seed diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 00c544ade..72e094c0c 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -27,11 +27,10 @@ .col-md-6 = render 'harvests' %p.text-right= link_to "#{t('home.harvests.view_all')} »", harvests_path, class: 'btn btn-block' - - %section.seeds.mx-auto - = render 'seeds' - .align-bottom + .col-md-6 + %section.seeds.mx-auto + = render 'seeds', max: 6 %p.text-right= link_to "#{t('home.seeds.view_all')} »", seeds_path, class: 'btn btn-block' - - %section.members.mx-auto= render 'members' - %section.discussion.mx-auto= render 'discuss' \ No newline at end of file + .col-md-6 + %section.members.mx-auto= render 'members', max: 6 + %section.discussion.mx-auto= render 'discuss', max: 3 \ No newline at end of file From eda77365a5c64070433089c9f6ee40f0b123eaf5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Fri, 5 Jul 2019 15:05:31 +1200 Subject: [PATCH 548/549] truncate long locations --- app/views/members/_location.html.haml | 3 ++- app/views/members/_member.haml | 2 +- app/views/seeds/_card.html.haml | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/members/_location.html.haml b/app/views/members/_location.html.haml index 46dec9fac..3b9a2f647 100644 --- a/app/views/members/_location.html.haml +++ b/app/views/members/_location.html.haml @@ -2,4 +2,5 @@ - if member.location.blank? unknown location - else - = link_to member.location, place_path(member.location, anchor: "members") + = link_to place_path(member.location, anchor: "members") do + = truncate(member.location, length: 40, separator: ' ', omission: '... ') diff --git a/app/views/members/_member.haml b/app/views/members/_member.haml index 2cb2b88e3..3f0746362 100644 --- a/app/views/members/_member.haml +++ b/app/views/members/_member.haml @@ -13,7 +13,7 @@ - if member.location.present? %span.badge.badge-success = icon 'fas', 'map-marker' - = member.location + = truncate(member.location, length: 50, separator: ' ', omission: '... ') %p %ul.nav.nav-justified.small diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index 3d3fe897f..e46e5da8b 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -7,5 +7,6 @@ %span.badge.badge-pill.badge-secondary Will trade #{seed.tradable_to} = link_to seed.owner do .card-footer - %span.badge.badge-pill.badge-secondary=seed.owner.location + %span.badge.badge-pill.badge-secondary + = truncate(seed.owner.location, length: 20, separator: ' ', omission: '... ') = render 'members/tiny', member: seed.owner \ No newline at end of file From cc271b2cc35aede653ec113c593cd2c1bd7f9c8a Mon Sep 17 00:00:00 2001 From: Brenda Wallace <brenda@wallace.net.nz> Date: Sat, 6 Jul 2019 10:43:11 +1200 Subject: [PATCH 549/549] Back out the max homepage items change --- app/views/home/_discuss.html.haml | 2 +- app/views/home/_members.html.haml | 2 +- app/views/home/_seeds.html.haml | 2 +- app/views/home/index.html.haml | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/home/_discuss.html.haml b/app/views/home/_discuss.html.haml index c5c430907..f3359b784 100644 --- a/app/views/home/_discuss.html.haml +++ b/app/views/home/_discuss.html.haml @@ -1,6 +1,6 @@ %h2.text-center= t('.discussion') .list-group - - Post.order(created_at: :desc).limit(max).each do |post| + - Post.order(created_at: :desc).limit(6).each do |post| = link_to post, class: 'list-group-item list-group-item-action flex-column align-items-start' do .d-flex.w-100.justify-content-between %h5.mb-2.h5= truncate(strip_tags(post.subject)) diff --git a/app/views/home/_members.html.haml b/app/views/home/_members.html.haml index 87bd563d9..90d4c7078 100644 --- a/app/views/home/_members.html.haml +++ b/app/views/home/_members.html.haml @@ -1,6 +1,6 @@ - cache cache_key_for(Member) do .hidden-xs - - members = Member.includes(plantings: :crop).interesting.limit(max) + - members = Member.includes(plantings: :crop).interesting.limit(6) - if members.present? %h2.text-center= t('.title') .member-cards.index-cards diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml index f01acb725..bff02e70d 100644 --- a/app/views/home/_seeds.html.haml +++ b/app/views/home/_seeds.html.haml @@ -1,5 +1,5 @@ - cache cache_key_for(Seed) do %h2.text-center= t('home.seeds.title') .homepage-cards - - Seed.current.tradable.includes(:owner, :crop).order(created_at: :desc).limit(max).each do |seed| + - Seed.current.tradable.includes(:owner, :crop).order(created_at: :desc).limit(6).each do |seed| = render 'seeds/card', seed: seed diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 72e094c0c..dd748925f 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -29,8 +29,8 @@ %p.text-right= link_to "#{t('home.harvests.view_all')} »", harvests_path, class: 'btn btn-block' .col-md-6 %section.seeds.mx-auto - = render 'seeds', max: 6 + = render 'seeds' %p.text-right= link_to "#{t('home.seeds.view_all')} »", seeds_path, class: 'btn btn-block' .col-md-6 - %section.members.mx-auto= render 'members', max: 6 - %section.discussion.mx-auto= render 'discuss', max: 3 \ No newline at end of file + %section.members.mx-auto= render 'members' + %section.discussion.mx-auto= render 'discuss' \ No newline at end of file