Style upgrades and emberified supplier lists

This commit is contained in:
2014-04-24 16:41:08 +02:00
parent 546e4499ea
commit 27a1022eb4
56 changed files with 321 additions and 139 deletions
@@ -1,18 +1,18 @@
Qsupplier.App.IndexController = Ember.ObjectController.extend Qsupplier.App.IndexController = Ember.ObjectController.extend
needs: ['application'] needs: ['application']
active_lists: (-> active_lists: (->
if @get('active_section_id') if @get('active_section.id')
@get('lists').filter (l)=>( l.get('section.id') == @get('active_section_id') && l.get('state') == 'active' ) @get('lists').filter (l)=>( l.get('section.id') == @get('active_section.id') && l.get('state') == 'active' )
else else
@get('lists').filterProperty('state', 'active') @get('lists').filterProperty('state', 'active')
).property('lists.@each.state', 'active_section_id') ).property('lists.@each.state', 'active_section.id')
active_orders: (-> active_orders: (->
if @get('active_section_id') if @get('active_section.id')
@get('orders').filter (o)=>( o.get('section.id') == @get('active_section_id') && o.get('needs_supplier_attention') ) @get('orders').filter (o)=>( o.get('section.id') == @get('active_section.id') && o.get('needs_supplier_attention') )
else else
@get('orders').filter (o)->( o.get('needs_supplier_attention') ) @get('orders').filter (o)->( o.get('needs_supplier_attention') )
).property('orders.@each.state', 'active_section_id') ).property('orders.@each.state', 'active_section.id')
markListAsHelped: (id)-> markListAsHelped: (id)->
if list = Qsupplier.App.List.findCached(id) if list = Qsupplier.App.List.findCached(id)
@@ -0,0 +1,6 @@
Qsupplier.App.ListController = Ember.ObjectController.extend
needs: ['application', 'lists', 'list'] #wtf? list, otherwise an Ember error
list: (-> @get('model')).property('model')
showTotal: (->
if @get('list.orders.length') && @get('list.orders.length') > 1 then true else false
).property('list.orders.length')
@@ -1,4 +0,0 @@
Qsupplier.App.ListsController = Ember.ArrayController.extend
dateChanged: (->
@set('model', @store.find('list', date: @get('date')))
).observes('date')
@@ -0,0 +1,8 @@
Qsupplier.App.ListsIndexController = Ember.ArrayController.extend
dateChanged: (->
if @get('date')
@set('model', @store.find('list', date: @get('date')))
else
@set('model', @store.find('list'))
).observes('date')
lists: (-> @get('model')).property('model')
@@ -1,5 +1,5 @@
Qsupplier.App.SectionsIndexController = Ember.ArrayController.extend Qsupplier.App.SectionsIndexController = Ember.ArrayController.extend
needs: ['application', 'sections'] needs: ['application', 'sections', 'index']
sections: (-> @get('controllers.sections.model')).property('controllers.sections.model') sections: (-> @get('controllers.sections.model')).property('controllers.sections.model')
sectionQrCodesUrl: ((a,b,c)-> sectionQrCodesUrl: ((a,b,c)->
debugger debugger
@@ -8,3 +8,7 @@ Qsupplier.App.SectionsIndexController = Ember.ArrayController.extend
newPath: Routes.new_suppliers_section_path() newPath: Routes.new_suppliers_section_path()
qrPath: (section_id)-> qrPath: (section_id)->
Routes.qr_codes_suppliers_tables_path section_id: section_id Routes.qr_codes_suppliers_tables_path section_id: section_id
actions:
showDashboardOrders: (section)->
@transitionToRoute('index').then =>
@get('controllers.index').set 'active_section', section
@@ -0,0 +1,4 @@
attr = DS.attr
Qsupplier.App.JoinRequest= DS.Model.extend
list: DS.belongsTo('list')
user: DS.belongsTo('user')
@@ -4,6 +4,7 @@ Qsupplier.App.List = DS.Model.extend
needs_help: attr 'boolean' needs_help: attr 'boolean'
needs_payment: attr 'boolean' needs_payment: attr 'boolean'
user_requests_closing: attr('boolean') user_requests_closing: attr('boolean')
users: DS.hasMany('user')
is_paid: attr 'boolean' is_paid: attr 'boolean'
has_active_orders: attr 'boolean' has_active_orders: attr 'boolean'
price: attr 'number' price: attr 'number'
@@ -28,6 +29,9 @@ Qsupplier.App.List = DS.Model.extend
@set 'needs_payment', true @set 'needs_payment', true
markIsPaid: -> markIsPaid: ->
@set 'needs_payment', false @set 'needs_payment', false
total: (->
@get('orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
).property('orders.@each.total')
close: -> close: ->
@markClosed() @markClosed()
@@ -36,3 +40,4 @@ Qsupplier.App.List = DS.Model.extend
is_helped: -> is_helped: ->
@markHelped() @markHelped()
$.post Routes.supplier_mark_list_as_helped_path(), list_id: @id $.post Routes.supplier_mark_list_as_helped_path(), list_id: @id
sorted_orders: (-> @get('orders').sortBy('created_at').reverseObjects()).property('orders.@each.isLoaded')
@@ -1,4 +1,6 @@
attr = DS.attr attr = DS.attr
Qsupplier.App.User= DS.Model.extend Qsupplier.App.User= DS.Model.extend
uid: attr 'string' facebook_id: attr('string')
#active_list: DS.belongsTo('list') email: attr('string')
list: DS.belongsTo('list') # in ember scope not many to many (yet)
join_requests: DS.hasMany('join_request')
@@ -10,6 +10,7 @@ Qsupplier.App.IndexRoute = Ember.Route.extend
#lists: @store.filter 'list', (l)-> l.get('state') == 'active' # DOES NOT WORK!!!! (yet) #lists: @store.filter 'list', (l)-> l.get('state') == 'active' # DOES NOT WORK!!!! (yet)
# use filter to create a scope on all the records # use filter to create a scope on all the records
lists: @store.filter 'list', -> true lists: @store.filter 'list', -> true
# mayby @store.all 'list' will work better!!!! (2014-04-24 a more experienced benjamin :)
orders: @store.filter 'order', -> true orders: @store.filter 'order', -> true
sections: @store.find 'section' sections: @store.find 'section'
setupController: (controller, model)-> setupController: (controller, model)->
@@ -1,4 +1,4 @@
Qsupplier.App.ListsRoute = Ember.Route.extend Qsupplier.App.ListsIndexRoute = Ember.Route.extend
#model: -> @store.find 'list' #model: -> @store.find 'list'
setupController: (controller, model)-> setupController: (controller, model)->
controller.set 'date', (new Date()).toISOString().substr(0,10) controller.set 'date', (new Date()).toISOString().substr(0,10) unless controller.get('date')
@@ -0,0 +1,19 @@
.display-row
.display-label=t 'attributes.list.created_at'
.display-field=time list.created_at
each user in list.users
img.facebook-image src="http://graph.facebook.com/#{unbound user.facebook_id}/picture?type=square" alt="f"
if list.orders
.list-orders-container
each order in list.sorted_orders
.list-order-container class=order.state
= order.display
span.currency= currency order.total
span.created_at= time order.created_at
if showTotal
.list-orders-total.total
= t 'total'
span.currency= currency list.total
else
p
span=t 'active_list.no_orders_explanation'
@@ -1,6 +1,6 @@
.page-header .page-header
div.pull-right div.dashboard-section-selection
'{{view 'Qsupplier.App.HomeSectionSelectorView' content=controller.sections prompt=controllers.application.supplier.name}} '{{view 'Qsupplier.App.HomeSectionSelectorView' selectionBinding="controller.active_section" content=controller.sections prompt=controllers.application.supplier.name}}
'{{view 'Qsupplier.App.HomeSectionJumperView'}} '{{view 'Qsupplier.App.HomeSectionJumperView'}}
h3 {{t 'active_lists.title'}} h3 {{t 'active_lists.title'}}
.well .well
@@ -0,0 +1,5 @@
.row
h2=t 'models.list'
partial "list_content"
link-to 'lists'
span Go to lists
@@ -1,26 +1 @@
h1=t 'models.plural.list' = outlet
Qsupplier.App.ListDisplayDateSelector valueBinding=date
if controller.model
table.table
thead
tr
th.state=t 'attributes.list.state'
th.boolean=t 'attributes.list.needs_help'
th.boolean=t 'attributes.list.needs_payment'
th.timestamp=t 'attributes.list.closed_at'
th.table_number=t 'models.table'
th.currentcy=t 'attributes.list.price'
th.timestamp=t 'attributes.list.created_at'
tbody
each list in controller
tr
td.state=state 'list' list.state
td.boolean.needs_help=boolean list.needs_help
td.boolean.needs_payment=boolean list.needs_payment
td.timestamp=time list.closed_at
td.table_number 7
td.currency=currency list.price
td.timestamp=time list.created_at
else
.row
.panel=t 'list.none_found'
@@ -0,0 +1,28 @@
h1=t 'models.plural.list'
Qsupplier.App.ListDisplayDateSelector valueBinding="date"
if lists
table.table
thead
tr
th.state=t 'attributes.list.state'
th.boolean=t 'attributes.list.needs_help'
th.boolean=t 'attributes.list.needs_payment'
th.timestamp=t 'attributes.list.closed_at'
th.table_number=t 'models.table'
th.currentcy=t 'attributes.list.price'
th.timestamp=t 'attributes.list.created_at'
tbody
each list in lists
tr
td.state
link-to 'list' list.id
= state 'list' list.state
td.boolean.needs_help=boolean list.needs_help
td.boolean.needs_payment=boolean list.needs_payment
td.timestamp=time list.closed_at
td.table_number 7
td.currency=currency list.price
td.timestamp=time list.created_at
else
.row
.panel=t 'list.none_found'
@@ -1,5 +1,5 @@
.section-tabs-container .section-tabs-container
link-to 'sections' | b link-to 'sections' class="goto-sections-index-tab-header": span
each section in sections each section in sections
view Qsupplier.App.SectionTabHeaderView context=section view Qsupplier.App.SectionTabHeaderView context=section
.section-manage-tables.pull-right .section-manage-tables.pull-right
@@ -31,6 +31,7 @@ if sections
/td.currency=currency list.price /td.currency=currency list.price
/td.timestamp=time list.created_at /td.timestamp=time list.created_at
td.actions td.actions
a.section-dashboard-orders{action showDashboardOrders section}: span
a.table-qr-codes{path qr_codes_suppliers_tables section_id=section.id} a.table-qr-codes{path qr_codes_suppliers_tables section_id=section.id}
span span
else else
@@ -1,11 +1,9 @@
Qsupplier.App.HomeSectionJumperView = Ember.View.extend Qsupplier.App.HomeSectionJumperView = Ember.View.extend
tagName: 'a' tagName: 'a'
classNames: ['main-board-section-jumper'] classNames: ['main-board-section-jumper']
attributeBindings: ['href']
#href: (-> Routes.suppliers_section_path(@get('controller.active_section_id') || 'nothing')).property('controller.active_section_id')
href: '#' href: '#'
isVisible: (-> !!@get('controller.active_section_id') ).property('controller.active_section_id') isVisible: (-> !!@get('controller.active_section.id') ).property('controller.active_section.id')
template: Ember.Handlebars.compile('=>') template: Ember.Handlebars.compile('<span class="fa fa-lg fa-chevron-circle-right"></span>')
click: (e)-> click: (e)->
e.preventDefault() e.preventDefault()
@get('controller').transitionToRoute 'section', @get('controller.active_section_id') @get('controller').transitionToRoute 'section', @get('controller.active_section.id')
@@ -3,6 +3,6 @@ HomeSectionOption = Ember.SelectOption.extend
Qsupplier.App.HomeSectionSelectorView = Ember.Select.extend Qsupplier.App.HomeSectionSelectorView = Ember.Select.extend
classNames: 'section_selector' classNames: 'section_selector'
optionView: HomeSectionOption optionView: HomeSectionOption
valueBinding: 'controller.active_section_id' #valueBinding: 'controller.active_section_id'
optionValuePath: 'content.id' optionValuePath: 'content.id'
optionLabelPath: 'select_label' optionLabelPath: 'select_label'
@@ -1,2 +1,5 @@
App.ListController = Ember.ObjectController.extend App.ListController = Ember.ObjectController.extend
list: (-> @get('model')).property('model') list: (-> @get('model')).property('model')
showTotal: (->
if @get('list.orders.length') && @get('list.orders.length') > 1 then true else false
).property('list.orders.length')
@@ -4,6 +4,8 @@ App.ProductOrdersController = Ember.ArrayController.extend
#Math.round(Math.random()*100) #Math.round(Math.random()*100)
@get('model').getEach('total').reduce(((sum, total) -> sum + total), 0) @get('model').getEach('total').reduce(((sum, total) -> sum + total), 0)
).property('model.@each.quantity') ).property('model.@each.quantity')
product_orders: (->@get('model')).property('model')
showTotal: (-> if @get('model.length') && @get('model.length') > 1 then true else false ).property('model.length')
actions: actions:
clearProductOrders: -> clearProductOrders: ->
#TODO: make clearing of unpersisted product orders #TODO: make clearing of unpersisted product orders
@@ -7,7 +7,7 @@ if list.orders
= order.display = order.display
span.currency= currency order.total span.currency= currency order.total
span.created_at= time order.created_at span.created_at= time order.created_at
if displayTotal if showTotal
.list-orders-total.total .list-orders-total.total
= t 'total' = t 'total'
span.currency= currency model.total span.currency= currency model.total
@@ -4,7 +4,7 @@ if modelDisabled
.clearfix .clearfix
.panel .panel
ul.product-orders ul.product-orders
each product_order in controller each product_order in product_orders
li.product_order li.product_order
= product_order.quantity = product_order.quantity
| x | x
@@ -14,8 +14,9 @@ if modelDisabled
span.currency=currency product_order.total span.currency=currency product_order.total
else else
li= t 'product_orders.no_orders' li= t 'product_orders.no_orders'
li.total if showTotal
= t 'product_orders.total' li.total
span.right.currency=currency orderTotal = t 'product_orders.total'
if model span.right.currency=currency orderTotal
a.tiny.button.right{action orderProducts} href="#"= t 'product_orders.order_button' if product_orders
a.order-selected-products-button{action orderProducts} href="#"= t 'product_orders.order_button'
@@ -1,5 +1,3 @@
@import font-awesome
@import ./foundation_and_overrides
.form-actions .form-actions
.form-action-submit .form-action-submit
+button($bg: $button-submit-color, $padding: $button-sml) +button($bg: $button-submit-color, $padding: $button-sml)
@@ -1,6 +1,3 @@
@import constants
@import font-awesome
@import foundation_and_overrides
header.top-menu header.top-menu
height: 90px height: 90px
background-color: transparent background-color: transparent
@@ -1,4 +1,3 @@
@import constants
aside.side-menu aside.side-menu
background-color: #444 background-color: #444
position: fixed position: fixed
@@ -1,4 +1,3 @@
@import font-awesome
#product-category-list #product-category-list
list-style: none list-style: none
li li
@@ -1,4 +1,3 @@
@import ./foundation_and_overrides
.products_preview-date .products_preview-date
.products_preview-time-container .products_preview-time-container
float: left float: left
@@ -0,0 +1,7 @@
//$qbrown: #634227
$qbrown: #853d15
$qbrown-active: lighten($qbrown, 20%)
$green: #7BB459 //Heineken
//$wood: image-url('textures/wood001-vertical.jpg')
$wood: image-url('textures/theme1.jpg')
$background-brown: #57351f
@@ -1,5 +1,6 @@
@import foundation_and_overrides .dashboard-section-selection
float: right
white-space: nowrap
.active-lists-table .active-lists-table
width: 100% width: 100%
.mark_list_as_helped .mark_list_as_helped
@@ -1,5 +1,3 @@
@import ./foundation_and_overrides
.display-row .display-row
@extend .row @extend .row
.display-label .display-label
@@ -1,5 +1,3 @@
@import ./foundation_and_overrides
.form-row .form-row
@extend .row @extend .row
.form-label .form-label
@@ -0,0 +1,36 @@
td.boolean
+table-fit
&.needs_help
.boolean-true
@extend .fa
@extend .fa-exclamation
&.needs_payment
.boolean-true
@extend .fa
@extend .fa-money
.list-orders-container
.currency
float: right
list-style: none
$padding: 6px 0 6px 35px
.list-order-container
background-position: left center
background-repeat: no-repeat
+grid-column(12)
padding: $padding
border-bottom: 1px solid #eee
&.active
background-image: image-url('icons/order-check.png')
&.delivered
background-image: image-url('icons/order-doublecheck.png')
.created_at
float: right
padding-right: 20px
padding-left: 10px
.list-orders-total
+grid-column(12)
padding: $padding
border-top: 2px solid #444
font-weight: bold
@@ -1,7 +1,4 @@
$side-spacing: 0px $side-spacing: 0px
@import constants
@import ./foundation_and_overrides
@import font-awesome
.supplier-is-closed .supplier-is-closed
+alert($bg: $secondary-color) +alert($bg: $secondary-color)
.close .close
@@ -1,6 +1,3 @@
@import constants
@import ./foundation_and_overrides
@import font-awesome
table table
&.table &.table
// Bootstrap behaviour // Bootstrap behaviour
@@ -36,3 +33,10 @@ table
span span
@extend .fa @extend .fa
@extend .fa-times @extend .fa-times
.section-dashboard-orders
+button($bg: $secondary-color)
+button-icon-only
margin-right: 0.7rem
span
@extend .fa
@extend .fa-list-alt
@@ -24,3 +24,10 @@
content: '' content: ''
display: block display: block
clear: left clear: left
.goto-sections-index-tab-header
float: left
span
@extend .fa
@extend .fa-share
@extend .fa-lg
@extend .fa-rotate-270
@@ -1,9 +0,0 @@
/*
*= require ./foundation_and_overrides
*= require 'jquery-ui-1.8.23.custom.css'
*= require qtip
*= require_directory ../base1-shared
*= require pickdate
*= require_directory .
*= require_self
*/
@@ -0,0 +1,18 @@
//= require qtip
//= require_directory ../base1-shared
//= require pickdate
@import ./qconstants
@import ./foundation_and_overrides
@import ./qstructure
@import ./qicons
@import ./qdashboard
@import ./qdisplays
@import ./form_actions
@import ./qforms
@import ./menu_main
@import ./menu_side
@import ./product_categories
@import ./products_preview
@import ./qtables
@import ./section_tab_headers
@import ./qlists
@@ -1,12 +0,0 @@
@import font-awesome
@import ./foundation_and_overrides
td.boolean
+table-fit
&.needs_help
.boolean-true
@extend .fa
@extend .fa-exclamation
&.needs_payment
.boolean-true
@extend .fa
@extend .fa-money
@@ -15,3 +15,6 @@ ul.product-orders
.icon .icon
@extend .fa @extend .fa
@extend .fa-times @extend .fa-times
.order-selected-products-button
float: right
+button($padding: $button-tny)
@@ -21,7 +21,7 @@ module Suppliers
respond_to do |format| respond_to do |format|
format.html # index.html.erb format.html # index.html.erb
format.json { render json: @lists, each_serializer: ListSerializer } format.json { render json: @lists, each_serializer: SupplierListSerializer }
end end
end end
@@ -64,7 +64,7 @@ module Suppliers
if params[:old_style] then if params[:old_style] then
render json: @list.with_orders_as_json render json: @list.with_orders_as_json
else else
render json: @list render json: @list, serializer: SupplierListSerializer
end end
end end
end end
@@ -0,0 +1,19 @@
class SupplierListSerializer < Qwaiter::Serializer
# user ids for facebook pictures
self.root = :list
embed :ids, include: true
attributes :extended_version, :state, :needs_help, :needs_payment, :user_requests_closing, :is_paid, :price,
:table_id, :table_number, :section_id, :user_ids, :supplier_id, :closed_at
has_many :orders
#has_many :product_categories
has_one :table, serializer: SupplierTableSerializer
has_many :join_requests
has_many :users, serializer: SupplierUserSerializer
#def has_active_orders
#object.has_active_orders?
#end
def extended_version
true
end
end
@@ -0,0 +1,9 @@
class SupplierSupplierSerializer < Qwaiter::Serializer
self.root = :supplier
attributes :extended_version, :open, :name
def extended_version
false
end
end
@@ -0,0 +1,6 @@
class SupplierTableSerializer < Qwaiter::Serializer
self.root = :table
embed :ids, include: true
attributes :number, :width, :height, :position_x, :position_y, :section_id, :occupied, :needs_help
has_one :supplier, serializer: SupplierSupplierSerializer
end
@@ -0,0 +1,4 @@
class SupplierUserSerializer < Qwaiter::Serializer
self.root = :user
attributes :email, :facebook_id
end
+1 -1
View File
@@ -1,7 +1,7 @@
class UserListSerializer < Qwaiter::Serializer class UserListSerializer < Qwaiter::Serializer
# user ids for facebook pictures # user ids for facebook pictures
#embed :ids #embed :ids
attributes :state, :needs_help, :needs_payment, :user_requests_closing, :is_paid, :price, :table_id, :table_number, :section_id, :user_ids, :supplier_name, :closed_at attributes :state, :needs_help, :needs_payment, :user_requests_closing, :is_paid, :price, :table_id, :table_number, :section_id, :user_ids, :supplier_name, :closed_at, :supplier_id
#def has_active_orders #def has_active_orders
#object.has_active_orders? #object.has_active_orders?
+37 -35
View File
@@ -1,35 +1,37 @@
.page-header= title t('supplier.lists.show.title', list: List.model_name.human) - content_for :head do
dl.dl-horizontal = javascript_include_tag 'supplier/app/application'
dt= List.human_attribute_name(:created_at) /.page-header= title t('supplier.lists.show.title', list: List.model_name.human)
dd= l @list.created_at, format: :short /dl.dl-horizontal
dt= t('supplier.lists.show.users') /dt= List.human_attribute_name(:created_at)
dd= @list.users.map(&:supplier_name).join(', ') /dd= l @list.created_at, format: :short
.display-row /dt= t('supplier.lists.show.users')
.display-label /dd= @list.users.map(&:supplier_name).join(', ')
span data-t='attributes.list.created_at' /.display-row
.display-field /.display-label
span data-time=@list.created_at.iso8601 /span data-t='attributes.list.created_at'
.well /.display-field
table#list-table.table.list-table /span data-time=@list.created_at.iso8601
thead /.well
tr /table#list-table.table.list-table
th= Order.model_name.human /thead
th.currency= Product.human_attribute_name(:price) /tr
tbody /th= Order.model_name.human
tr /th.currency= Product.human_attribute_name(:price)
td colspan=2 = slider_image /tbody
tfoot /tr
tr /td colspan=2 = slider_image
td /tfoot
td.currency /tr
strong.list-total /td
script#list-order-template[type="text/html"]= render 'supplier/list_order.mustache' /td.currency
.form-actions /strong.list-total
= link_to t("helpers.links.back"), suppliers_lists_path(date: @list.created_at.strftime('%Y-%m-%d')), class: 'btn' /script#list-order-template[type="text/html"]= render 'supplier/list_order.mustache'
' /.form-actions
= link_to t('helpers.links.edit'), [:edit, :suppliers, @list], class: 'btn btn-info' /= link_to t("helpers.links.back"), suppliers_lists_path(date: @list.created_at.strftime('%Y-%m-%d')), class: 'btn'
- content_for :footer do /'
javascript: /= link_to t('helpers.links.edit'), [:edit, :suppliers, @list], class: 'btn btn-info'
jQuery(function(){ /- content_for :footer do
Qsupplier.load_list('#{@list.id}'); /javascript:
}) /jQuery(function(){
/Qsupplier.load_list('#{@list.id}');
/})
+9
View File
@@ -0,0 +1,9 @@
class Symbol
def to_json(*)
to_s
end
def as_json(*)
to_s
end
end
+1
View File
@@ -1,5 +1,6 @@
en: en:
user: user:
total: Total
messages: messages:
cannot_order_on_non_active_list: You cannot place an order on a closed list cannot_order_on_non_active_list: You cannot place an order on a closed list
no_active_list: There is no active list no_active_list: There is no active list
+1
View File
@@ -1,5 +1,6 @@
nl: nl:
user: user:
total: Totaal
messages: messages:
cannot_order_on_non_active_list: Je kan niet bestellen op een gesloten lijst cannot_order_on_non_active_list: Je kan niet bestellen op een gesloten lijst
no_active_list: Er is momenteel geen lijst actief no_active_list: Er is momenteel geen lijst actief
@@ -7,12 +7,12 @@ end
step "the user clicks on the order product button :product_name" do |product_name| step "the user clicks on the order product button :product_name" do |product_name|
@last_product = instance_variable_get product_name.underscore.gsub(/\s/, '_').prepend('@') @last_product = instance_variable_get product_name.underscore.gsub(/\s/, '_').prepend('@')
button = find ".order-product-#{@last_product.id}" button = find ".order-product-#{@last_product.id} .add-product-to-list"
button.click button.click
end end
step "the user clicks on the user order button" do step "the user clicks on the user order button" do
find('#active-order-table .btn-primary').click find('.order-selected-products-button').click
sleep 1 sleep 1
end end
+23 -1
View File
@@ -1,14 +1,36 @@
require 'spec_helper' require 'spec_helper'
describe ProductCategory do describe ProductCategory do
let(:all_week){ Array.new(7, 1) }
let(:show_saturday){ [0,0,0,0,0,0,1] }
let(:show_sunday){ [1,0,0,0,0,0,0] }
describe '#week_days' do describe '#week_days' do
let(:product_category) { create :product_category } let(:product_category) { create :product_category }
subject { product_category } subject { product_category }
let(:default) { Array.new(7, 1) } let(:default) { all_week }
its(:week_days) { should == default } its(:week_days) { should == default }
it "typecasts strings into integers" do it "typecasts strings into integers" do
subject.week_days = Array.new(7, "0") subject.week_days = Array.new(7, "0")
subject.week_days.should == Array.new(7, 0) subject.week_days.should == Array.new(7, 0)
end end
end end
describe '#for_supplier_in_time' do
subject{ described_class }
let(:supplier){ create :supplier, time_zone: 'Tijuana', night_offset: 150 }
it 'works for a normal product category' do
c1 = create :product_category, supplier: supplier, name: 'Lunch', full_day: true, week_days: all_week
c2 = create :product_category, supplier: supplier, name: 'Happy hour', full_day: false, week_days: all_week, start_from: 1320, end_on: 1380 # from 22 to 23 hour
subject.for_supplier_in_time(supplier, Time.now.beginning_of_day + 1300.minutes).should == [c1]
subject.for_supplier_in_time(supplier, Time.now.beginning_of_day + 1350.minutes).should == [c1, c2]
end
it 'finds sunday morning products on saturday categories' do
c1 = create :product_category, supplier: supplier, name: 'Lunch', full_day: true, week_days: show_saturday
c2 = create :product_category, supplier: supplier, name: 'Sunday special', full_day: true, week_days: show_sunday
end
end
end end
+11
View File
@@ -0,0 +1,11 @@
require 'spec_helper'
describe Symbol do
it 'to_json becomes a string in json format' do
:abc.to_json.should == 'abc'
end
it 'as_json becomes a string in json format' do
:abc.as_json.should == 'abc'
end
end