From ef0e9dc0cab26914fdb04bd34b5b03fdd155c036 Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Sat, 2 May 2020 18:33:09 +0100 Subject: [PATCH] Replace select box with text when only one OC is available for selection --- .../darkswarm/_shop-navigation.css.scss | 9 ++++++++- app/views/enterprises/shop.html.haml | 17 +++++++++++------ .../features/consumer/shopping/shopping_spec.rb | 2 +- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/_shop-navigation.css.scss b/app/assets/stylesheets/darkswarm/_shop-navigation.css.scss index 80c2bfe09a..6d28406f08 100644 --- a/app/assets/stylesheets/darkswarm/_shop-navigation.css.scss +++ b/app/assets/stylesheets/darkswarm/_shop-navigation.css.scss @@ -60,6 +60,14 @@ ordercycle { } select { + background-image: url('/assets/white-caret.svg'); + } + + p { + text-align: left; + } + + select, p { width: inherit; display: inline-block; color: $white; @@ -70,7 +78,6 @@ ordercycle { line-height: 1.5em; padding: 0.5em 1.25em 0.5em 0.75em; height: 2.35em; - background-image: url('/assets/white-caret.svg'); background-size: 30px auto; border-radius: 0 0.25em 0.25em 0; min-width: 13em; diff --git a/app/views/enterprises/shop.html.haml b/app/views/enterprises/shop.html.haml index 7f98960b33..6414e82546 100644 --- a/app/views/enterprises/shop.html.haml +++ b/app/views/enterprises/shop.html.haml @@ -30,13 +30,18 @@ .select-label %span= t :enterprises_ready_for - %select.select2.avenir#order_cycle_id{"ng-model" => "order_cycle.order_cycle_id", - "ofn-change-order-cycle" => true, - "disabled" => require_customer?, - "ng-options" => "oc.id as oc.time for oc in #{oc_select_options.to_json}"} + - if oc_select_options.count == 1 + %p + = oc_select_options.first[:time] - - if oc_select_options.count > 1 - %option{value: "", disabled: "", selected: ""}= t :shopping_oc_select + - else + %select.select2.avenir#order_cycle_id{"ng-model" => "order_cycle.order_cycle_id", + "ofn-change-order-cycle" => true, + "disabled" => require_customer?, + "ng-options" => "oc.id as oc.time for oc in #{oc_select_options.to_json}"} + + - if oc_select_options.count > 1 + %option{value: "", disabled: "", selected: ""}= t :shopping_oc_select - content_for :ordercycle_sidebar do .show-for-large-up.large-4.columns diff --git a/spec/features/consumer/shopping/shopping_spec.rb b/spec/features/consumer/shopping/shopping_spec.rb index b8a6727727..bf849364c8 100644 --- a/spec/features/consumer/shopping/shopping_spec.rb +++ b/spec/features/consumer/shopping/shopping_spec.rb @@ -50,7 +50,7 @@ feature "As a consumer I want to shop with a distributor", js: true do it "selects an order cycle if only one is open" do exchange1.update_attribute :pickup_time, "turtles" visit shop_path - expect(page).to have_selector "option[selected]", text: 'turtles' + expect(page).to have_selector "p", text: 'turtles' end describe "with multiple order cycles" do