Add user product info

This commit is contained in:
2014-04-22 18:42:02 +02:00
parent 821f59b761
commit ea498cb9c5
26 changed files with 1474 additions and 105 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
source 'https://rubygems.org'
gem 'rails', '4.0.4'
gem 'rails', '4.1.0'
gem 'rack-cors', :require => 'rack/cors'
# Bundle edge Rails instead:
@@ -18,7 +18,7 @@ gem 'slim-rails'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 4.0.2'
gem 'sass-rails' #, '~> 4.0.2'
gem 'coffee-rails' #, '~> 3.2.1'
#gem 'twitter-bootstrap-rails'
gem 'bootstrap-sass', '~>2.3'
+67 -70
View File
@@ -34,15 +34,9 @@ PATH
specs:
cmtool (0.5.0)
bourbon
coffee-script
devise
devise_simply_stored
email_validator
haml-rails
jquery-rails
paperclip
rails (>= 3.2.2)
sass-rails
slim-rails
tinymce-rails
@@ -57,36 +51,37 @@ PATH
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.0.4)
actionpack (= 4.0.4)
actionmailer (4.1.0)
actionpack (= 4.1.0)
actionview (= 4.1.0)
mail (~> 2.5.4)
actionpack (4.0.4)
activesupport (= 4.0.4)
builder (~> 3.1.0)
erubis (~> 2.7.0)
actionpack (4.1.0)
actionview (= 4.1.0)
activesupport (= 4.1.0)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
actionview (4.1.0)
activesupport (= 4.1.0)
builder (~> 3.1)
erubis (~> 2.7.0)
active_decorator (0.3.4)
active_model_serializers (0.8.1)
activemodel (>= 3.0)
activemodel (4.0.4)
activesupport (= 4.0.4)
builder (~> 3.1.0)
activerecord (4.0.4)
activemodel (= 4.0.4)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.4)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.3)
activesupport (4.0.4)
activemodel (4.1.0)
activesupport (= 4.1.0)
builder (~> 3.1)
activerecord (4.1.0)
activemodel (= 4.1.0)
activesupport (= 4.1.0)
arel (~> 5.0.0)
activesupport (4.1.0)
i18n (~> 0.6, >= 0.6.9)
minitest (~> 4.2)
multi_json (~> 1.3)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
addressable (2.3.5)
arel (4.0.2)
atomic (1.1.16)
tzinfo (~> 1.1)
addressable (2.3.6)
arel (5.0.1.20140414130214)
barber (0.4.2)
ember-source
execjs
@@ -97,10 +92,10 @@ GEM
bcrypt (3.1.7)
bootstrap-sass (2.3.2.2)
sass (~> 3.2)
bourbon (3.1.8)
sass (>= 3.2.0)
bourbon (3.2.0)
sass (~> 3.2)
thor
builder (3.1.4)
builder (3.2.2)
capybara (2.2.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
@@ -113,7 +108,7 @@ GEM
chunky_png (1.3.0)
climate_control (0.0.3)
activesupport (>= 3.0)
cocaine (0.5.3)
cocaine (0.5.4)
climate_control (>= 0.0.3, < 1.0)
coderay (1.1.0)
coffee-rails (4.0.1)
@@ -123,15 +118,15 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.7.0)
compass (0.12.4)
compass (0.12.6)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.2.17)
sass (~> 3.2.19)
compass-rails (1.1.6)
compass (>= 0.12.2)
connection_pool (1.2.0)
cookiejar (0.3.2)
couchbase (1.3.6)
couchbase (1.3.7)
connection_pool (~> 1.0, >= 1.0.0)
multi_json (~> 1.0)
yaji (~> 0.3, >= 0.3.2)
@@ -174,12 +169,12 @@ GEM
handlebars-source
jquery-rails (>= 1.0.17)
railties (>= 3.1)
ember-source (1.4.0)
ember-source (1.5.0)
handlebars-source (~> 1.0)
emblem-rails (0.2.1)
barber-emblem (~> 0.1.1)
ember-rails (>= 0.14.0)
emblem-source (0.3.12)
emblem-source (0.3.15)
erubis (2.7.0)
eventmachine (1.0.3)
execjs (2.0.2)
@@ -203,7 +198,7 @@ GEM
websocket-driver (>= 0.3.1)
font-awesome-rails (4.0.3.1)
railties (>= 3.2, < 5.0)
foundation-rails (5.2.1.0)
foundation-rails (5.2.2.0)
railties (>= 3.1.0)
sass (>= 3.2.0)
fssm (0.2.10)
@@ -220,14 +215,14 @@ GEM
haml (>= 3.1, < 5.0)
railties (>= 4.0.1)
handlebars-source (1.3.0)
hashie (2.0.5)
hashie (2.1.1)
hike (1.2.3)
http_parser.rb (0.6.0)
i18n (0.6.9)
jquery-rails (3.1.0)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (4.2.0)
jquery-ui-rails (4.2.1)
railties (>= 3.2.16)
js-routes (0.9.7)
railties (>= 3.2)
@@ -250,8 +245,8 @@ GEM
mime-types (1.25.1)
mini_magick (3.7.0)
subexec (~> 0.2.1)
mini_portile (0.5.2)
minitest (4.7.5)
mini_portile (0.5.3)
minitest (5.3.3)
multi_json (1.9.2)
multi_xml (0.5.5)
multipart-post (2.0.0)
@@ -291,20 +286,22 @@ GEM
rack-cors (0.2.9)
rack-test (0.6.2)
rack (>= 1.0)
rails (4.0.4)
actionmailer (= 4.0.4)
actionpack (= 4.0.4)
activerecord (= 4.0.4)
activesupport (= 4.0.4)
rails (4.1.0)
actionmailer (= 4.1.0)
actionpack (= 4.1.0)
actionview (= 4.1.0)
activemodel (= 4.1.0)
activerecord (= 4.1.0)
activesupport (= 4.1.0)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.4)
sprockets-rails (~> 2.0.0)
railties (4.0.4)
actionpack (= 4.0.4)
activesupport (= 4.0.4)
railties (= 4.1.0)
sprockets-rails (~> 2.0)
railties (4.1.0)
actionpack (= 4.1.0)
activesupport (= 4.1.0)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.2.2)
rake (10.3.1)
rest-client (1.6.7)
mime-types (>= 1.16)
rqrcode (0.4.2)
@@ -325,15 +322,15 @@ GEM
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
ruby-progressbar (1.4.2)
sass (3.2.18)
sass-rails (4.0.2)
sass (3.2.19)
sass-rails (4.0.3)
railties (>= 4.0.0, < 5.0)
sass (~> 3.2.0)
sprockets (~> 2.8, <= 2.11.0)
sprockets-rails (~> 2.0.0)
simple_form (3.0.1)
actionpack (>= 4.0.0, < 4.1)
activemodel (>= 4.0.0, < 4.1)
sprockets-rails (~> 2.0)
simple_form (3.0.2)
actionpack (~> 4.0)
activemodel (~> 4.0)
simplecov (0.8.2)
docile (~> 1.1.0)
multi_json
@@ -342,10 +339,10 @@ GEM
slim (2.0.2)
temple (~> 0.6.6)
tilt (>= 1.3.3, < 2.1)
slim-rails (2.1.2)
actionpack (>= 3.0, < 4.1)
activesupport (>= 3.0, < 4.1)
railties (>= 3.0, < 4.1)
slim-rails (2.1.4)
actionpack (>= 3.0, < 4.2)
activesupport (>= 3.0, < 4.2)
railties (>= 3.0, < 4.2)
slim (~> 2.0)
slop (3.5.0)
sprockets (2.11.0)
@@ -353,7 +350,7 @@ GEM
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.0.1)
sprockets-rails (2.1.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
@@ -363,9 +360,8 @@ GEM
daemons (>= 1.0.9)
eventmachine (>= 1.0.0)
rack (>= 1.0.0)
thor (0.19.0)
thread_safe (0.3.1)
atomic (>= 1.1.7, < 2)
thor (0.19.1)
thread_safe (0.3.3)
tilt (1.4.1)
tinymce-rails (4.0.19)
railties (>= 3.1.1)
@@ -375,7 +371,8 @@ GEM
turnip (1.2.1)
gherkin (>= 2.5)
rspec (>= 2.0, < 4.0)
tzinfo (0.3.39)
tzinfo (1.1.0)
thread_safe (~> 0.1)
uglifier (2.5.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
@@ -427,10 +424,10 @@ DEPENDENCIES
pry-rails
quiet_assets
rack-cors
rails (= 4.0.4)
rails (= 4.1.0)
rqrcode
rspec-rails
sass-rails (~> 4.0.2)
sass-rails
simple_form
simplecov
simply_stored!
@@ -0,0 +1,5 @@
App.ModalInfoController = Ember.ObjectController.extend
actions:
close: ->
@get('model.cancel').call(@) if @get('model.cancel')
@send 'closeModal'
@@ -28,3 +28,7 @@ App.TableController = Ember.ObjectController.extend
@set 'join_request_sent', true # keeps the button deactivated
toggleProductCategory: (product_category)->
product_category.set 'collapsed', not product_category.get('collapsed')
showProductDescription: (product)->
@send 'openModal', 'modal_info', Ember.Object.create
title: product.get('name')
body: textile(product.get('description'))
@@ -2,5 +2,6 @@ attr = DS.attr
App.Product = DS.Model.extend
name: attr 'string'
price: attr 'number'
description: attr 'string'
product_category: DS.belongsTo('product_category')
product_orders: DS.hasMany('product_order')
@@ -6,6 +6,11 @@ ControllerExtensions = Ember.Mixin.create
if jqXHR.status == 401
App.__container__.lookup('route:application').unauthorized()
handler
showModal: (options={})->
$(document).foundation('reflow') # needed (stupid!!!)
@confirm_cancel = options.cancel
@set 'controllers.application.modal.title', options.title if options.title
@set 'controllers.application.modal.content', options.content if options.content
Ember.ArrayController.reopen ControllerExtensions
Ember.Controller.reopen
needs: ['application']
@@ -47,13 +52,6 @@ Ember.Controller.reopen
##@set 'controllers.application.confirm.content', options.content if options.content
##$('#confirm-modal').foundation('reveal', 'open') # this kills the ember actions
##$('#confirm-modal').css('visibility', 'visible').show()
showModal: (options={})->
#this.container.lookup('view:modal', {title:'Test title'})
#debugger
$(document).foundation('reflow') # needed (stupid!!!)
@confirm_cancel = options.cancel
@set 'controllers.application.modal.title', options.title if options.title
@set 'controllers.application.modal.content', options.content if options.content
#$('#confirm-modal').foundation('reveal', 'open') #this kills the ember actions
#$('#confirm-modal').css('visibility', 'visible').show()
@@ -0,0 +1,5 @@
modal-dialog action="close"
h3.flush--top= title
p==body
hr
button{action 'close'}= t 'modal.info.close'
@@ -25,9 +25,16 @@
unless product_category.collapsed
ul.product_category-products
each product in product_category.products
li
li class="order-product-#{unbound product.id}"
if product.description
button.show-product-description{action showProductDescription product}
span
else
span.no-product-description
a{action addProduct product}= product.name
span.right.currency=currency product.price
button.add-product-to-list{action addProduct product}
span
span.product-price.currency=currency product.price
.large-6.columns= render 'product_orders'
else
.large12
@@ -39,5 +46,8 @@
ul.product_category-products
each product in product_category.products
li
if product.description
button.show-product-description{action showProductDescription product}
span
span= product.name
span.right.currency=currency product.price
@@ -9,6 +9,7 @@
#= require translations
#= require js-routes
#= require_directory .
#= require textile-js
#= require_self
#
# (($) ->
@@ -1,4 +1,4 @@
@import foundation_and_overrides
@import ./foundation_and_overrides
.form-row
@extend .row
@@ -13,6 +13,8 @@
// $rem-base: 16px;
// Allows the use of rem-calc() or lower-bound() in your settings
a.unused-class
display: inline-block
@import "foundation/functions"
// $experimental: true;
@@ -8,8 +8,8 @@ header.top-menu
background-position: left bottom, right bottom
background-image: image-url('theme1/button-bar-left.png'), image-url('theme1/button-bar-right.png')
color: $green
padding-left: 49px
padding-right: 52px
padding-left: 48px
padding-right: 52px
.menu-content
background-color: white
background-repeat: repeat-x
@@ -1,12 +1,37 @@
@import font-awesome
ul.product_category-products
list-style: none
.product_category-title
cursor: pointer
.icon
@extend .fa
@extend .fa-arrow-down
color: #ccc
padding-right: 10px
&.collapsed
@extend .fa-arrow-right
//@import ./foundation_and_overrides
//@import font-awesome
//ul.product_category-products
//list-style: none
//.product_category-title
//cursor: pointer
//.icon
//@extend .fa
//@extend .fa-arrow-down
//color: #ccc
//padding-right: 10px
//&.collapsed
//@extend .fa-arrow-right
//.product_category-products
//.product-price
//float: right
//.show-product-description
//+button($bg: $secondary-color)
//+button-icon-only
//margin-right: 7px
//span
//@extend .fa
//@extend .fa-info
//@extend .fa-lg
//.no-product-description
//// Empty space to match the product description for layout
//display: inline-block
//width: 1.65rem
//.add-product-to-list
//+button($bg: $secondary-color)
//+button-icon-only
//float: right
//margin-left: 5px
//span
//@extend .fa
//@extend .fa-plus
//@extend .fa-lg
@@ -95,7 +95,7 @@ module Suppliers
private
def product_params
params.require(:product).permit(:name, :code, :price, product_category_ids: [])
params.require(:product).permit(:name, :code, :price, :description, product_category_ids: [])
end
end
end
@@ -1,6 +1,7 @@
module Users
class ApplicationController < ::ApplicationController
before_action :user_authentication, :unless => ->(c){ %w(obtain_token).include?(c.action_name) || c.request.format.symbol == :html } # , except: [:obtain_token, :index]
private
def user_authentication
+1
View File
@@ -5,6 +5,7 @@ class Product
property :name
property :code
property :price, type: Float
property :description
#belongs_to :product_category
has_and_belongs_to_many :product_categories, storing_keys: false
+1 -1
View File
@@ -1,4 +1,4 @@
class ProductSerializer < Qwaiter::Serializer
embed :ids, include: true
attributes :name, :price
attributes :name, :price, :description
end
+1 -1
View File
@@ -7,7 +7,7 @@ html lang="en"
title Qwaiter
= stylesheet_link_tag "user/foundation/application"
= javascript_include_tag "vendor/modernizr"
/= javascript_include_tag 'http://connect.facebook.net/en_US/all.js'
= javascript_include_tag 'http://connect.facebook.net/en_US/all.js'
= javascript_include_tag "user/flat/application"
- if ENV['QWAITER_MOBILE_EXPORT'] == 'yes'
javascript:
+8 -3
View File
@@ -1,20 +1,25 @@
= form_for [:suppliers, @product] do |f|
= render 'error_messages', target: @product
.form-row
.form-row class=(f.object.errors[:name].any? ? 'error' : nil)
.form-label
= f.label :name, data: {t: 'attributes.product.name'}
.form-field
= f.text_field :name
.form-row
.form-row class=(f.object.errors[:code].any? ? 'error' : nil)
.form-label
= f.label :code, data: {t: 'attributes.product.code'}
.form-field
= f.text_field :code
.form-row
.form-row class=(f.object.errors[:price].any? ? 'error' : nil)
.form-label
= f.label :price, data: {t: 'attributes.product.price'}
.form-field
= f.text_field :price
.form-row class=(f.object.errors[:description].any? ? 'error' : nil)
.form-label
= f.label :description, data: {t: 'attributes.product.description'}
.form-field
= f.text_area :description
/= f.input :name
/= f.input :code
/= f.input :price
+3 -3
View File
@@ -1,17 +1,17 @@
-# DEPRICATED
= form_for [:suppliers, @section], html: {class: 'form-horizontal' } do |f|
= render 'error_messages', target: @section
.form-row class=(@section.errors[:title].any? ? 'error' : nil)
.form-row class=(f.object.errors[:title].any? ? 'error' : nil)
.form-label
= f.label :title
.form-field
= f.text_field :title
.form-row class=(@section.errors[:width].any? ? 'error' : nil)
.form-row class=(f.object.errors[:width].any? ? 'error' : nil)
.form-label
= f.label :width
.form-field
= f.number_field :width
.form-row class=(@section.errors[:height].any? ? 'error' : nil)
.form-row class=(f.object.errors[:height].any? ? 'error' : nil)
.form-label
= f.label :height
.form-field
+3
View File
@@ -96,3 +96,6 @@ en:
closed: 'Closed'
datepicker:
no_date: 'Pick a date'
modal:
info:
close: OK
+3
View File
@@ -96,3 +96,6 @@ nl:
closed: 'Afgesloten'
datepicker:
no_date: 'Selecteer een datum'
modal:
info:
close: OK
@@ -0,0 +1,12 @@
Feature: Getting product information during an order
@javascript
Scenario: Happy flow
Given There is an open supplier with a menu
And the product 'Heineken beer' has description 'Brewed in Amsterdam'
And I am signed in as a user
#And I open the debugger
And I am on the user homepage
#When the user scans a table QR code
#And the user clicks on the more info button for the product with name 'Heineken beer'
#Then the page should have content 'Brewed in Amsterdam'
@@ -0,0 +1,6 @@
step "the product :product_name has description :product_description" do |product_name, product_description|
product = @product && @product.name == product_name ? @product : Product.find_by_name(product_name)
product.description = product_description
product.save or raise "Cannot save product: #{product.errors.full_messages.to_sentence}"
@product ||= product
end
@@ -27,3 +27,8 @@ step "there is a signed in user with an active order" do
step "I am signed in as a user"
step "the user has an active order"
end
step "the user clicks on the more info button for the product with name :product_name" do |product_name|
product = @product && @product.name == product_name ? @product : Product.find_by_name(product_name)
find(".order-product-#{product.id} .show-product-description").click
end
File diff suppressed because it is too large Load Diff