From 8fa0464249d944e87180eb0ddcc23d71c5230706 Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Mon, 28 Feb 2022 14:41:12 -0800 Subject: [PATCH 01/21] Add back button to forms --- app/views/plants/edit.html.haml | 4 +++- app/views/plants/new.html.haml | 2 ++ app/views/plots/edit.html.haml | 2 ++ app/views/plots/new.html.haml | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/views/plants/edit.html.haml b/app/views/plants/edit.html.haml index 0089acc2..486faa5a 100644 --- a/app/views/plants/edit.html.haml +++ b/app/views/plants/edit.html.haml @@ -1,2 +1,4 @@ -- content_for_title("Edit #{@plant.common_name}") +- content_for_title("Edit #{@plant.common_name.titleize}") +- content_for(:subnav) do + = button_to('« Back', @plant, class: 'button primary', method: 'get') = render partial: 'form' diff --git a/app/views/plants/new.html.haml b/app/views/plants/new.html.haml index 3d7ca828..3da50679 100644 --- a/app/views/plants/new.html.haml +++ b/app/views/plants/new.html.haml @@ -1,2 +1,4 @@ - content_for_title('New Plant') +- content_for(:subnav) do + = button_to('« Plants', plants_path, class: 'button primary', title: 'List of all plants', method: 'get') = render partial: 'form' diff --git a/app/views/plots/edit.html.haml b/app/views/plots/edit.html.haml index 49f83668..81e1f51b 100644 --- a/app/views/plots/edit.html.haml +++ b/app/views/plots/edit.html.haml @@ -1,2 +1,4 @@ - content_for_title("Edit Plot ##{@plot.plot_id}") +- content_for(:subnav) do + = button_to('« Back', @plot, class: 'button primary', title: 'List of all plots', method: 'get') = render partial: 'form' \ No newline at end of file diff --git a/app/views/plots/new.html.haml b/app/views/plots/new.html.haml index c6cead48..6ca2b646 100644 --- a/app/views/plots/new.html.haml +++ b/app/views/plots/new.html.haml @@ -1,2 +1,4 @@ - content_for_title('New Plot') +- content_for(:subnav) do + = button_to('« Plots', plots_path, class: 'button primary', title: 'List of all plots', method: 'get') = render partial: 'form' From 5ad63a2a0e379e88a7db71588a69aa592583dcc7 Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Mon, 28 Feb 2022 15:45:00 -0800 Subject: [PATCH 02/21] Capitalize titles --- app/views/plots/show.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/plots/show.html.haml b/app/views/plots/show.html.haml index df52b65c..3037f4a1 100644 --- a/app/views/plots/show.html.haml +++ b/app/views/plots/show.html.haml @@ -56,10 +56,10 @@ %th{scope: 'row'} Inoculated? %td= @plot.inoculated ? 'Yes' : 'No' %tr - %th{scope: 'row'} Initial planting date + %th{scope: 'row'} Initial Planting Date %td= @plot.initial_planting_date %tr - %th{scope: 'row'} Initial succession + %th{scope: 'row'} Initial Succession %td= @plot.initial_succession - if @plot.featured_plant %h2.center= @plot.featured_plant.common_name.titleize From c0434099b0dbb25384a2ce3c6682b22cf4877b4f Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Mon, 28 Feb 2022 16:16:58 -0800 Subject: [PATCH 03/21] Change CSS class name --- app/assets/stylesheets/homepage.css.scss | 2 +- app/views/static_pages/home.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/homepage.css.scss b/app/assets/stylesheets/homepage.css.scss index 7314a310..8f7746cd 100644 --- a/app/assets/stylesheets/homepage.css.scss +++ b/app/assets/stylesheets/homepage.css.scss @@ -13,7 +13,7 @@ color: $grey2; } -.caption { +.subtitle { margin: $space4; font-family: 'graphik-regular-italic'; color: $grey2; diff --git a/app/views/static_pages/home.html.haml b/app/views/static_pages/home.html.haml index 5f961863..ac932ce7 100644 --- a/app/views/static_pages/home.html.haml +++ b/app/views/static_pages/home.html.haml @@ -1,6 +1,6 @@ .jumbotron.center %h1.title Ecotone - %h2.caption A Living, Learning Laboratory at OSU-Cascades + %h2.subtitle A Living, Learning Laboratory at OSU-Cascades .img-container .col.center .img-circle From be49585342be28dd1798d69b955c21a2a0100219 Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Mon, 28 Feb 2022 17:31:07 -0800 Subject: [PATCH 04/21] Remove title attribute --- app/views/plants/new.html.haml | 2 +- app/views/plots/edit.html.haml | 2 +- app/views/plots/new.html.haml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/plants/new.html.haml b/app/views/plants/new.html.haml index 3da50679..84ad1a5c 100644 --- a/app/views/plants/new.html.haml +++ b/app/views/plants/new.html.haml @@ -1,4 +1,4 @@ - content_for_title('New Plant') - content_for(:subnav) do - = button_to('« Plants', plants_path, class: 'button primary', title: 'List of all plants', method: 'get') + = button_to('« Plants', plants_path, class: 'button primary', method: 'get') = render partial: 'form' diff --git a/app/views/plots/edit.html.haml b/app/views/plots/edit.html.haml index 81e1f51b..b5959505 100644 --- a/app/views/plots/edit.html.haml +++ b/app/views/plots/edit.html.haml @@ -1,4 +1,4 @@ - content_for_title("Edit Plot ##{@plot.plot_id}") - content_for(:subnav) do - = button_to('« Back', @plot, class: 'button primary', title: 'List of all plots', method: 'get') + = button_to('« Back', @plot, class: 'button primary', method: 'get') = render partial: 'form' \ No newline at end of file diff --git a/app/views/plots/new.html.haml b/app/views/plots/new.html.haml index 6ca2b646..312d7d0e 100644 --- a/app/views/plots/new.html.haml +++ b/app/views/plots/new.html.haml @@ -1,4 +1,4 @@ - content_for_title('New Plot') - content_for(:subnav) do - = button_to('« Plots', plots_path, class: 'button primary', title: 'List of all plots', method: 'get') + = button_to('« Plots', plots_path, class: 'button primary', method: 'get') = render partial: 'form' From 53c05c9f127875216b66d08ddf330d56e1296e7b Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Mon, 28 Feb 2022 17:31:39 -0800 Subject: [PATCH 05/21] Add field_with_errors to defaults from custom.css --- app/assets/stylesheets/default.css.scss | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/default.css.scss b/app/assets/stylesheets/default.css.scss index 13118103..7f4dcc89 100644 --- a/app/assets/stylesheets/default.css.scss +++ b/app/assets/stylesheets/default.css.scss @@ -1,5 +1,5 @@ @import './constants.css.scss'; -@import "bootstrap"; +@import 'bootstrap'; @mixin box_sizing { @@ -32,7 +32,7 @@ p { a { text-decoration: none; &:link, &:visited, &:hover, &:active { - text-decoration: none + text-decoration: none; } } @@ -78,3 +78,13 @@ form.button_to { margin: 0px; padding: 0px; } + +.field_with_errors { + @extend .has-error; + .form-control { + background-color: $red9; + &:focus { + background-color: white; + } + } +} \ No newline at end of file From 04336e6ba109a5531ba2a55eeffae162587d78ad Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Mon, 28 Feb 2022 18:04:27 -0800 Subject: [PATCH 06/21] Add redirect on cancel function to controllers --- app/controllers/plants_controller.rb | 5 +++++ app/controllers/plots_controller.rb | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/app/controllers/plants_controller.rb b/app/controllers/plants_controller.rb index e3c95549..a0bb4b39 100644 --- a/app/controllers/plants_controller.rb +++ b/app/controllers/plants_controller.rb @@ -2,6 +2,7 @@ class PlantsController < ApplicationController before_action :set_plant, only: [:show, :edit, :update, :destroy, :download_qr] before_action :login_required, only: [:new, :create, :edit, :update, :destroy] before_action :admin_required, only: [:new, :create, :edit, :update, :destroy] + before_action :redirect_cancel, :only => [:create, :update] def index @plants = Plant.all @@ -34,6 +35,10 @@ def update end end + def redirect_cancel + redirect_to @plant if params[:cancel] + end + def destroy @plant.destroy redirect_to plants_path diff --git a/app/controllers/plots_controller.rb b/app/controllers/plots_controller.rb index d3fc9df4..899633a4 100644 --- a/app/controllers/plots_controller.rb +++ b/app/controllers/plots_controller.rb @@ -2,6 +2,7 @@ class PlotsController < ApplicationController before_action :set_plot, only: [:show, :edit, :update, :destroy, :download_qr] before_action :login_required, except: [:index, :show, :download_qr] before_action :admin_required, except: [:index, :show, :download_qr] + before_action :redirect_cancel, :only => [:create, :update] def index @plots = Plot.order(:plot_id) @@ -39,6 +40,10 @@ def update end end + def redirect_cancel + redirect_to @plot if params[:cancel] + end + def delete_plot_image_attachment @photo = ActiveStorage::Attachment.find(params[:id]) @photo.purge From 6c1d9af6ee6b1437aea6ebd48510683c4191d9a0 Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Mon, 28 Feb 2022 18:53:30 -0800 Subject: [PATCH 07/21] Add special orange border shadow --- app/assets/stylesheets/constants.css.scss | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/assets/stylesheets/constants.css.scss b/app/assets/stylesheets/constants.css.scss index cd2f9bcd..f0db1789 100644 --- a/app/assets/stylesheets/constants.css.scss +++ b/app/assets/stylesheets/constants.css.scss @@ -149,10 +149,13 @@ $shadow5: 0 20px 40px rgba(0,0,0,.2); $orange-shadow: 0 10px 20px rgba(194, 68, 0, 0.45), 0 5px 10px rgba(0,0,0,.10); // shadow3 mixed with green2 $green-shadow: 0 10px 20px rgba(81, 120, 18, 0.5), 0 5px 10px rgba(0,0,0,.10); +// border shadow mixed with orange7 +$border-orange: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(249, 150, 108, 0.6); // picture border shadow $border-shadow: inset 0 0 0 1px hsla(0, 0%, 0%, .1); + // ICONS @font-face { font-family: 'icomoon'; From 8a3dfab97be96fbdd1ff594241cb749f944ae102 Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Mon, 28 Feb 2022 18:56:00 -0800 Subject: [PATCH 08/21] Add new btn-form class for forms, update some code to override custom.css --- app/assets/stylesheets/buttons.css.scss | 35 +++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/buttons.css.scss b/app/assets/stylesheets/buttons.css.scss index 1e7f0b0d..d4fb7256 100644 --- a/app/assets/stylesheets/buttons.css.scss +++ b/app/assets/stylesheets/buttons.css.scss @@ -7,6 +7,7 @@ padding: $space0; text-align: center; border-radius: $space0; + border: 1px solid black; transition-duration: 0.1s; } @@ -16,20 +17,38 @@ border-color: $orange3; box-shadow: $shadow2; &:hover, &:focus, &:focus-visible { - color: $grey9; background-color: $orange3; border-color: $orange3; box-shadow: $shadow1; outline: 0px; } &:active { - color: $grey9; background-color: $orange2; border-color: $orange2; box-shadow: $shadow1; } } +.secondary { + color: $orange3; + background-color: white; + border-color: $orange3; + box-shadow: $shadow2; + &:hover, &:focus, &:focus-visible { + color: $orange3; + background-color: white; + border-color: $orange3; + box-shadow: $shadow1; + outline: 0px; + } + &:active { + color: $orange3; + background-color: $grey9; + border-color: $orange2; + box-shadow: $shadow1; + } +} + .btn-icon { height: $space5; width: $space5; @@ -55,3 +74,15 @@ column-gap: $space2; justify-content: end; } + +.btn-form { + display: grid; + grid-auto-flow: column; + column-gap: $space3; + justify-content: end; + border-top: 1px solid $grey7; + padding: $space3; + &.submit { + margin-right: $space0; + } +} From d0d78fe2e0874591e3c614efcea067adfe12d942 Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Mon, 28 Feb 2022 18:59:09 -0800 Subject: [PATCH 09/21] Comment out /remove old css --- app/assets/stylesheets/custom.css.scss.erb | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/app/assets/stylesheets/custom.css.scss.erb b/app/assets/stylesheets/custom.css.scss.erb index d42356c0..21dd2451 100644 --- a/app/assets/stylesheets/custom.css.scss.erb +++ b/app/assets/stylesheets/custom.css.scss.erb @@ -7,11 +7,11 @@ $osu-orange: #C34500; $gray-medium-light: #eaeaea; -@mixin box_sizing { +<%# @mixin box_sizing { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; -} +} %> // Universal @@ -98,13 +98,13 @@ a.navbar-brand img { } -.debug_dump { +<%# .debug_dump { clear: both; float: left; width: 100%; margin-top: 45px; @include box-sizing; -} +} %> // Sign In @@ -121,40 +121,40 @@ a.navbar-brand img { // Forms -input, textarea, select, .uneditable-input { +<%# input, textarea, select, .uneditable-input { border: 1px solid #bbb; width: 100%; margin-bottom: 15px; @include box_sizing; -} +} %> -input[type="checkbox"] { +<%# input[type="checkbox"] { margin-bottom: 15px; box-shadow: none !important; -} +} %> -textarea { +<%# textarea { resize: vertical; -} +} %> -.field_with_errors { +<%# .field_with_errors { @extend .has-error; .form-control { color: $state-danger-text; } -} +} %> -.g-recaptcha { +<%# .g-recaptcha { margin-bottom: 15px; -} +} %> -form img { +<%# form img { margin-bottom: 20px; } label.form-label-photo { display: block; -} +} %> // Model indexes From 3baf8560cb97f7f2ec17f67b105b05d0c537315c Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Mon, 28 Feb 2022 18:59:29 -0800 Subject: [PATCH 10/21] Remove mixin --- app/assets/stylesheets/default.css.scss | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/assets/stylesheets/default.css.scss b/app/assets/stylesheets/default.css.scss index 7f4dcc89..ed2cc10e 100644 --- a/app/assets/stylesheets/default.css.scss +++ b/app/assets/stylesheets/default.css.scss @@ -2,12 +2,6 @@ @import 'bootstrap'; -@mixin box_sizing { - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; - box-sizing: border-box; -} - html, body { height: 100%; width: 100%; From 2ca0e979b771dc689c02668a626d78e6052bf079 Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Mon, 28 Feb 2022 18:59:43 -0800 Subject: [PATCH 11/21] Update form UI based on RUI --- app/assets/stylesheets/form.css.scss | 83 ++++++++++++++++++++++ app/views/plots/_form.html.haml | 100 ++++++++++++++++++--------- 2 files changed, 149 insertions(+), 34 deletions(-) create mode 100644 app/assets/stylesheets/form.css.scss diff --git a/app/assets/stylesheets/form.css.scss b/app/assets/stylesheets/form.css.scss new file mode 100644 index 00000000..1f3376bc --- /dev/null +++ b/app/assets/stylesheets/form.css.scss @@ -0,0 +1,83 @@ +@import './constants.css.scss'; + +.form { + display: grid; + grid-auto-flow: row; + margin: $space4; + justify-content: center; + + .content { + display: grid; + grid-template-columns: $space11 $space13; + border-top: 1px solid $grey7; + margin: 0px; + padding-left: $space0; + padding-right: $space0; + } + + .caption { + padding: $space3; + h3 { + margin: 0px 0px $space1; + } + p { + color: $grey4; + font-size: $txt1; + } + } + + .input { + display: grid; + grid-auto-flow: rows; + row-gap: $space3; + padding: $space3; + margin-bottom: $space1; + font-size: $txt2; + } + + // input[type="checkbox"] { + // margin: 0px; + // size: $txt2; + // } + + .photos { + display: grid; + grid-template-columns: auto auto auto; + row-gap: $space4; + justify-content: space-evenly; + .img-square { + height: $space9; + width: $space9; + margin: 0px; + } + } + + .data { + label { + color: $grey3; + font-family: 'graphik-light'; + font-weight: 100; + margin-bottom: $space0; + } + } + + .submit { + margin-right: $space0; + } +} + +.form-control { + height: $txt7; + &:focus{ + border-color: $orange6; + box-shadow: $border-orange; + } +} + +@media (max-width: 500px) { + // .content { + // grid-auto-flow: row; + // align-items: center; + // justify-items: center; + // } +} diff --git a/app/views/plots/_form.html.haml b/app/views/plots/_form.html.haml index 2353dc8c..e8329e38 100644 --- a/app/views/plots/_form.html.haml +++ b/app/views/plots/_form.html.haml @@ -1,34 +1,66 @@ -.row - .col-md-6.col-md-offset-3 - = form_for(@plot, html: { multipart: true }) do |form| - = form_errors_for(@plot) - = form.label :plot_id, "Plot ID" - = form.text_field :plot_id, class: 'form-control' - = form.label :featured_plant_id - = form.collection_select :featured_plant_id, @plants, :id, :common_name, include_blank: 'Choose one' - = form.label :location_description - = form.text_area :location_description, class: 'form-control' - = form.label :latitude - = form.text_field :latitude, class: 'form-control' - = form.label :longitude - = form.text_field :longitude, class: 'form-control' - = form.label :elevation, 'Elevation (ft)' - = form.text_field :elevation, class: 'form-control' - = form.label :area, 'Area (sq ft)' - = form.text_field :area, class: 'form-control' - = form.label :aspect - = form.text_field :aspect, class: 'form-control' - = form.label :origin - = form.text_field :origin, class: 'form-control' - = form.label :inoculated, "Inoculated?" - = form.check_box :inoculated, class: 'form-control' - = form.label :initial_planting_date - = form.text_field :initial_planting_date, class: 'form-control' - = form.label :initial_succession - = form.text_field :initial_succession, class: 'form-control' - = form.label :photo - - (0...@plot.photo.count).each do |photo| - = image_tag(@plot.photo[photo].variant(resize: "200x200"), alt: "Photo of #{@plot.photo}") unless @plot.new_record? if @plot.photo.attached? - = form.file_field :photo, multiple: true, class: 'form-control' - = form.submit class: 'btn btn-primary' - +.form + = form_for(@plot, html: { multipart: true }) do |form| + = form_errors_for(@plot) + .content + .caption + %h3 About + %p.italic Describe interesting plot features and where to find it + .input + .data + = form.label :plot_id, "Plot ID" + = form.text_field :plot_id, class: 'form-control' + .data + = form.label :location_description, "Description" + = form.text_area :location_description, class: 'form-control' + .data + = form.label :featured_plant_id, "Featured Plant" + = form.collection_select :featured_plant_id, @plants, :id, :common_name, include_blank: 'None' + .data + = form.label :area, 'Area (sq ft)' + = form.text_field :area, class: 'form-control' + .content + .caption + %h3 Location + %p.italic Add specific plot coordinates and exposure information + .input + .data + = form.label :latitude + = form.text_field :latitude, class: 'form-control' + .data + = form.label :longitude + = form.text_field :longitude, class: 'form-control' + .data + = form.label :elevation, 'Elevation (ft)' + = form.text_field :elevation, class: 'form-control' + .data + = form.label :aspect + = form.text_field :aspect, class: 'form-control' + .content + .caption + %h3 Information + %p.italic Detail the health and history of the plot + .input + .data + = form.label :origin + = form.text_field :origin, class: 'form-control' + .data + = form.label :inoculated, "Inoculated?" + = form.check_box :inoculated + .data + = form.label :initial_planting_date, "Initial Planting Date" + = form.text_field :initial_planting_date, class: 'form-control' + .data + = form.label :initial_succession, "Initial Succession" + = form.text_field :initial_succession, class: 'form-control' + .content + .caption + %h3 Photos + %p.italic Show the changes of the plot over time by adding pictures + .input + .photos + - @plot.photo.each_with_index do |image, index| + .img-square{ :style => "background-image: url(#{rails_blob_url(photo(@plot, index))})", :alt => "Photo of #{image}" } + = form.file_field :photo, multiple: true, class: 'form-control' + .btn-form + = button_to('Cancel', @plot, name: 'cancel', class: 'button secondary', method: 'get') + = form.submit class: 'button primary submit' From 328efb47facb6590b6981087576826db55af1b97 Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Mon, 28 Feb 2022 19:03:28 -0800 Subject: [PATCH 12/21] Update wording in test to match updates in form UI --- spec/features/admin_creates_plot_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/features/admin_creates_plot_spec.rb b/spec/features/admin_creates_plot_spec.rb index 3de9cd36..d881fefb 100644 --- a/spec/features/admin_creates_plot_spec.rb +++ b/spec/features/admin_creates_plot_spec.rb @@ -12,8 +12,8 @@ scenario 'providing valid plot attributes' do visit new_plot_path fill_in('Plot', with: 1) - select('Plant Example', from: 'Featured plant') - fill_in('Location description', with: 'Top of the hill') + select('Plant Example', from: 'Featured Plant') + fill_in('Description', with: 'Top of the hill') fill_in('Latitude', with: 1234) fill_in('Longitude', with: 1234) fill_in('Elevation', with: 3000) @@ -21,8 +21,8 @@ fill_in('Aspect', with: 'South') fill_in('Origin', with: 'Salvage') check('Inoculated') - fill_in('Initial planting date', with: 'Spring 2016') - fill_in('Initial succession', with: 'example succession') + fill_in('Initial Planting Date', with: 'Spring 2016') + fill_in('Initial Succession', with: 'example succession') click_on('Create Plot') expect(page).to have_content('Plot was successfully created.') end From 646e56086a5b70bcfa2c8b5b334c906c9f1779c4 Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Mon, 28 Feb 2022 19:09:54 -0800 Subject: [PATCH 13/21] Fix bug where cancel broke on new pages --- app/controllers/plants_controller.rb | 9 +++++++-- app/controllers/plots_controller.rb | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/controllers/plants_controller.rb b/app/controllers/plants_controller.rb index a0bb4b39..215457df 100644 --- a/app/controllers/plants_controller.rb +++ b/app/controllers/plants_controller.rb @@ -2,7 +2,8 @@ class PlantsController < ApplicationController before_action :set_plant, only: [:show, :edit, :update, :destroy, :download_qr] before_action :login_required, only: [:new, :create, :edit, :update, :destroy] before_action :admin_required, only: [:new, :create, :edit, :update, :destroy] - before_action :redirect_cancel, :only => [:create, :update] + before_action :redirect_cancel_edit, :only => [:update] + before_action :redirect_cancel_edit, :only => [:create] def index @plants = Plant.all @@ -35,10 +36,14 @@ def update end end - def redirect_cancel + def redirect_cancel_edit redirect_to @plant if params[:cancel] end + def redirect_cancel_new + redirect_to plants_path if params[:cancel] + end + def destroy @plant.destroy redirect_to plants_path diff --git a/app/controllers/plots_controller.rb b/app/controllers/plots_controller.rb index 899633a4..8ffa5ee9 100644 --- a/app/controllers/plots_controller.rb +++ b/app/controllers/plots_controller.rb @@ -2,7 +2,8 @@ class PlotsController < ApplicationController before_action :set_plot, only: [:show, :edit, :update, :destroy, :download_qr] before_action :login_required, except: [:index, :show, :download_qr] before_action :admin_required, except: [:index, :show, :download_qr] - before_action :redirect_cancel, :only => [:create, :update] + before_action :redirect_cancel_edit, :only => [:update] + before_action :redirect_cancel_new, :only => [:create] def index @plots = Plot.order(:plot_id) @@ -40,10 +41,14 @@ def update end end - def redirect_cancel + def redirect_cancel_edit redirect_to @plot if params[:cancel] end + def redirect_cancel_new + redirect_to plots_path if params[:cancel] + end + def delete_plot_image_attachment @photo = ActiveStorage::Attachment.find(params[:id]) @photo.purge From 16ad762d46f464d9240040412566d8b255852ba0 Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Mon, 28 Feb 2022 22:49:31 -0800 Subject: [PATCH 14/21] Update photo to gallery view, fix checkbox --- app/assets/stylesheets/form.css.scss | 27 +++++++++++++++++---------- app/views/plots/_form.html.haml | 4 ++-- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/assets/stylesheets/form.css.scss b/app/assets/stylesheets/form.css.scss index 1f3376bc..02d72466 100644 --- a/app/assets/stylesheets/form.css.scss +++ b/app/assets/stylesheets/form.css.scss @@ -35,20 +35,24 @@ font-size: $txt2; } - // input[type="checkbox"] { - // margin: 0px; - // size: $txt2; - // } + input[type="checkbox"] { + margin: 0px $space2 0px; + height: $txt2; + width: $txt2; + justify-self: center; + align-self: center; + } - .photos { - display: grid; - grid-template-columns: auto auto auto; - row-gap: $space4; - justify-content: space-evenly; + .gallery { + &#form { + justify-content: left; + margin: 0px; + padding: 0px; + } .img-square { + margin: 0px $space2 $space2 0px; height: $space9; width: $space9; - margin: 0px; } } @@ -59,6 +63,9 @@ font-weight: 100; margin-bottom: $space0; } + textarea { + resize: vertical; + } } .submit { diff --git a/app/views/plots/_form.html.haml b/app/views/plots/_form.html.haml index e8329e38..f6094d15 100644 --- a/app/views/plots/_form.html.haml +++ b/app/views/plots/_form.html.haml @@ -57,10 +57,10 @@ %h3 Photos %p.italic Show the changes of the plot over time by adding pictures .input - .photos + .gallery#form - @plot.photo.each_with_index do |image, index| .img-square{ :style => "background-image: url(#{rails_blob_url(photo(@plot, index))})", :alt => "Photo of #{image}" } - = form.file_field :photo, multiple: true, class: 'form-control' + = form.file_field :photo, multiple: true .btn-form = button_to('Cancel', @plot, name: 'cancel', class: 'button secondary', method: 'get') = form.submit class: 'button primary submit' From 0f567b1c56950c44dc2f13b371b231fa36c953f0 Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Tue, 1 Mar 2022 14:13:29 -0800 Subject: [PATCH 15/21] Add method for titleizing common names in selects --- app/models/plant.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/plant.rb b/app/models/plant.rb index ae26c2ec..52aaab93 100644 --- a/app/models/plant.rb +++ b/app/models/plant.rb @@ -14,4 +14,8 @@ class Plant < ApplicationRecord def to_s "#{common_name} (#{scientific_name})" end + + def form_common_name + common_name.titleize + end end From d919544e530ef0c688b7adadb89dc0f3321cd84e Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Tue, 1 Mar 2022 14:14:03 -0800 Subject: [PATCH 16/21] Update select and checkbox CSS --- app/assets/stylesheets/form.css.scss | 23 +++++++++++++++++++---- app/views/plots/_form.html.haml | 6 +++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/form.css.scss b/app/assets/stylesheets/form.css.scss index 02d72466..76af1841 100644 --- a/app/assets/stylesheets/form.css.scss +++ b/app/assets/stylesheets/form.css.scss @@ -36,11 +36,19 @@ } input[type="checkbox"] { - margin: 0px $space2 0px; + margin: 0px $space1 0px; height: $txt2; width: $txt2; - justify-self: center; - align-self: center; + outline: 0px; + } + + .checkbox-label { + color: $grey3; + font-family: 'graphik-light'; + font-weight: 100; + padding: 0px; + padding-top: $space1; + margin: 0px; } .gallery { @@ -62,10 +70,17 @@ font-family: 'graphik-light'; font-weight: 100; margin-bottom: $space0; + &.checkbox-label { + margin: $space1 0px 0px; + padding: 0px; + } } textarea { resize: vertical; } + select { + padding-left: $space1; + } } .submit { @@ -75,7 +90,7 @@ .form-control { height: $txt7; - &:focus{ + &:focus, &:focus-visible{ border-color: $orange6; box-shadow: $border-orange; } diff --git a/app/views/plots/_form.html.haml b/app/views/plots/_form.html.haml index f6094d15..8a623d68 100644 --- a/app/views/plots/_form.html.haml +++ b/app/views/plots/_form.html.haml @@ -14,7 +14,7 @@ = form.text_area :location_description, class: 'form-control' .data = form.label :featured_plant_id, "Featured Plant" - = form.collection_select :featured_plant_id, @plants, :id, :common_name, include_blank: 'None' + = form.collection_select :featured_plant_id, @plants, :id, :form_common_name, {include_blank: 'None'}, {class: 'form-control'} .data = form.label :area, 'Area (sq ft)' = form.text_field :area, class: 'form-control' @@ -44,7 +44,7 @@ = form.label :origin = form.text_field :origin, class: 'form-control' .data - = form.label :inoculated, "Inoculated?" + = form.label :inoculated, "Inoculated?", class: 'checkbox-label' = form.check_box :inoculated .data = form.label :initial_planting_date, "Initial Planting Date" @@ -55,7 +55,7 @@ .content .caption %h3 Photos - %p.italic Show the changes of the plot over time by adding pictures + %p.italic Show plot changes over time by adding pictures .input .gallery#form - @plot.photo.each_with_index do |image, index| From 7d862c2f0a21e011f98fe8519be5ffeee7e6a821 Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Tue, 1 Mar 2022 15:32:12 -0800 Subject: [PATCH 17/21] Create custom checkbox for forms --- app/assets/stylesheets/checkbox.css.scss | 39 ++++++++++++++++++++++ app/assets/stylesheets/form.css.scss | 41 +++++++++++++----------- app/views/plots/_form.html.haml | 4 +-- 3 files changed, 63 insertions(+), 21 deletions(-) create mode 100644 app/assets/stylesheets/checkbox.css.scss diff --git a/app/assets/stylesheets/checkbox.css.scss b/app/assets/stylesheets/checkbox.css.scss new file mode 100644 index 00000000..822b7a17 --- /dev/null +++ b/app/assets/stylesheets/checkbox.css.scss @@ -0,0 +1,39 @@ +@import './constants.css.scss'; + +input[type="checkbox"] { + appearance: none; + margin: 0px $space2 0px !important; + padding: 3px 7px 2px !important; + vertical-align: text-bottom; + height: $txt4; + width: $txt4; + outline: 0px; + border-radius: $space0; + background-color: white; + border: 1px solid #ccc; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + cursor: pointer; + &::before { + position: absolute; + content: ''; + width: 6px; + height: 12px; + border-style: solid; + color: white; + border-width: 0 3px 3px 0; + transform: rotate(38deg); + opacity: 0; + } + &:hover{ + border-color: $orange6; + box-shadow: $border-orange; + } + &:checked { + border-color: $orange5; + background: $orange5; + box-shadow: none; + &::before { + opacity: 1; + } + } +} \ No newline at end of file diff --git a/app/assets/stylesheets/form.css.scss b/app/assets/stylesheets/form.css.scss index 76af1841..744aaac0 100644 --- a/app/assets/stylesheets/form.css.scss +++ b/app/assets/stylesheets/form.css.scss @@ -35,21 +35,14 @@ font-size: $txt2; } - input[type="checkbox"] { - margin: 0px $space1 0px; - height: $txt2; - width: $txt2; - outline: 0px; - } - - .checkbox-label { - color: $grey3; - font-family: 'graphik-light'; - font-weight: 100; - padding: 0px; - padding-top: $space1; - margin: 0px; - } + // .checkbox-label { + // color: $grey3; + // font-family: 'graphik-light'; + // font-weight: 100; + // // padding: 0px; + // margin: $space1 0px 0px; + // // margin: 0px; + // } .gallery { &#form { @@ -70,10 +63,10 @@ font-family: 'graphik-light'; font-weight: 100; margin-bottom: $space0; - &.checkbox-label { - margin: $space1 0px 0px; - padding: 0px; - } + // &.checkbox-label { + // // margin: $space1 0px 0px; + // // padding: 0px; + // } } textarea { resize: vertical; @@ -81,6 +74,16 @@ select { padding-left: $space1; } + + } + + .checkbox-container { + display: inline; + margin: $space1 0px 0px; + label { + margin: 0px; + padding: 0px; + } } .submit { diff --git a/app/views/plots/_form.html.haml b/app/views/plots/_form.html.haml index 8a623d68..692c2df8 100644 --- a/app/views/plots/_form.html.haml +++ b/app/views/plots/_form.html.haml @@ -43,8 +43,8 @@ .data = form.label :origin = form.text_field :origin, class: 'form-control' - .data - = form.label :inoculated, "Inoculated?", class: 'checkbox-label' + .data.checkbox-container + = form.label :inoculated, "Inoculated?" = form.check_box :inoculated .data = form.label :initial_planting_date, "Initial Planting Date" From 762ce373848f28ce29dc240923fa1a28c1257f5c Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Tue, 1 Mar 2022 16:41:17 -0800 Subject: [PATCH 18/21] Add hoverable delete overlay to photos on form page --- app/assets/stylesheets/buttons.css.scss | 20 +++++++++++++ app/assets/stylesheets/form.css.scss | 40 +++++++++++++++---------- app/views/plots/_form.html.haml | 4 ++- 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/app/assets/stylesheets/buttons.css.scss b/app/assets/stylesheets/buttons.css.scss index d4fb7256..6b84ee23 100644 --- a/app/assets/stylesheets/buttons.css.scss +++ b/app/assets/stylesheets/buttons.css.scss @@ -49,6 +49,26 @@ } } +.delete { + width: $space7; + color: white; + background-color: $red4; + border-color: $red4; + transition: all .15s ease-in-out; + &:hover, &:focus, &:focus-visible { + color: white; + background-color: $red4; + border-color: $red4; + outline: 0px; + transform: scale(1.1); + } + &:active { + color: white; + background-color: $red3; + border-color: $red3; + } +} + .btn-icon { height: $space5; width: $space5; diff --git a/app/assets/stylesheets/form.css.scss b/app/assets/stylesheets/form.css.scss index 744aaac0..d04845aa 100644 --- a/app/assets/stylesheets/form.css.scss +++ b/app/assets/stylesheets/form.css.scss @@ -35,25 +35,40 @@ font-size: $txt2; } - // .checkbox-label { - // color: $grey3; - // font-family: 'graphik-light'; - // font-weight: 100; - // // padding: 0px; - // margin: $space1 0px 0px; - // // margin: 0px; - // } - .gallery { &#form { justify-content: left; margin: 0px; padding: 0px; } - .img-square { + + .overlay-container { + display: grid; margin: 0px $space2 $space2 0px; + position: relative; height: $space9; width: $space9; + &:hover .img-square{ + opacity: 0.3; + } + &:hover .overlay{ + opacity: 1; + } + } + + .img-square { + margin: 0px $space2 $space2 0px; + width: 100%; + height: 100%; + transition: 0.35s ease; + } + + .overlay { + position: absolute; + align-self: center; + justify-self: center; + opacity: 0; + transition: 0.35s ease; } } @@ -63,10 +78,6 @@ font-family: 'graphik-light'; font-weight: 100; margin-bottom: $space0; - // &.checkbox-label { - // // margin: $space1 0px 0px; - // // padding: 0px; - // } } textarea { resize: vertical; @@ -74,7 +85,6 @@ select { padding-left: $space1; } - } .checkbox-container { diff --git a/app/views/plots/_form.html.haml b/app/views/plots/_form.html.haml index 692c2df8..7798cacc 100644 --- a/app/views/plots/_form.html.haml +++ b/app/views/plots/_form.html.haml @@ -59,7 +59,9 @@ .input .gallery#form - @plot.photo.each_with_index do |image, index| - .img-square{ :style => "background-image: url(#{rails_blob_url(photo(@plot, index))})", :alt => "Photo of #{image}" } + .overlay-container + .img-square{ :style => "background-image: url(#{rails_blob_url(photo(@plot, index))})", :alt => "Photo of #{image}" } + %button.button.delete.overlay Delete = form.file_field :photo, multiple: true .btn-form = button_to('Cancel', @plot, name: 'cancel', class: 'button secondary', method: 'get') From 37cfaf3d2d337575854bc487a390a1b8f3ef2cfa Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Tue, 1 Mar 2022 17:54:07 -0800 Subject: [PATCH 19/21] Add delete button functionality for form photo overlay --- app/assets/stylesheets/buttons.css.scss | 2 ++ app/controllers/plots_controller.rb | 17 +++++++++-------- app/views/plots/_form.html.haml | 2 +- config/routes.rb | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/assets/stylesheets/buttons.css.scss b/app/assets/stylesheets/buttons.css.scss index 6b84ee23..58dda714 100644 --- a/app/assets/stylesheets/buttons.css.scss +++ b/app/assets/stylesheets/buttons.css.scss @@ -50,6 +50,8 @@ } .delete { + font-size: $txt0; + height: $space4; width: $space7; color: white; background-color: $red4; diff --git a/app/controllers/plots_controller.rb b/app/controllers/plots_controller.rb index 8ffa5ee9..45dbdf84 100644 --- a/app/controllers/plots_controller.rb +++ b/app/controllers/plots_controller.rb @@ -2,8 +2,9 @@ class PlotsController < ApplicationController before_action :set_plot, only: [:show, :edit, :update, :destroy, :download_qr] before_action :login_required, except: [:index, :show, :download_qr] before_action :admin_required, except: [:index, :show, :download_qr] - before_action :redirect_cancel_edit, :only => [:update] before_action :redirect_cancel_new, :only => [:create] + before_action :redirect_cancel_edit, :only => [:update] + def index @plots = Plot.order(:plot_id) @@ -41,25 +42,25 @@ def update end end - def redirect_cancel_edit - redirect_to @plot if params[:cancel] - end - def redirect_cancel_new redirect_to plots_path if params[:cancel] end - def delete_plot_image_attachment + def redirect_cancel_edit + redirect_to @plot if params[:cancel] + end + + def delete_image_attachment @photo = ActiveStorage::Attachment.find(params[:id]) @photo.purge - redirect_back fallback_location: plots_path + redirect_back fallback_location: @plot flash[:success] = 'Photo was successfully deleted.' end def destroy @plot.destroy redirect_to plots_path - flash[:success] = 'Plot was successfully destroyed.' + flash[:success] = 'Plot was successfully deleted.' end def download_qr diff --git a/app/views/plots/_form.html.haml b/app/views/plots/_form.html.haml index 7798cacc..7ba8b972 100644 --- a/app/views/plots/_form.html.haml +++ b/app/views/plots/_form.html.haml @@ -61,7 +61,7 @@ - @plot.photo.each_with_index do |image, index| .overlay-container .img-square{ :style => "background-image: url(#{rails_blob_url(photo(@plot, index))})", :alt => "Photo of #{image}" } - %button.button.delete.overlay Delete + = link_to("Delete", delete_image_attachment_plot_url(image), method: :delete, class: 'button delete overlay') = form.file_field :photo, multiple: true .btn-form = button_to('Cancel', @plot, name: 'cancel', class: 'button secondary', method: 'get') diff --git a/config/routes.rb b/config/routes.rb index 10f71f03..6b87585a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -30,7 +30,7 @@ resources :plots do member do - delete :delete_plot_image_attachment + delete :delete_image_attachment end end From 78a795fcd6e02232385e3e8ebb70a6684cfc119e Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Tue, 1 Mar 2022 18:03:25 -0800 Subject: [PATCH 20/21] Update tests to match new UI --- spec/controllers/plots_controller_spec.rb | 2 +- spec/features/admin_deletes_plot_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/controllers/plots_controller_spec.rb b/spec/controllers/plots_controller_spec.rb index 28358bc0..64cbd956 100644 --- a/spec/controllers/plots_controller_spec.rb +++ b/spec/controllers/plots_controller_spec.rb @@ -125,7 +125,7 @@ it 'produces correct flash notice' do delete :destroy, params: { id: @plot } - assert_equal 'Plot was successfully destroyed.', flash[:success] + assert_equal 'Plot was successfully deleted.', flash[:success] end end diff --git a/spec/features/admin_deletes_plot_spec.rb b/spec/features/admin_deletes_plot_spec.rb index 660a7048..a4c43905 100644 --- a/spec/features/admin_deletes_plot_spec.rb +++ b/spec/features/admin_deletes_plot_spec.rb @@ -11,7 +11,7 @@ scenario 'by selecting an existing plot' do visit plot_path(1) click_link 'Delete' - expect(page).to have_content('Plot was successfully destroyed.') + expect(page).to have_content('Plot was successfully deleted.') end From 5f0011823f800bcfa2d3e06476bf34ced3bec25a Mon Sep 17 00:00:00 2001 From: NikitaRubocki Date: Tue, 1 Mar 2022 18:10:26 -0800 Subject: [PATCH 21/21] Move alerts into new CSS file from custom --- app/assets/stylesheets/alerts.css.scss | 42 +++++++++++ app/assets/stylesheets/custom.css.scss.erb | 81 ---------------------- 2 files changed, 42 insertions(+), 81 deletions(-) create mode 100644 app/assets/stylesheets/alerts.css.scss diff --git a/app/assets/stylesheets/alerts.css.scss b/app/assets/stylesheets/alerts.css.scss new file mode 100644 index 00000000..31e5ce61 --- /dev/null +++ b/app/assets/stylesheets/alerts.css.scss @@ -0,0 +1,42 @@ +.alert { + ul { + margin: 0 0 30px 0; + } +} + +.alert .alert-heading { + margin: 0 0 10px 0; +} + +.alert ul { + margin: 0px; +} + +// Devise alerts +.alert-error { + background-color: #f2dede; + border-color: #eed3d7; + color: #b94a48; + text-align: left; + } + +.alert-alert { + background-color: #f2dede; + border-color: #eed3d7; + color: #b94a48; + text-align: left; + } + +.alert-success { + background-color: #dff0d8; + border-color: #d6e9c6; + color: #468847; + text-align: left; + } + +.alert-notice { + background-color: #dff0d8; + border-color: #d6e9c6; + color: #468847; + text-align: left; + } \ No newline at end of file diff --git a/app/assets/stylesheets/custom.css.scss.erb b/app/assets/stylesheets/custom.css.scss.erb index 21dd2451..329c55df 100644 --- a/app/assets/stylesheets/custom.css.scss.erb +++ b/app/assets/stylesheets/custom.css.scss.erb @@ -46,49 +46,6 @@ ul.pagination { } } -.alert { - ul { - margin: 0 0 30px 0; - } -} - -.alert .alert-heading { - margin: 0 0 10px 0; -} - -.alert ul { - margin: 0px; -} - -// Devise alerts - -.alert-error { - background-color: #f2dede; - border-color: #eed3d7; - color: #b94a48; - text-align: left; - } - -.alert-alert { - background-color: #f2dede; - border-color: #eed3d7; - color: #b94a48; - text-align: left; - } - -.alert-success { - background-color: #dff0d8; - border-color: #d6e9c6; - color: #468847; - text-align: left; - } - -.alert-notice { - background-color: #dff0d8; - border-color: #d6e9c6; - color: #468847; - text-align: left; - } // Header @@ -119,44 +76,6 @@ a.navbar-brand img { } } -// Forms - -<%# input, textarea, select, .uneditable-input { - border: 1px solid #bbb; - width: 100%; - margin-bottom: 15px; - @include box_sizing; -} %> - -<%# input[type="checkbox"] { - margin-bottom: 15px; - box-shadow: none !important; -} %> - -<%# textarea { - resize: vertical; -} %> - -<%# .field_with_errors { - @extend .has-error; - .form-control { - color: $state-danger-text; - } -} %> - -<%# .g-recaptcha { - margin-bottom: 15px; -} %> - -<%# form img { - margin-bottom: 20px; -} - -label.form-label-photo { - display: block; -} %> - - // Model indexes ul.indexing {