From c0d0579acc7046d99b757b921dd2bd6be2e4aa1d Mon Sep 17 00:00:00 2001 From: Liloka Date: Wed, 15 Mar 2017 23:31:42 +0000 Subject: [PATCH 01/22] Issue #150 - Completed artist form and consent/pending - Added helper method for journey options --- app/helpers/drawings_helper.rb | 8 ++++ app/views/drawings/_form.html.haml | 71 ++++++++++++++---------------- 2 files changed, 41 insertions(+), 38 deletions(-) diff --git a/app/helpers/drawings_helper.rb b/app/helpers/drawings_helper.rb index 242c1f9..5065d82 100644 --- a/app/helpers/drawings_helper.rb +++ b/app/helpers/drawings_helper.rb @@ -35,6 +35,14 @@ def mood_select_box selections end + def gender_options + selections = ["Male", "Female", "Other", "Prefer not to say"] + end + + def journey_options + selections = ["At home", "In temporary shelter", "Awaiting transit", "On the move", "Arrived at destination"] + end + def image_consent_default @drawing.new_record? ? true : @drawing.image_consent end diff --git a/app/views/drawings/_form.html.haml b/app/views/drawings/_form.html.haml index 3c2daf5..a3dec34 100644 --- a/app/views/drawings/_form.html.haml +++ b/app/views/drawings/_form.html.haml @@ -1,53 +1,48 @@ .container - %h3 - = form_title + .row + .col-xs-12.text-center + %h1 + = form_title .row.drawings-wrapper - = simple_form_for @drawing, html: { multipart: true } do |f| - .col-md-5.col-sm-12.col-xs-12 + = simple_form_for @drawing, html: {multipart: true } do |f| + .col-xs-12 .image-wrap.text-center - %h4 Upload an image - %i (this is required) = image_tag preview_image(@drawing), id: 'image-preview', class: 'img-responsive' - %br - %b Allowed image types: jpg/jpeg, png, tiff, gif, bmp - = f.input :image, label: false, required: false, input_html: { onChange: 'loadFile(event)' } - .form-group.form-consent - = f.input :image_consent, label: @drawing.image_consent_text, input_html: { checked: image_consent_default } + %b Allowed image types: jpg, jpeg, png, tiff, gif, bmp + =f.input :image, label: false, required: false, input_html: { onChange: 'loadFile(event)' } - .col-md-7.col-sm-12.col-xs-12 - %h4 Details of Drawing (required when marked complete) - .form-group - = f.input :country, priority: TOP_COUNTRIES, selected: (@drawing.new_record? ? current_user.country : @drawing.country), label: "Country drawn in", include_blank: "-- select country that picture was drawn in --", class: 'form-control' + .col-xs-12.col-sm-6 + %h2.text-center Drawing Details .form-group - = f.input :subject_matter, collection: ["Home / Country of origin", "Transit", "Camp life", "Future hopes / destination"], label: 'Subject matter of drawing', required: false, prompt: "-- select an option --" + = f.input :country, priority: TOP_COUNTRIES, selected: (@drawing.new_record? ? current_user.country : @drawing.country), label: "Country drawn in", class: 'form-control' + .form-group + = f.input :subject_matter, collection: ["Home/Country of origin", "In transit", "Camp life", "Future hopes/destination"], label: "Subject matter of drawing", required: false .form-group - = f.input :description, label: 'Description of drawing', placeholder: 'e.g. Children playing in the garden, mountains in background' + = f.input :mood_rating, as: :radio_buttons, collection: mood_select_box, label: 'How would you rate the mood of the drawing?' .form-group - = f.input :mood_rating, as: :select, collection: mood_select_box, label: 'How would you rate the mood of the drawing?', prompt: "-- scale is from 1 (sad/tragic) to 5 (happy/joyful) --" - - %hr + = f.input :description, as: :text, label: 'Description of drawing' - %h4 Details of Artist + .col-xs-12.col-sm-6 + %h2.text-center Artist Details .form-group - = f.input :age, type: 'number', label: 'Age of artist', required: false, placeholder: 'e.g. 8' - .form-group.genders - = f.label 'Gender of Artist' - %br - = f.collection_radio_buttons :gender, radio_genders, :first, :last do |b| - = b.radio_button - = b.label(class: "btn") + = f.input :age, type: 'number', label: 'Age of artist', required: false .form-group - = f.input :origin_country, priority: TOP_ORIGIN_COUNTRIES, selected: @drawing.origin_country, label: "Country of origin", include_blank: "-- select country that artist comes from --", class: 'form-control' + = f.input :gender, as: :radio_buttons, collection: gender_options, label: 'Gender' .form-group - = f.input :stage_of_journey, collection: ["At home", "In temporary shelter", "Awaiting transit", "On the move", "Arrived at destination"], label: 'Stage of journey', required: false, prompt: "-- select an option --" + = f.input :origin_country, priority: TOP_ORIGIN_COUNTRIES, selected: @drawing.origin_country, label: "Country of origin", class: 'form-control' .form-group - = f.input :story, label: 'Context / story of the artist', required: false, placeholder: 'e.g. interesting cultural or psychological notes (optional)' + = f.input :stage_of_journey, as: :radio_buttons, collection: journey_options, required: false + .form-group + = f.input :story, label: 'Story of the artist', required: false + + .col-xs-12 + .form-group.form-consent.text-center + = f.input :image_consent, label: @drawing.image_consent_text, input_html: { checked: image_consent_default } .row.drawings-wrapper - %hr - .col-md-12 - .form-group.text-center - %label{for: "status"} Status (leave this as Pending if you need to enter required details later) - = f.input :status, collection: radio_statuses, label_method: lambda {|k| k.last.capitalize }, as: :radio_buttons, required: true, label: false - .form-group.text-center - = f.button :submit, class: 'btn-success btn-block' + .col-xs-12.col-sm-6.col-md-4 + .form-group + %label{for: "status"} Status + = f.input :status, collection: radio_statuses, label_method: lambda {|k| k.last.capitalize }, as: :radio_buttons, required: true, label: false + .form-group.text-center + = f.button :submit, class: 'btn-success btn-block' From 3ae7485490f3530ce79a101d05ac9b1fd5ed3126 Mon Sep 17 00:00:00 2001 From: Liloka Date: Wed, 15 Mar 2017 23:34:17 +0000 Subject: [PATCH 02/22] Issue #150 - Reduced width of forms --- app/views/drawings/_form.html.haml | 42 ++++++++++++++++-------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/app/views/drawings/_form.html.haml b/app/views/drawings/_form.html.haml index a3dec34..6b0f514 100644 --- a/app/views/drawings/_form.html.haml +++ b/app/views/drawings/_form.html.haml @@ -12,28 +12,30 @@ =f.input :image, label: false, required: false, input_html: { onChange: 'loadFile(event)' } .col-xs-12.col-sm-6 - %h2.text-center Drawing Details - .form-group - = f.input :country, priority: TOP_COUNTRIES, selected: (@drawing.new_record? ? current_user.country : @drawing.country), label: "Country drawn in", class: 'form-control' - .form-group - = f.input :subject_matter, collection: ["Home/Country of origin", "In transit", "Camp life", "Future hopes/destination"], label: "Subject matter of drawing", required: false - .form-group - = f.input :mood_rating, as: :radio_buttons, collection: mood_select_box, label: 'How would you rate the mood of the drawing?' - .form-group - = f.input :description, as: :text, label: 'Description of drawing' + .col-xs-12.col-sm-10.col-md-8 + %h2.text-center Drawing Details + .form-group + = f.input :country, priority: TOP_COUNTRIES, selected: (@drawing.new_record? ? current_user.country : @drawing.country), label: "Country drawn in", class: 'form-control' + .form-group + = f.input :subject_matter, collection: ["Home/Country of origin", "In transit", "Camp life", "Future hopes/destination"], label: "Subject matter of drawing", required: false + .form-group + = f.input :mood_rating, as: :radio_buttons, collection: mood_select_box, label: 'How would you rate the mood of the drawing?' + .form-group + = f.input :description, as: :text, label: 'Description of drawing' .col-xs-12.col-sm-6 - %h2.text-center Artist Details - .form-group - = f.input :age, type: 'number', label: 'Age of artist', required: false - .form-group - = f.input :gender, as: :radio_buttons, collection: gender_options, label: 'Gender' - .form-group - = f.input :origin_country, priority: TOP_ORIGIN_COUNTRIES, selected: @drawing.origin_country, label: "Country of origin", class: 'form-control' - .form-group - = f.input :stage_of_journey, as: :radio_buttons, collection: journey_options, required: false - .form-group - = f.input :story, label: 'Story of the artist', required: false + .col-xs-12.col-sm-10.col-md-8 + %h2.text-center Artist Details + .form-group + = f.input :age, type: 'number', label: 'Age of artist', required: false + .form-group + = f.input :gender, as: :radio_buttons, collection: gender_options, label: 'Gender' + .form-group + = f.input :origin_country, priority: TOP_ORIGIN_COUNTRIES, selected: @drawing.origin_country, label: "Country of origin", class: 'form-control' + .form-group + = f.input :stage_of_journey, as: :radio_buttons, collection: journey_options, required: false + .form-group + = f.input :story, label: 'Story of the artist', required: false .col-xs-12 .form-group.form-consent.text-center From 3a916c964b8ce1402751c3f79641e5748a89fa9b Mon Sep 17 00:00:00 2001 From: Liloka Date: Wed, 15 Mar 2017 23:40:22 +0000 Subject: [PATCH 03/22] Issue #150 - Positioned forms to be centered - Added position sass using margins and not floats or text centre --- app/assets/stylesheets/application.scss | 1 + app/assets/stylesheets/layout.scss | 8 ++++++++ app/views/drawings/_form.html.haml | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 app/assets/stylesheets/layout.scss diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index a4636ec..a6c1a30 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -2,6 +2,7 @@ @import "font-awesome-sprockets"; @import "font-awesome"; +@import "layout"; @import "drawings"; @import "organisations"; @import "edit"; diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss new file mode 100644 index 0000000..2891196 --- /dev/null +++ b/app/assets/stylesheets/layout.scss @@ -0,0 +1,8 @@ +.position { + float: none; + + &.central { + margin-left: auto; + margin-right: auto; + } +} \ No newline at end of file diff --git a/app/views/drawings/_form.html.haml b/app/views/drawings/_form.html.haml index 6b0f514..352b9b0 100644 --- a/app/views/drawings/_form.html.haml +++ b/app/views/drawings/_form.html.haml @@ -12,7 +12,7 @@ =f.input :image, label: false, required: false, input_html: { onChange: 'loadFile(event)' } .col-xs-12.col-sm-6 - .col-xs-12.col-sm-10.col-md-8 + .col-xs-12.col-sm-10.col-md-8.position.central %h2.text-center Drawing Details .form-group = f.input :country, priority: TOP_COUNTRIES, selected: (@drawing.new_record? ? current_user.country : @drawing.country), label: "Country drawn in", class: 'form-control' @@ -24,7 +24,7 @@ = f.input :description, as: :text, label: 'Description of drawing' .col-xs-12.col-sm-6 - .col-xs-12.col-sm-10.col-md-8 + .col-xs-12.col-sm-10.col-md-8.position.central %h2.text-center Artist Details .form-group = f.input :age, type: 'number', label: 'Age of artist', required: false From abe79f5f4ca0b6b56f6f91393216fc37a8b234e2 Mon Sep 17 00:00:00 2001 From: Liloka Date: Thu, 16 Mar 2017 19:51:30 +0000 Subject: [PATCH 04/22] issue #150 - Finished upload form - Added consent, status and savings CTAs --- app/views/drawings/_form.html.haml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/views/drawings/_form.html.haml b/app/views/drawings/_form.html.haml index 352b9b0..3e37afc 100644 --- a/app/views/drawings/_form.html.haml +++ b/app/views/drawings/_form.html.haml @@ -12,7 +12,7 @@ =f.input :image, label: false, required: false, input_html: { onChange: 'loadFile(event)' } .col-xs-12.col-sm-6 - .col-xs-12.col-sm-10.col-md-8.position.central + .col-xs-12.col-sm-10.col-md-9.position.central %h2.text-center Drawing Details .form-group = f.input :country, priority: TOP_COUNTRIES, selected: (@drawing.new_record? ? current_user.country : @drawing.country), label: "Country drawn in", class: 'form-control' @@ -22,9 +22,11 @@ = f.input :mood_rating, as: :radio_buttons, collection: mood_select_box, label: 'How would you rate the mood of the drawing?' .form-group = f.input :description, as: :text, label: 'Description of drawing' + .form-group.form-consent + = f.input :image_consent, label: @drawing.image_consent_text, input_html: { checked: image_consent_default } .col-xs-12.col-sm-6 - .col-xs-12.col-sm-10.col-md-8.position.central + .col-xs-12.col-sm-10.col-md-9.position.central %h2.text-center Artist Details .form-group = f.input :age, type: 'number', label: 'Age of artist', required: false @@ -37,12 +39,8 @@ .form-group = f.input :story, label: 'Story of the artist', required: false - .col-xs-12 - .form-group.form-consent.text-center - = f.input :image_consent, label: @drawing.image_consent_text, input_html: { checked: image_consent_default } - .row.drawings-wrapper - .col-xs-12.col-sm-6.col-md-4 + .col-xs-12.col-sm-5.position.central .form-group %label{for: "status"} Status = f.input :status, collection: radio_statuses, label_method: lambda {|k| k.last.capitalize }, as: :radio_buttons, required: true, label: false From edb59d7da9f74fa153d53bab709716a35059091a Mon Sep 17 00:00:00 2001 From: Liloka Date: Thu, 16 Mar 2017 21:04:02 +0000 Subject: [PATCH 05/22] Issue #150 - Rebuilt drawing upload form --- app/assets/stylesheets/components/form.scss | 14 ++++ app/assets/stylesheets/layout.scss | 3 +- app/assets/stylesheets/variables.scss | 5 ++ app/views/drawings/_form.html.haml | 81 ++++++++++----------- 4 files changed, 61 insertions(+), 42 deletions(-) diff --git a/app/assets/stylesheets/components/form.scss b/app/assets/stylesheets/components/form.scss index 3b21005..3876939 100644 --- a/app/assets/stylesheets/components/form.scss +++ b/app/assets/stylesheets/components/form.scss @@ -4,3 +4,17 @@ input.btn.btn-default.btn-success.btn-block { width: 60%; display: inline; } + +.forms-wrapper { + overflow: hidden; +} + +.forms-wrapper [class*="col-"]{ + margin-bottom: -99999px; + padding-bottom: 99999px; +} + +.form-section { + background-color: $white; + padding: $spacing-unit calc( #{$spacing-unit * 2} ); +} \ No newline at end of file diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 2891196..172ffe1 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -1,8 +1,9 @@ .position { float: none; + overflow: auto; &.central { margin-left: auto; margin-right: auto; } -} \ No newline at end of file +} diff --git a/app/assets/stylesheets/variables.scss b/app/assets/stylesheets/variables.scss index 01dca1e..ab929e4 100644 --- a/app/assets/stylesheets/variables.scss +++ b/app/assets/stylesheets/variables.scss @@ -20,3 +20,8 @@ $white: #fff; /**** Dimensions ****/ $drawingsPadding: 24px; /***************************/ + +/***************************/ +/**** Sizes ****/ +$spacing-unit: 15px; +/***************************/ diff --git a/app/views/drawings/_form.html.haml b/app/views/drawings/_form.html.haml index 3e37afc..3e2f35d 100644 --- a/app/views/drawings/_form.html.haml +++ b/app/views/drawings/_form.html.haml @@ -1,48 +1,47 @@ -.container - .row - .col-xs-12.text-center - %h1 - = form_title - .row.drawings-wrapper +.col-xs-12.text-center + %h1 + = form_title +.row.drawings-wrapper + .col-xs-12.col-sm-11.position.central = simple_form_for @drawing, html: {multipart: true } do |f| - .col-xs-12 + .col-xs-12.col-sm-4 .image-wrap.text-center = image_tag preview_image(@drawing), id: 'image-preview', class: 'img-responsive' %b Allowed image types: jpg, jpeg, png, tiff, gif, bmp =f.input :image, label: false, required: false, input_html: { onChange: 'loadFile(event)' } - .col-xs-12.col-sm-6 - .col-xs-12.col-sm-10.col-md-9.position.central - %h2.text-center Drawing Details - .form-group - = f.input :country, priority: TOP_COUNTRIES, selected: (@drawing.new_record? ? current_user.country : @drawing.country), label: "Country drawn in", class: 'form-control' - .form-group - = f.input :subject_matter, collection: ["Home/Country of origin", "In transit", "Camp life", "Future hopes/destination"], label: "Subject matter of drawing", required: false - .form-group - = f.input :mood_rating, as: :radio_buttons, collection: mood_select_box, label: 'How would you rate the mood of the drawing?' - .form-group - = f.input :description, as: :text, label: 'Description of drawing' - .form-group.form-consent - = f.input :image_consent, label: @drawing.image_consent_text, input_html: { checked: image_consent_default } - - .col-xs-12.col-sm-6 - .col-xs-12.col-sm-10.col-md-9.position.central - %h2.text-center Artist Details - .form-group - = f.input :age, type: 'number', label: 'Age of artist', required: false - .form-group - = f.input :gender, as: :radio_buttons, collection: gender_options, label: 'Gender' - .form-group - = f.input :origin_country, priority: TOP_ORIGIN_COUNTRIES, selected: @drawing.origin_country, label: "Country of origin", class: 'form-control' - .form-group - = f.input :stage_of_journey, as: :radio_buttons, collection: journey_options, required: false - .form-group - = f.input :story, label: 'Story of the artist', required: false + .forms-wrapper.col-xs.12.col-sm-8 + .col-xs-12.col-sm-6 + .col-xs-12.col-sm-11.col-md-10.position.central.form-section + %h2.text-center 1. Drawing Details + .form-group + = f.input :country, priority: TOP_COUNTRIES, selected: (@drawing.new_record? ? current_user.country : @drawing.country), label: "Country drawn in", class: 'form-control' + .form-group + = f.input :subject_matter, collection: ["Home/Country of origin", "In transit", "Camp life", "Future hopes/destination"], label: "Subject matter of drawing", required: false + .form-group + = f.input :mood_rating, as: :radio_buttons, collection: mood_select_box, label: 'How would you rate the mood of the drawing?' + .form-group + = f.input :description, as: :text, label: 'Description of drawing' + .form-group.form-consent + = f.input :image_consent, label: @drawing.image_consent_text, input_html: { checked: image_consent_default } - .row.drawings-wrapper - .col-xs-12.col-sm-5.position.central - .form-group - %label{for: "status"} Status - = f.input :status, collection: radio_statuses, label_method: lambda {|k| k.last.capitalize }, as: :radio_buttons, required: true, label: false - .form-group.text-center - = f.button :submit, class: 'btn-success btn-block' + .col-xs-12.col-sm-6 + .col-xs-12.col-sm-11.col-md-10.position.central.form-section + %h2.text-center 2. Artist Details + .form-group + = f.input :age, type: 'number', label: 'Age of artist', required: false + .form-group + = f.input :gender, as: :radio_buttons, collection: gender_options, label: 'Gender' + .form-group + = f.input :origin_country, priority: TOP_ORIGIN_COUNTRIES, selected: @drawing.origin_country, label: "Country of origin", class: 'form-control' + .form-group + = f.input :stage_of_journey, as: :radio_buttons, collection: journey_options, required: false + .form-group + = f.input :story, label: 'Story of the artist', required: false + + .col-xs-12.col-sm-11.col-md-10.position.central + .form-group + %label{for: "status"} Status + = f.input :status, collection: radio_statuses, label_method: lambda {|k| k.last.capitalize }, as: :radio_buttons, required: true, label: false + .form-group.text-center + = f.button :submit, class: 'btn-success btn-block' From f8b30e1b4689ec03c590e87bef41b0899bd59b4c Mon Sep 17 00:00:00 2001 From: Liloka Date: Thu, 16 Mar 2017 21:25:54 +0000 Subject: [PATCH 06/22] Issue #150 - Enlarged body text to be recommended 16px --- app/assets/stylesheets/application.scss | 1 + app/assets/stylesheets/variables.scss | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index a6c1a30..72a0d0f 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -16,6 +16,7 @@ html, body { height: 100%; background-color: $ice-white; font-family: proxima-nova, 'Helvetica Neue', Arial, Helvetica, sans-serif; + font-size: $base-font-size; } .alert { diff --git a/app/assets/stylesheets/variables.scss b/app/assets/stylesheets/variables.scss index ab929e4..7047ee9 100644 --- a/app/assets/stylesheets/variables.scss +++ b/app/assets/stylesheets/variables.scss @@ -1,3 +1,8 @@ +/***************************/ +/**** Fonts ****/ +$base-font-size: 16px; +/***************************/ + /***************************/ /**** Colours ****/ $aluminium: #a5a7aa; From bfa852031dca66e6ea7a14ec43949f186379ccf2 Mon Sep 17 00:00:00 2001 From: Liloka Date: Thu, 16 Mar 2017 22:06:16 +0000 Subject: [PATCH 07/22] Issue #150 - Styled the upload form - Changed Stage of journey to drop down to decrease length of form and remove need for scrolling - Removed extra margin bottom for labels for radio button form inputs --- app/assets/stylesheets/components/form.scss | 36 +++++++++++++++------ app/assets/stylesheets/edit.scss | 30 ----------------- app/assets/stylesheets/variables.scss | 2 +- app/views/drawings/_form.html.haml | 11 ++++--- 4 files changed, 34 insertions(+), 45 deletions(-) diff --git a/app/assets/stylesheets/components/form.scss b/app/assets/stylesheets/components/form.scss index 3876939..5576006 100644 --- a/app/assets/stylesheets/components/form.scss +++ b/app/assets/stylesheets/components/form.scss @@ -5,16 +5,34 @@ input.btn.btn-default.btn-success.btn-block { display: inline; } -.forms-wrapper { - overflow: hidden; +.form-section { + background-color: $white; + padding: $spacing-unit; + padding-bottom: 0; } -.forms-wrapper [class*="col-"]{ - margin-bottom: -99999px; - padding-bottom: 99999px; +.form-title { + border-bottom: 1px $light-gray solid; + margin-bottom: $spacing-unit; + + h2 { + font-size: 1.3em; + margin-top: 0; + } } -.form-section { - background-color: $white; - padding: $spacing-unit calc( #{$spacing-unit * 2} ); -} \ No newline at end of file +.form-group { + margin-bottom: $spacing-unit; +} + +.form-consent label { + font-weight: bold; +} + +label { + font-weight: normal; + + &.radio_buttons { + margin-bottom: 0px; + } +} diff --git a/app/assets/stylesheets/edit.scss b/app/assets/stylesheets/edit.scss index 46e73fc..6ca378e 100644 --- a/app/assets/stylesheets/edit.scss +++ b/app/assets/stylesheets/edit.scss @@ -23,33 +23,3 @@ text-align: center; } } - -// TODO - Tidy up during the week -.form-group.genders { - label { - border-radius: 5px; - margin-right: 5px; - } - label[for=drawing_gender_not_specified] { - background-color: #D3D3D3; - padding-left: 15px; - } - label[for=drawing_gender_female] { - background-color: #FFB6C1; - padding-left: 15px; - } - label[for=drawing_gender_male] { - background-color: #ADD8E6; - padding-left: 15px; - } - label[for=drawing_gender_other] { - background-color: #FFE8CD; - padding-left: 15px; - } -} - -.form-consent { - label { - font-weight: bold; - } -} diff --git a/app/assets/stylesheets/variables.scss b/app/assets/stylesheets/variables.scss index 7047ee9..e7456f2 100644 --- a/app/assets/stylesheets/variables.scss +++ b/app/assets/stylesheets/variables.scss @@ -28,5 +28,5 @@ $drawingsPadding: 24px; /***************************/ /**** Sizes ****/ -$spacing-unit: 15px; +$spacing-unit: 30px; /***************************/ diff --git a/app/views/drawings/_form.html.haml b/app/views/drawings/_form.html.haml index 3e2f35d..c12f6d0 100644 --- a/app/views/drawings/_form.html.haml +++ b/app/views/drawings/_form.html.haml @@ -13,7 +13,8 @@ .forms-wrapper.col-xs.12.col-sm-8 .col-xs-12.col-sm-6 .col-xs-12.col-sm-11.col-md-10.position.central.form-section - %h2.text-center 1. Drawing Details + .form-title + %h2 Drawing Details .form-group = f.input :country, priority: TOP_COUNTRIES, selected: (@drawing.new_record? ? current_user.country : @drawing.country), label: "Country drawn in", class: 'form-control' .form-group @@ -27,7 +28,8 @@ .col-xs-12.col-sm-6 .col-xs-12.col-sm-11.col-md-10.position.central.form-section - %h2.text-center 2. Artist Details + .form-title + %h2 Artist Details .form-group = f.input :age, type: 'number', label: 'Age of artist', required: false .form-group @@ -35,13 +37,12 @@ .form-group = f.input :origin_country, priority: TOP_ORIGIN_COUNTRIES, selected: @drawing.origin_country, label: "Country of origin", class: 'form-control' .form-group - = f.input :stage_of_journey, as: :radio_buttons, collection: journey_options, required: false + = f.input :stage_of_journey, collection: ["At home", "In temporary shelter", "Awaiting transit", "On the move", "Arrived at destination"], label: 'Stage of journey', required: false .form-group = f.input :story, label: 'Story of the artist', required: false - .col-xs-12.col-sm-11.col-md-10.position.central .form-group - %label{for: "status"} Status + %label.radio_buttons{for: "status"} Status = f.input :status, collection: radio_statuses, label_method: lambda {|k| k.last.capitalize }, as: :radio_buttons, required: true, label: false .form-group.text-center = f.button :submit, class: 'btn-success btn-block' From 650d22a8207b785ad77407f0a10d346403dd2f8f Mon Sep 17 00:00:00 2001 From: Liloka Date: Thu, 16 Mar 2017 22:09:16 +0000 Subject: [PATCH 08/22] Issue #150 - Styled button to be minimum recommended height and font-size --- app/assets/stylesheets/components/form.scss | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/components/form.scss b/app/assets/stylesheets/components/form.scss index 5576006..d08166d 100644 --- a/app/assets/stylesheets/components/form.scss +++ b/app/assets/stylesheets/components/form.scss @@ -1,8 +1,10 @@ @import "variables"; input.btn.btn-default.btn-success.btn-block { - width: 60%; display: inline; + min-height: 60px; + font-weight: bold; + font-size: $base-font-size; } .form-section { From cc1a505b794caa61e095347e3ba73fe108b58a84 Mon Sep 17 00:00:00 2001 From: Liloka Date: Fri, 17 Mar 2017 18:45:37 +0000 Subject: [PATCH 09/22] Removed redundant col-xs-12 from forms --- app/views/drawings/_form.html.haml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/drawings/_form.html.haml b/app/views/drawings/_form.html.haml index c12f6d0..31d024c 100644 --- a/app/views/drawings/_form.html.haml +++ b/app/views/drawings/_form.html.haml @@ -12,7 +12,7 @@ .forms-wrapper.col-xs.12.col-sm-8 .col-xs-12.col-sm-6 - .col-xs-12.col-sm-11.col-md-10.position.central.form-section + .position.central.form-section .form-title %h2 Drawing Details .form-group @@ -27,7 +27,7 @@ = f.input :image_consent, label: @drawing.image_consent_text, input_html: { checked: image_consent_default } .col-xs-12.col-sm-6 - .col-xs-12.col-sm-11.col-md-10.position.central.form-section + .position.central.form-section .form-title %h2 Artist Details .form-group @@ -40,7 +40,7 @@ = f.input :stage_of_journey, collection: ["At home", "In temporary shelter", "Awaiting transit", "On the move", "Arrived at destination"], label: 'Stage of journey', required: false .form-group = f.input :story, label: 'Story of the artist', required: false - + .form-group %label.radio_buttons{for: "status"} Status = f.input :status, collection: radio_statuses, label_method: lambda {|k| k.last.capitalize }, as: :radio_buttons, required: true, label: false From 78fef439a7e4b9bba5e154a0d19076a6f77f9324 Mon Sep 17 00:00:00 2001 From: EChesters Date: Fri, 17 Mar 2017 20:35:20 +0000 Subject: [PATCH 10/22] Issue #150 - Refactored gender options - Removed my own collection helper method - Flipped the id and label to return correct labels on the form --- app/helpers/drawings_helper.rb | 6 +----- app/views/drawings/_form.html.haml | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/helpers/drawings_helper.rb b/app/helpers/drawings_helper.rb index 5065d82..ecb8f7a 100644 --- a/app/helpers/drawings_helper.rb +++ b/app/helpers/drawings_helper.rb @@ -21,7 +21,7 @@ def radio_statuses def radio_genders # Example output: [ ["gender0", "Gender 0"], ["gender1", "Gender 1"] ... ] [].tap do |arr| - Drawing.genders.keys.each { |s| arr << [s, s.humanize] } + Drawing.genders.keys.each { |s| arr << [s.humanize, s] } end end @@ -35,10 +35,6 @@ def mood_select_box selections end - def gender_options - selections = ["Male", "Female", "Other", "Prefer not to say"] - end - def journey_options selections = ["At home", "In temporary shelter", "Awaiting transit", "On the move", "Arrived at destination"] end diff --git a/app/views/drawings/_form.html.haml b/app/views/drawings/_form.html.haml index 31d024c..07a0692 100644 --- a/app/views/drawings/_form.html.haml +++ b/app/views/drawings/_form.html.haml @@ -33,7 +33,7 @@ .form-group = f.input :age, type: 'number', label: 'Age of artist', required: false .form-group - = f.input :gender, as: :radio_buttons, collection: gender_options, label: 'Gender' + = f.input :gender, as: :radio_buttons, collection: radio_genders, label: 'Gender' .form-group = f.input :origin_country, priority: TOP_ORIGIN_COUNTRIES, selected: @drawing.origin_country, label: "Country of origin", class: 'form-control' .form-group From 9ffc5506317cda1ef4494321d34db728ae6d3aab Mon Sep 17 00:00:00 2001 From: EChesters Date: Fri, 17 Mar 2017 20:51:24 +0000 Subject: [PATCH 11/22] Refactored helper methods for humanizing options - Gender - Status - Journey --- app/helpers/drawings_helper.rb | 20 +++++++++++--------- app/models/drawing.rb | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/helpers/drawings_helper.rb b/app/helpers/drawings_helper.rb index ecb8f7a..e50ea9e 100644 --- a/app/helpers/drawings_helper.rb +++ b/app/helpers/drawings_helper.rb @@ -12,17 +12,11 @@ def form_title end def radio_statuses - # Example output: [ ["status1", "status1"], ["status2", "status2"] ] - [].tap do |arr| - Drawing.statuses.keys.each { |s| arr << [s, s] } - end + get_humanized_options(Drawing.statuses) end def radio_genders - # Example output: [ ["gender0", "Gender 0"], ["gender1", "Gender 1"] ... ] - [].tap do |arr| - Drawing.genders.keys.each { |s| arr << [s.humanize, s] } - end + get_humanized_options(Drawing.genders) end def mood_select_box @@ -36,10 +30,18 @@ def mood_select_box end def journey_options - selections = ["At home", "In temporary shelter", "Awaiting transit", "On the move", "Arrived at destination"] + get_humanized_options(Drawing.journeys) end def image_consent_default @drawing.new_record? ? true : @drawing.image_consent end + + def get_humanized_options(options) + # Example output: [ ["gender0", "Gender 0"], ["gender1", "Gender 1"] ... ] + options.keys.map do |option| + [option.humanize, option] + end + end + end diff --git a/app/models/drawing.rb b/app/models/drawing.rb index 7d09a45..b8b08d5 100644 --- a/app/models/drawing.rb +++ b/app/models/drawing.rb @@ -1,6 +1,7 @@ class Drawing < ActiveRecord::Base enum status: %i(pending complete) enum gender: %i(not_specified female male other) + enum journey: %i(at_home in_temporary_shelter awaiting_transit on_the_move arrived_at_destination) validates :image, presence: true validates :status, presence: true From 18a87aaf3133aea568c674e9c0e2bd89130f1599 Mon Sep 17 00:00:00 2001 From: EChesters Date: Fri, 17 Mar 2017 20:54:37 +0000 Subject: [PATCH 12/22] Refactored getting mood rating --- app/helpers/drawings_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/drawings_helper.rb b/app/helpers/drawings_helper.rb index e50ea9e..87cc71e 100644 --- a/app/helpers/drawings_helper.rb +++ b/app/helpers/drawings_helper.rb @@ -21,9 +21,10 @@ def radio_genders def mood_select_box # Example output: [ ["1 (sad face)", 1], ["2", 2] ... ["4", 4] ["5 (happy face)", 5] ] - selections = [].tap do |arr| - (1..5).each { |n| arr << [n.to_s, n] } + selections = (1..5).map do |number| + [number.to_s, number] end + selections[0][0] += " 😢" selections[-1][0] += " 😃" selections From 6f2e75f59768383a3ea463f5daf9a5451d1d27b0 Mon Sep 17 00:00:00 2001 From: EChesters Date: Fri, 17 Mar 2017 21:06:09 +0000 Subject: [PATCH 13/22] Refactored subject matter to be keys in Drawing and use humanize helper method --- app/helpers/drawings_helper.rb | 4 ++++ app/models/drawing.rb | 1 + app/views/drawings/_form.html.haml | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/helpers/drawings_helper.rb b/app/helpers/drawings_helper.rb index 87cc71e..89ca8b0 100644 --- a/app/helpers/drawings_helper.rb +++ b/app/helpers/drawings_helper.rb @@ -34,6 +34,10 @@ def journey_options get_humanized_options(Drawing.journeys) end + def subject_matter_options + get_humanized_options(Drawing.subject_matters) + end + def image_consent_default @drawing.new_record? ? true : @drawing.image_consent end diff --git a/app/models/drawing.rb b/app/models/drawing.rb index b8b08d5..9791498 100644 --- a/app/models/drawing.rb +++ b/app/models/drawing.rb @@ -2,6 +2,7 @@ class Drawing < ActiveRecord::Base enum status: %i(pending complete) enum gender: %i(not_specified female male other) enum journey: %i(at_home in_temporary_shelter awaiting_transit on_the_move arrived_at_destination) + enum subject_matter: %i(home/Country_of_origin in_transit camp_life Future_hopes/destination) validates :image, presence: true validates :status, presence: true diff --git a/app/views/drawings/_form.html.haml b/app/views/drawings/_form.html.haml index 07a0692..6d04b72 100644 --- a/app/views/drawings/_form.html.haml +++ b/app/views/drawings/_form.html.haml @@ -18,7 +18,7 @@ .form-group = f.input :country, priority: TOP_COUNTRIES, selected: (@drawing.new_record? ? current_user.country : @drawing.country), label: "Country drawn in", class: 'form-control' .form-group - = f.input :subject_matter, collection: ["Home/Country of origin", "In transit", "Camp life", "Future hopes/destination"], label: "Subject matter of drawing", required: false + = f.input :subject_matter, collection: subject_matter_options, label: "Subject matter of drawing", required: false .form-group = f.input :mood_rating, as: :radio_buttons, collection: mood_select_box, label: 'How would you rate the mood of the drawing?' .form-group @@ -37,7 +37,7 @@ .form-group = f.input :origin_country, priority: TOP_ORIGIN_COUNTRIES, selected: @drawing.origin_country, label: "Country of origin", class: 'form-control' .form-group - = f.input :stage_of_journey, collection: ["At home", "In temporary shelter", "Awaiting transit", "On the move", "Arrived at destination"], label: 'Stage of journey', required: false + = f.input :stage_of_journey, collection: journey_options, label: 'Stage of journey', required: false .form-group = f.input :story, label: 'Story of the artist', required: false From 2bca42a759ffd7b97478227afc2dde780e163d32 Mon Sep 17 00:00:00 2001 From: EChesters Date: Fri, 17 Mar 2017 21:47:15 +0000 Subject: [PATCH 14/22] Issue #150 - Added spacing to drawing upload page title --- app/assets/stylesheets/application.scss | 1 + app/assets/stylesheets/spacing.scss | 11 +++++++++++ app/views/drawings/_form.html.haml | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 app/assets/stylesheets/spacing.scss diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 72a0d0f..68a1377 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -3,6 +3,7 @@ @import "font-awesome"; @import "layout"; +@import "spacing"; @import "drawings"; @import "organisations"; @import "edit"; diff --git a/app/assets/stylesheets/spacing.scss b/app/assets/stylesheets/spacing.scss new file mode 100644 index 0000000..565889e --- /dev/null +++ b/app/assets/stylesheets/spacing.scss @@ -0,0 +1,11 @@ +@import "variables"; + +.add-margin { + &.top { + margin-top: $spacing-unit; + } + + &.bottom { + margin-bottom: $spacing-unit; + } +} diff --git a/app/views/drawings/_form.html.haml b/app/views/drawings/_form.html.haml index 6d04b72..ff8484a 100644 --- a/app/views/drawings/_form.html.haml +++ b/app/views/drawings/_form.html.haml @@ -1,5 +1,5 @@ .col-xs-12.text-center - %h1 + %h1.add-margin.top.bottom = form_title .row.drawings-wrapper .col-xs-12.col-sm-11.position.central From b0b5cc192e09821226068cfa5285250c45e709d5 Mon Sep 17 00:00:00 2001 From: EChesters Date: Thu, 30 Mar 2017 18:49:56 +0100 Subject: [PATCH 15/22] Removed redundant .keep from models folder --- app/models/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 app/models/.keep diff --git a/app/models/.keep b/app/models/.keep deleted file mode 100644 index e69de29..0000000 From ee70cce09629c0a5d8583962ef16f0cbd0d256ec Mon Sep 17 00:00:00 2001 From: EChesters Date: Thu, 30 Mar 2017 19:12:49 +0100 Subject: [PATCH 16/22] Issue #150 - Altered mobile padding sizes - default padding on col-* made the elements too small on mobile --- app/assets/stylesheets/spacing.scss | 4 ++++ app/views/drawings/_form.html.haml | 25 +++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/assets/stylesheets/spacing.scss b/app/assets/stylesheets/spacing.scss index 565889e..f075baf 100644 --- a/app/assets/stylesheets/spacing.scss +++ b/app/assets/stylesheets/spacing.scss @@ -9,3 +9,7 @@ margin-bottom: $spacing-unit; } } + +.no-padding { + padding: 0 !important; +} \ No newline at end of file diff --git a/app/views/drawings/_form.html.haml b/app/views/drawings/_form.html.haml index ff8484a..433666d 100644 --- a/app/views/drawings/_form.html.haml +++ b/app/views/drawings/_form.html.haml @@ -1,17 +1,17 @@ .col-xs-12.text-center %h1.add-margin.top.bottom = form_title -.row.drawings-wrapper - .col-xs-12.col-sm-11.position.central +.row.drawings-wrapper.no-padding + .col-xs-12.col-sm-11.position.central.no-padding = simple_form_for @drawing, html: {multipart: true } do |f| - .col-xs-12.col-sm-4 + .col-xs-12.col-md-4 .image-wrap.text-center = image_tag preview_image(@drawing), id: 'image-preview', class: 'img-responsive' %b Allowed image types: jpg, jpeg, png, tiff, gif, bmp =f.input :image, label: false, required: false, input_html: { onChange: 'loadFile(event)' } - .forms-wrapper.col-xs.12.col-sm-8 - .col-xs-12.col-sm-6 + .forms-wrapper.col-xs.12.col-sm-8.no-padding + .col-xs-12.col-md-6 .position.central.form-section .form-title %h2 Drawing Details @@ -26,7 +26,7 @@ .form-group.form-consent = f.input :image_consent, label: @drawing.image_consent_text, input_html: { checked: image_consent_default } - .col-xs-12.col-sm-6 + .col-xs-12.col-md-6 .position.central.form-section .form-title %h2 Artist Details @@ -40,9 +40,10 @@ = f.input :stage_of_journey, collection: journey_options, label: 'Stage of journey', required: false .form-group = f.input :story, label: 'Story of the artist', required: false - - .form-group - %label.radio_buttons{for: "status"} Status - = f.input :status, collection: radio_statuses, label_method: lambda {|k| k.last.capitalize }, as: :radio_buttons, required: true, label: false - .form-group.text-center - = f.button :submit, class: 'btn-success btn-block' + + .col-xs-12.col-md-4.col-md-offset-7.add-margin.top + .form-group + %label.radio_buttons{for: "status"} Status + = f.input :status, collection: radio_statuses, label_method: lambda {|k| k.last.capitalize }, as: :radio_buttons, required: true, label: false + .form-group.text-center + = f.button :submit, class: 'btn-success btn-block' From 50302a6547f52cc57a1ddbb5359793b19b2d0d3e Mon Sep 17 00:00:00 2001 From: EChesters Date: Thu, 30 Mar 2017 21:02:05 +0100 Subject: [PATCH 17/22] Issue #150 - Fixed broken data structures for subject matter and journey stage --- app/helpers/drawings_helper.rb | 10 +++++----- app/models/drawing.rb | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/helpers/drawings_helper.rb b/app/helpers/drawings_helper.rb index 89ca8b0..a1b719e 100644 --- a/app/helpers/drawings_helper.rb +++ b/app/helpers/drawings_helper.rb @@ -12,11 +12,11 @@ def form_title end def radio_statuses - get_humanized_options(Drawing.statuses) + get_humanized_options(Drawing.statuses.keys) end def radio_genders - get_humanized_options(Drawing.genders) + get_humanized_options(Drawing.genders.keys) end def mood_select_box @@ -31,11 +31,11 @@ def mood_select_box end def journey_options - get_humanized_options(Drawing.journeys) + get_humanized_options(Drawing::STAGES_OF_JOURNEY) end def subject_matter_options - get_humanized_options(Drawing.subject_matters) + get_humanized_options(Drawing::SUBJECT_MATTERS) end def image_consent_default @@ -44,7 +44,7 @@ def image_consent_default def get_humanized_options(options) # Example output: [ ["gender0", "Gender 0"], ["gender1", "Gender 1"] ... ] - options.keys.map do |option| + options.map do |option| [option.humanize, option] end end diff --git a/app/models/drawing.rb b/app/models/drawing.rb index 9791498..a1d8ff5 100644 --- a/app/models/drawing.rb +++ b/app/models/drawing.rb @@ -1,8 +1,9 @@ class Drawing < ActiveRecord::Base enum status: %i(pending complete) enum gender: %i(not_specified female male other) - enum journey: %i(at_home in_temporary_shelter awaiting_transit on_the_move arrived_at_destination) - enum subject_matter: %i(home/Country_of_origin in_transit camp_life Future_hopes/destination) + + STAGES_OF_JOURNEY = ["At home", "In temporary shelter", "Awaiting transit", "On the move", "Arrived at destination"].freeze + SUBJECT_MATTERS = ["Home/Country of origin", "In transit", "Camp life", "Future_hopes/destination"].freeze validates :image, presence: true validates :status, presence: true From 8ec87d0aa5d6252cc74a502ec20912feea9ff686 Mon Sep 17 00:00:00 2001 From: EChesters Date: Fri, 31 Mar 2017 20:43:55 +0100 Subject: [PATCH 18/22] Issue #150 - Fixed spacing and best practice issues --- app/assets/stylesheets/components/form.scss | 22 ++++++++++----------- app/assets/stylesheets/spacing.scss | 2 +- app/helpers/drawings_helper.rb | 13 ++---------- app/models/drawing.rb | 14 ++++++++++--- app/views/drawings/_form.html.haml | 6 +++--- 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/app/assets/stylesheets/components/form.scss b/app/assets/stylesheets/components/form.scss index d08166d..6d0c1b9 100644 --- a/app/assets/stylesheets/components/form.scss +++ b/app/assets/stylesheets/components/form.scss @@ -8,23 +8,23 @@ input.btn.btn-default.btn-success.btn-block { } .form-section { - background-color: $white; - padding: $spacing-unit; - padding-bottom: 0; + background-color: $white; + padding: $spacing-unit; + padding-bottom: 0; } .form-title { - border-bottom: 1px $light-gray solid; - margin-bottom: $spacing-unit; + border-bottom: 1px $light-gray solid; + margin-bottom: $spacing-unit; - h2 { - font-size: 1.3em; - margin-top: 0; - } + h2 { + font-size: 1.3em; + margin-top: 0; + } } .form-group { - margin-bottom: $spacing-unit; + margin-bottom: $spacing-unit; } .form-consent label { @@ -35,6 +35,6 @@ label { font-weight: normal; &.radio_buttons { - margin-bottom: 0px; + margin-bottom: 0px; } } diff --git a/app/assets/stylesheets/spacing.scss b/app/assets/stylesheets/spacing.scss index f075baf..f93c4f2 100644 --- a/app/assets/stylesheets/spacing.scss +++ b/app/assets/stylesheets/spacing.scss @@ -12,4 +12,4 @@ .no-padding { padding: 0 !important; -} \ No newline at end of file +} diff --git a/app/helpers/drawings_helper.rb b/app/helpers/drawings_helper.rb index a1b719e..054f9a2 100644 --- a/app/helpers/drawings_helper.rb +++ b/app/helpers/drawings_helper.rb @@ -21,7 +21,7 @@ def radio_genders def mood_select_box # Example output: [ ["1 (sad face)", 1], ["2", 2] ... ["4", 4] ["5 (happy face)", 5] ] - selections = (1..5).map do |number| + selections = (1..5).map do |number| [number.to_s, number] end @@ -30,14 +30,6 @@ def mood_select_box selections end - def journey_options - get_humanized_options(Drawing::STAGES_OF_JOURNEY) - end - - def subject_matter_options - get_humanized_options(Drawing::SUBJECT_MATTERS) - end - def image_consent_default @drawing.new_record? ? true : @drawing.image_consent end @@ -48,5 +40,4 @@ def get_humanized_options(options) [option.humanize, option] end end - -end +end \ No newline at end of file diff --git a/app/models/drawing.rb b/app/models/drawing.rb index a1d8ff5..a5f98f2 100644 --- a/app/models/drawing.rb +++ b/app/models/drawing.rb @@ -1,10 +1,10 @@ class Drawing < ActiveRecord::Base + # STAGES_OF_JOURNEY + # SUBJECT_MATTERS + enum status: %i(pending complete) enum gender: %i(not_specified female male other) - STAGES_OF_JOURNEY = ["At home", "In temporary shelter", "Awaiting transit", "On the move", "Arrived at destination"].freeze - SUBJECT_MATTERS = ["Home/Country of origin", "In transit", "Camp life", "Future_hopes/destination"].freeze - validates :image, presence: true validates :status, presence: true validates_inclusion_of :image_consent, in: [true, false] @@ -52,6 +52,14 @@ def self.to_csv(hxl: false) end end + def self.stages_of_journey + @stages_of_journey = ["At home", "In temporary shelter", "Awaiting transit", "On the move", "Arrived at destination"] + end + + def self.subject_matters + @subject_matters = ["Home / Country of origin", "In transit", "Camp life", "Future_hopes / destination"] + end + def can_view?(current_user) super_admin_or_same_org?(current_user) end diff --git a/app/views/drawings/_form.html.haml b/app/views/drawings/_form.html.haml index 433666d..cf7647e 100644 --- a/app/views/drawings/_form.html.haml +++ b/app/views/drawings/_form.html.haml @@ -18,7 +18,7 @@ .form-group = f.input :country, priority: TOP_COUNTRIES, selected: (@drawing.new_record? ? current_user.country : @drawing.country), label: "Country drawn in", class: 'form-control' .form-group - = f.input :subject_matter, collection: subject_matter_options, label: "Subject matter of drawing", required: false + = f.input :subject_matter, collection: Drawing.subject_matters, label: "Subject matter of drawing", required: false .form-group = f.input :mood_rating, as: :radio_buttons, collection: mood_select_box, label: 'How would you rate the mood of the drawing?' .form-group @@ -37,10 +37,10 @@ .form-group = f.input :origin_country, priority: TOP_ORIGIN_COUNTRIES, selected: @drawing.origin_country, label: "Country of origin", class: 'form-control' .form-group - = f.input :stage_of_journey, collection: journey_options, label: 'Stage of journey', required: false + = f.input :stage_of_journey, collection: Drawing.stages_of_journey, label: 'Stage of journey', required: false .form-group = f.input :story, label: 'Story of the artist', required: false - + .col-xs-12.col-md-4.col-md-offset-7.add-margin.top .form-group %label.radio_buttons{for: "status"} Status From 94055660880b36ba2384db6dd47cb4f31582b009 Mon Sep 17 00:00:00 2001 From: EChesters Date: Fri, 31 Mar 2017 20:57:45 +0100 Subject: [PATCH 19/22] Issue #150 - Fixing newline on drawings_helper for robocop --- app/helpers/drawings_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/drawings_helper.rb b/app/helpers/drawings_helper.rb index 054f9a2..501f1f5 100644 --- a/app/helpers/drawings_helper.rb +++ b/app/helpers/drawings_helper.rb @@ -40,4 +40,4 @@ def get_humanized_options(options) [option.humanize, option] end end -end \ No newline at end of file +end From 1e232df61ddf9ce56408d66840cbd41e90d50e3d Mon Sep 17 00:00:00 2001 From: EChesters Date: Sat, 22 Apr 2017 17:00:37 +0100 Subject: [PATCH 20/22] Issue #150 - Amended spacing on form to reduce whitespace - Amended required fields to match current form --- app/assets/stylesheets/spacing.scss | 8 ++++++++ app/views/drawings/_form.html.haml | 17 ++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/assets/stylesheets/spacing.scss b/app/assets/stylesheets/spacing.scss index f93c4f2..2a06a55 100644 --- a/app/assets/stylesheets/spacing.scss +++ b/app/assets/stylesheets/spacing.scss @@ -3,10 +3,18 @@ .add-margin { &.top { margin-top: $spacing-unit; + + &.half { + margin-top: calc( #{ $spacing-unit} / 2); + } } &.bottom { margin-bottom: $spacing-unit; + + &.half { + margin-bottom: calc( #{ $spacing-unit} / 2); + } } } diff --git a/app/views/drawings/_form.html.haml b/app/views/drawings/_form.html.haml index cf7647e..a25fc74 100644 --- a/app/views/drawings/_form.html.haml +++ b/app/views/drawings/_form.html.haml @@ -22,7 +22,7 @@ .form-group = f.input :mood_rating, as: :radio_buttons, collection: mood_select_box, label: 'How would you rate the mood of the drawing?' .form-group - = f.input :description, as: :text, label: 'Description of drawing' + = f.input :description, as: :text, input_html: {:rows => 8 }, label: 'Description of drawing' .form-group.form-consent = f.input :image_consent, label: @drawing.image_consent_text, input_html: { checked: image_consent_default } @@ -31,7 +31,7 @@ .form-title %h2 Artist Details .form-group - = f.input :age, type: 'number', label: 'Age of artist', required: false + = f.input :age, type: 'number', label: 'Age of artist', class: 'optional', required: false .form-group = f.input :gender, as: :radio_buttons, collection: radio_genders, label: 'Gender' .form-group @@ -39,11 +39,10 @@ .form-group = f.input :stage_of_journey, collection: Drawing.stages_of_journey, label: 'Stage of journey', required: false .form-group - = f.input :story, label: 'Story of the artist', required: false + = f.input :story, label: 'Story of the artist', class: 'optional-label', required: false - .col-xs-12.col-md-4.col-md-offset-7.add-margin.top - .form-group - %label.radio_buttons{for: "status"} Status - = f.input :status, collection: radio_statuses, label_method: lambda {|k| k.last.capitalize }, as: :radio_buttons, required: true, label: false - .form-group.text-center - = f.button :submit, class: 'btn-success btn-block' + .col-xs-12.col-sm-10.col-md-8.add-margin.top.half.position.central + .form-group + = f.input :status, collection: radio_statuses, label_method: lambda {|k| k.last.capitalize }, as: :radio_buttons, required: true, label: 'Status', class: 'add-margin bottom half' + .form-group.text-center + = f.button :submit, class: 'btn-success btn-block no-margin' From ea085f81f7b31b628e6e0e0e1b48ef3f9f5b1aaa Mon Sep 17 00:00:00 2001 From: EChesters Date: Sat, 22 Apr 2017 17:17:00 +0100 Subject: [PATCH 21/22] Issue #150 - Refactored constants in drawing.rb --- app/models/drawing.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/drawing.rb b/app/models/drawing.rb index a5f98f2..58e4cd8 100644 --- a/app/models/drawing.rb +++ b/app/models/drawing.rb @@ -1,6 +1,6 @@ class Drawing < ActiveRecord::Base - # STAGES_OF_JOURNEY - # SUBJECT_MATTERS + STAGES_OF_JOURNEY = ["At home", "In temporary shelter", "Awaiting transit", "On the move", "Arrived at destination"].freeze + SUBJECT_MATTERS = ["Home / Country of origin", "In transit", "Camp life", "Future hopes / destination"].freeze enum status: %i(pending complete) enum gender: %i(not_specified female male other) @@ -53,11 +53,11 @@ def self.to_csv(hxl: false) end def self.stages_of_journey - @stages_of_journey = ["At home", "In temporary shelter", "Awaiting transit", "On the move", "Arrived at destination"] + STAGES_OF_JOURNEY end def self.subject_matters - @subject_matters = ["Home / Country of origin", "In transit", "Camp life", "Future_hopes / destination"] + SUBJECT_MATTERS end def can_view?(current_user) From b7a0c561226d8f294d8000c1a6f4d9fd8855a0da Mon Sep 17 00:00:00 2001 From: EChesters Date: Sat, 22 Apr 2017 18:29:26 +0100 Subject: [PATCH 22/22] Issue #150 - Amended new hash syntax + Switched comment formats around --- app/helpers/drawings_helper.rb | 2 +- app/views/drawings/_form.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/drawings_helper.rb b/app/helpers/drawings_helper.rb index 501f1f5..4b00b94 100644 --- a/app/helpers/drawings_helper.rb +++ b/app/helpers/drawings_helper.rb @@ -35,7 +35,7 @@ def image_consent_default end def get_humanized_options(options) - # Example output: [ ["gender0", "Gender 0"], ["gender1", "Gender 1"] ... ] + # Example output: [ ["Gender 0", "gender0"], ["Gender 1", "gender1"] ... ] options.map do |option| [option.humanize, option] end diff --git a/app/views/drawings/_form.html.haml b/app/views/drawings/_form.html.haml index a25fc74..bdd0ec4 100644 --- a/app/views/drawings/_form.html.haml +++ b/app/views/drawings/_form.html.haml @@ -22,7 +22,7 @@ .form-group = f.input :mood_rating, as: :radio_buttons, collection: mood_select_box, label: 'How would you rate the mood of the drawing?' .form-group - = f.input :description, as: :text, input_html: {:rows => 8 }, label: 'Description of drawing' + = f.input :description, as: :text, input_html: { rows: 8 }, label: 'Description of drawing' .form-group.form-consent = f.input :image_consent, label: @drawing.image_consent_text, input_html: { checked: image_consent_default }