From 81d4545104ab441c0d7846cfbc2be5fbdef84bc8 Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Wed, 23 Sep 2015 17:14:53 +0200 Subject: [PATCH] C&V test improvements --- .../supplier/app/components/form/boolean-switch.js.coffee | 3 +-- .../supplier/app/components/form/my-select.js.coffee | 7 +++++-- .../app/templates/modals/product_category_form.emblem | 4 ++-- .../supplier/foundation1/components/_nav_main.sass | 1 + app/helpers/application_helper.rb | 7 +++++++ app/models/list.rb | 8 ++++---- app/serializers/users/product_category_serializer.rb | 4 ++++ config/locales/supplier.en.yml | 2 ++ config/routes.rb | 2 +- docker-compose.yml | 4 ++-- spec/support/features/basic_helpers.rb | 2 +- wip.md | 3 +++ 12 files changed, 33 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/supplier/app/components/form/boolean-switch.js.coffee b/app/assets/javascripts/supplier/app/components/form/boolean-switch.js.coffee index b658e69c..41d0c27c 100644 --- a/app/assets/javascripts/supplier/app/components/form/boolean-switch.js.coffee +++ b/app/assets/javascripts/supplier/app/components/form/boolean-switch.js.coffee @@ -3,6 +3,5 @@ App.BooleanSwitchComponent = Ember.Component.extend classNames: "switch" classNameBindings: ['rounded:round'] - click: -> - @set 'value', !@get('value') + # UniqueId is used to connect the label and the checkbox to eachother in the template setUniqueId: (->@set 'switchId', "switch-#{Math.round(Math.random()*1000)}").on('init') diff --git a/app/assets/javascripts/supplier/app/components/form/my-select.js.coffee b/app/assets/javascripts/supplier/app/components/form/my-select.js.coffee index 142dd7a7..d3285fd4 100644 --- a/app/assets/javascripts/supplier/app/components/form/my-select.js.coffee +++ b/app/assets/javascripts/supplier/app/components/form/my-select.js.coffee @@ -19,8 +19,11 @@ App.MySelectComponent = Ember.Component.extend didRender: -> # Set select to current value if can be found - key = @get('optionValuePath') - index = @get('content').mapBy(key).indexOf(@get("selection.#{key}")) + if @get('identity') + key = @get('optionValuePath') + index = @get('content').mapBy(key).indexOf(@get("selection.#{key}")) # Ember 2.0.1 cannot find real objects yet + else + index = @get('content').indexOf(@get('selection')) if index > -1 @$('select:first').prop('selectedIndex', index) diff --git a/app/assets/javascripts/supplier/app/templates/modals/product_category_form.emblem b/app/assets/javascripts/supplier/app/templates/modals/product_category_form.emblem index f45ced09..d2a58c4d 100644 --- a/app/assets/javascripts/supplier/app/templates/modals/product_category_form.emblem +++ b/app/assets/javascripts/supplier/app/templates/modals/product_category_form.emblem @@ -1,6 +1,6 @@ .form-row.name .form-label.half=t 'attributes.product_category.name' - .form-field.half= input valueBinding="model.name" action="save" + .form-field.half= input value=model.name action="save" .row .small-12.medium-6.columns unless model.supplier.week_starts_on_monday @@ -28,7 +28,7 @@ if model.supplier.week_starts_on_monday .form-row.sunday .form-label.half= t 'date.day_name.sunday' - .form-field.half= boolean-switch valueBinding=model.active_on_sunday + .form-field.half= boolean-switch value=model.active_on_sunday .small-12.medium-6.columns .row .small-12.columns.text-center= boolean-button value=model.full_day reverse=true text_path="product_category.modal.active_between.top" diff --git a/app/assets/stylesheets/supplier/foundation1/components/_nav_main.sass b/app/assets/stylesheets/supplier/foundation1/components/_nav_main.sass index 9cd3208b..a08518a9 100644 --- a/app/assets/stylesheets/supplier/foundation1/components/_nav_main.sass +++ b/app/assets/stylesheets/supplier/foundation1/components/_nav_main.sass @@ -109,6 +109,7 @@ header.top-menu .current-employee-nav float: right margin-right: 10px + cursor: pointer .dropdown-trigger.gravatar display: inline-block overflow: hidden diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ebe29de1..a1f29772 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -22,6 +22,13 @@ module ApplicationHelper super(*args) end + def user_root_path + case Rails.env + when 'development' then 'http://localhost:4200/' + else '/user/index.html' + end + end + def user_dynamic_data_host case Rails.env when 'test' then "$data_host = data_host = 'http://#{request.host}:#{request.port}';".html_safe diff --git a/app/models/list.rb b/app/models/list.rb index 665a85bd..d7103b75 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -52,19 +52,19 @@ class List } }|, reduce_function: '_sum' - view :active_for_supplier_and_section_view, type: :custom, map_function: %[function(doc){ + view :active_for_supplier_and_section_view, type: :custom, map_function: %|function(doc){ if(doc.ruby_class == 'List' && doc.state == 'active'){ emit([doc.supplier_id, doc.section_id], 1); } - }], reduce_function: '_sum' + }|, reduce_function: '_sum' - view :active_users_view, type: :custom, map_function: %[function(doc){ + view :active_users_view, type: :custom, map_function: %|function(doc){ if(doc.ruby_class == 'List' && doc.state == 'active'){ doc.user_ids && doc.user_ids.forEach(function(uid){ emit([doc.supplier_id, uid], 1); }) } - }], reduce_function: '_sum' + }|, reduce_function: '_sum' view :for_user_view, type: :custom, map_function: %|function(doc){ if(doc.ruby_class == 'List' && doc.user_ids && doc.user_ids.length){ diff --git a/app/serializers/users/product_category_serializer.rb b/app/serializers/users/product_category_serializer.rb index 1312ca39..6529e8ab 100644 --- a/app/serializers/users/product_category_serializer.rb +++ b/app/serializers/users/product_category_serializer.rb @@ -1,8 +1,12 @@ class Users::ProductCategorySerializer + FEATURED_NAMES = %w[ + featured + ] include Qwaiter::UserBaseSerializer attributes :name, :supplier_id, :active_on_sunday, :active_on_monday, :active_on_tuesday, :active_on_wednesday, :active_on_thursday, :active_on_friday, :active_on_saturday, :full_day, :start_from, :end_on, :position + attribute(:collapsed){ FEATURED_NAMES.exclude? object.name.to_s.downcase } has_many :products, serializer: Users::ProductSerializer has_one :supplier, serializer: Users::SupplierSerializer end diff --git a/config/locales/supplier.en.yml b/config/locales/supplier.en.yml index 24de6ec4..b42d841f 100644 --- a/config/locales/supplier.en.yml +++ b/config/locales/supplier.en.yml @@ -175,6 +175,8 @@ en: body_header: '' move_to_top: Move to top move_below_label: "Place below ${models.product_category|downcase}" + products: + title: Sort ${models.plural.product|downcase} product: new: 'New ${model.product|downcase}' destroy_confirmation: Are you sure you want to delete ${models.product|downcase} %{name} diff --git a/config/routes.rb b/config/routes.rb index 59843596..c7f421df 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -55,7 +55,7 @@ Qwaiter::Application.routes.draw do # USER #default_url_options format: 'html' #get '/user/index' => 'user#index', as: :user_root - get '/user' => 'user#index' + #get '/user/index.html#' => 'user#index', as: :user_root #get '/user/active_list(.:format)' => 'user#active_list', as: :user_active_list #get '/user/list_info' => 'user#list_info', as: :user_list_info, via: [:get, :options] #post '/user/needs_help' => 'user#needs_help', as: :user_needs_help diff --git a/docker-compose.yml b/docker-compose.yml index cc2dfbe4..e2e92006 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,8 +12,8 @@ counters: volumes: - ./config:/usr/src/app/config command: development - links: - - db + #links: + #- db faye: build: faye net: host diff --git a/spec/support/features/basic_helpers.rb b/spec/support/features/basic_helpers.rb index b593811f..b7868b74 100644 --- a/spec/support/features/basic_helpers.rb +++ b/spec/support/features/basic_helpers.rb @@ -23,7 +23,7 @@ module Features def user_visit(path) #visit File.join("http://localhost:3/") - visit File.join("/user/index.html#", path) + visit File.join(user_root_path, path) end def login_employee_as(email) diff --git a/wip.md b/wip.md index 2d675f14..5dc0a8f1 100644 --- a/wip.md +++ b/wip.md @@ -16,6 +16,9 @@ Supplier - Add qr print functionality offering to send the stickers - Use modernizr svg to determine svg handling capabilities - Add spec for switching from non-manager supplier to other supplier +- Testing + - Change list table + - Set product_category day from false to true User