Many improvements and fixes
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
Qsupplier.App.ApplicationController = Ember.Controller.extend
|
||||
active_section: null
|
||||
init: ->
|
||||
#success = (supplier)=>
|
||||
## A supplier record with id current and with the content of the returned supplier is created
|
||||
|
||||
@@ -7,6 +7,7 @@ Qsupplier.App.IndexController = Ember.ObjectController.extend
|
||||
@get('lists').filterProperty('state', 'active')
|
||||
).property('lists.@each.state', 'active_section.id')
|
||||
|
||||
active_section: (-> @get('controllers.application.active_section')).property('controllers.application.active_section')
|
||||
active_orders: (->
|
||||
if @get('active_section.id')
|
||||
@get('orders').filter (o)=>( o.get('section.id') == @get('active_section.id') && o.get('needs_supplier_attention') )
|
||||
@@ -39,4 +40,3 @@ Qsupplier.App.IndexController = Ember.ObjectController.extend
|
||||
@transitionToRoute 'list', id
|
||||
showListInfo: (view, link)->
|
||||
debugger
|
||||
|
||||
|
||||
@@ -13,3 +13,6 @@ Qsupplier.App.SectionsIndexController = Ember.ArrayController.extend
|
||||
@transitionToRoute('index').then =>
|
||||
@get('controllers.index').set 'active_section', section
|
||||
addSection: -> @send 'openModal', 'modal_add_section', @get('model')
|
||||
goToSection: (section)->
|
||||
@set 'controllers.application.active_section', section
|
||||
@transitionToRoute 'section', section.id
|
||||
|
||||
@@ -23,7 +23,7 @@ Qsupplier.App.Order = DS.Model.extend
|
||||
@set 'state', 'cancelled'
|
||||
total: (->
|
||||
@get('product_orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
|
||||
).property('product_orders.@each.quantity', 'product_orders.@each.product.@each.price')
|
||||
).property('product_orders.@each.total')
|
||||
|
||||
display: (->
|
||||
@get('product_orders').map((po) -> "#{po.get('quantity')} x #{po.get('product.name')}").join(', ')
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
attr = DS.attr
|
||||
Qsupplier.App.ProductOrder = DS.Model.extend
|
||||
quantity: attr 'number', defaultValue: 1
|
||||
price: attr 'number'
|
||||
product: DS.belongsTo('product')
|
||||
order: DS.belongsTo('order')
|
||||
increment: ->
|
||||
@set('quantity', @get('quantity') + 1)
|
||||
total: (-> @get('quantity') * @get('product.price')).property('quantity', 'product.price')
|
||||
total: (-> @get('quantity') * @get('price')).property('quantity', 'price')
|
||||
|
||||
@@ -2,9 +2,9 @@ td.status-icons
|
||||
if view.content.needs_help
|
||||
span.icon.needs-help
|
||||
if view.content.needs_payment
|
||||
|
|
||||
|
|
||||
span.icon.needs-payment
|
||||
td.numeric.table_number {{view.content.table.number}}
|
||||
td.numeric.table_number: Qsupplier.App.TableNumberWithInfoView contextBinding="view.content"
|
||||
td.section_title {{view.content.section.title}}
|
||||
td.currency.total_list_amount {{currency view.content.total}}
|
||||
td.actions
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
td.status-icons
|
||||
span.active-order.fa.fa-check.fa-lg
|
||||
td {{view.content.display}}
|
||||
td.numeric.table_number
|
||||
view Qsupplier.App.ActiveOrderTableNumberView contextBinding="view.content"
|
||||
td.section_title {{view.content.list.section.title}}
|
||||
td.currency {{currency view.content.total }}
|
||||
td= view.content.display
|
||||
td.numeric.table_number: Qsupplier.App.TableNumberWithInfoView contextBinding="view.content.list"
|
||||
td.section_title= view.content.list.section.title
|
||||
td.currency=currency view.content.total
|
||||
td.actions
|
||||
if view.content.placed
|
||||
button.mark_order_active{ action markOrderActive view.content.id}
|
||||
@@ -13,7 +12,7 @@ td.actions
|
||||
/button.hide.mark-order-active{ action markOrderActive view.content.id}
|
||||
span.button-icon
|
||||
span.button-text=t 'order.being_processed'
|
||||
button.mark_order_delivered{ action markOrderDelivered view.content.id}
|
||||
button.mark_order_delivered{ action markOrderDelivered view.content.id }
|
||||
span.fa.fa-2x.fa-shifted-stack
|
||||
span.fa-shifted.fa-check
|
||||
span.fa-shifted.fa-check
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
.number= list.table.number
|
||||
.extra-list-info
|
||||
img.spinner src="/assets/spinner.gif" alt=""
|
||||
@@ -1,6 +1,6 @@
|
||||
.page-header
|
||||
div.dashboard-section-selection
|
||||
Qsupplier.App.HomeSectionSelectorView selectionBinding="controller.active_section" content=controller.sections prompt=controllers.application.supplier.name
|
||||
Qsupplier.App.HomeSectionSelectorView selectionBinding="controller.controllers.application.active_section" content=controller.sections prompt=controllers.application.supplier.name
|
||||
Qsupplier.App.HomeSectionJumperView
|
||||
h3=t 'active_lists.title'
|
||||
.well
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
.section-tabs-container
|
||||
link-to 'sections' class="goto-sections-index-tab-header": span
|
||||
each section in sections
|
||||
view Qsupplier.App.SectionTabHeaderView context=section
|
||||
Qsupplier.App.SectionTabHeaderView context=section
|
||||
a.add-section{action "addSection"}: span
|
||||
.section-manage-tables.pull-right
|
||||
if editmode
|
||||
|
||||
@@ -18,8 +18,7 @@ if sections
|
||||
each section in sections
|
||||
tr
|
||||
td
|
||||
link-to 'section' section
|
||||
=section.title
|
||||
a{ action "goToSection" section}= section.title
|
||||
td
|
||||
span.table-count= section.tables.length
|
||||
td.numeric= section.width
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
.number= table.number
|
||||
.extra-list-info
|
||||
span.loading.medium
|
||||
@@ -1,10 +0,0 @@
|
||||
Qsupplier.App.ActiveOrderTableNumberView = Ember.View.extend
|
||||
tagName: 'span'
|
||||
templateName: 'active_order_table_number'
|
||||
classNames: 'active_order_table_number'
|
||||
click: ->
|
||||
$el = $(@get('element')).find('.extra-list-info')
|
||||
return $el.hide() if $el.is(':visible')
|
||||
$el.show()
|
||||
$.get Routes.extra_info_suppliers_list_path(@get('context.list.id')), (res)->
|
||||
$el.html(res)
|
||||
@@ -3,6 +3,7 @@ Qsupplier.App.SectionTabHeaderView = Ember.View.extend DragNDrop.Droppable,
|
||||
classNames: ['section-tab-header']
|
||||
classNameBindings: ['section_header_class', 'controller.controllers.application.isDragging:table-dragging', 'section_active']
|
||||
click: (e)->
|
||||
@set 'controller.controllers.application.active_section', @get('context')
|
||||
@get('controller').transitionToRoute 'section', @get('context.id')
|
||||
|
||||
section_header_class: (-> "section-tab-header-#{@get('context.id')}").property()
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
Qsupplier.App.TableNumberWithInfoView = Ember.View.extend
|
||||
tagName: 'span'
|
||||
templateName: 'table_number_with_info'
|
||||
classNames: 'table-number-with-info'
|
||||
click: ->
|
||||
$el = $(@get('element')).find('.extra-list-info')
|
||||
return $el.hide() if $el.is(':visible')
|
||||
$el.show()
|
||||
$.get Routes.extra_info_suppliers_list_path(@get('context.id')), (res)->
|
||||
$el.html(res)
|
||||
@@ -3,16 +3,18 @@ root.Qsupplier=
|
||||
watch_events: ->
|
||||
faye = new Faye.Client(event_host)
|
||||
faye.subscribe "/supplier/"+supplier_id, (e)=>
|
||||
console.log(e)
|
||||
console.log "Event: #{e.event}"
|
||||
console.log e.data
|
||||
if(e.event == 'new_order')
|
||||
if Qsupplier.App
|
||||
Qsupplier.App.store().pushPayload(e.data)
|
||||
# Fix for ember pushPayload bug not creating the proper relations/triggers
|
||||
setTimeout ->
|
||||
if order = Qsupplier.App.store().all('order').findProperty('id', e.data.order.id)
|
||||
# console.log "Ugly ember fix for adding order #{e.data.order.id} as relation to its list"
|
||||
list = order.get('list')
|
||||
list.get('orders').addRecord order
|
||||
, 100
|
||||
, 200
|
||||
else if(e.event == 'list_needs_help')
|
||||
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
|
||||
list.markNeedsHelp()
|
||||
@@ -63,8 +65,8 @@ root.Qsupplier=
|
||||
else if e.event == 'order_cancelled'
|
||||
if Qsupplier.App and order = Qsupplier.App.Order.findCached(e.data.id)
|
||||
order.markCancelled()
|
||||
$('.supplier-orders-placed-count-number').text(e.data.orders_placed_count) if Number.isInteger(e.data.orders_placed_count)
|
||||
$('.supplier-orders-in-process-count-number').text(e.data.orders_in_process_count) if Number.isInteger(e.data.orders_in_process_count)
|
||||
$('.supplier-orders-placed-count-number').text(e.data.orders_placed_count) if e.data.orders_placed_count == 0 or e.data.orders_placed_count
|
||||
$('.supplier-orders-in-process-count-number').text(e.data.orders_in_process_count) if e.data.orders_in_process_count == 0 or e.data.orders_in_process_count
|
||||
|
||||
|
||||
# old stuff
|
||||
|
||||
@@ -9,23 +9,19 @@
|
||||
.status-icons
|
||||
.active-order
|
||||
display: inline-block
|
||||
.active-orders-table
|
||||
tbody
|
||||
tr
|
||||
td
|
||||
.active_order_table_number
|
||||
position: relative
|
||||
.extra-list-info
|
||||
// Facebook profiles
|
||||
display: none
|
||||
$extra-info-width: 220px
|
||||
position: absolute
|
||||
width: $extra-info-width
|
||||
// 7px is padding + border, 5px is extra spacing
|
||||
right: -$extra-info-width - 7px*2 - 5px
|
||||
top: -7px*2
|
||||
padding: 4px
|
||||
border: 3px solid #aaa
|
||||
border-radius: 3px
|
||||
background-color: white
|
||||
text-align: left
|
||||
.table-number-with-info
|
||||
position: relative
|
||||
.extra-list-info
|
||||
// Facebook profiles
|
||||
display: none
|
||||
$extra-info-width: 220px
|
||||
position: absolute
|
||||
width: $extra-info-width
|
||||
// 7px is padding + border, 5px is extra spacing
|
||||
right: -$extra-info-width - 7px*2 - 5px
|
||||
top: -7px*2
|
||||
padding: 4px
|
||||
border: 3px solid #aaa
|
||||
border-radius: 3px
|
||||
background-color: white
|
||||
text-align: left
|
||||
|
||||
@@ -50,8 +50,12 @@ main.main-section
|
||||
|
||||
.hide, .hidden
|
||||
display: none
|
||||
|
||||
span.loading
|
||||
@extend .fa
|
||||
@extend .fa-spinner
|
||||
@extend .fa-lg
|
||||
@extend .fa-spin
|
||||
&.medium
|
||||
@extend .fa-lg
|
||||
&.large
|
||||
@extend .fa-2x
|
||||
|
||||
@@ -19,3 +19,12 @@ span.icon
|
||||
li
|
||||
span.currency
|
||||
float: right
|
||||
|
||||
span.loading
|
||||
@extend .fa
|
||||
@extend .fa-spinner
|
||||
@extend .fa-spin
|
||||
&.medium
|
||||
@extend .fa-lg
|
||||
&.large
|
||||
@extend .fa-2x
|
||||
|
||||
@@ -105,7 +105,7 @@ module Suppliers
|
||||
else
|
||||
format.html do
|
||||
@tables = current_supplier.active_tables
|
||||
render action: "new"
|
||||
render action: "new"
|
||||
end
|
||||
format.json { render json: @list.errors, status: :unprocessable_entity }
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Feature: Supplier main board
|
||||
|
||||
@javascript @broken
|
||||
@javascript
|
||||
Scenario: the active list should be present and contained in row having its id
|
||||
Given there is an active list and order
|
||||
And I am signed in as supplier
|
||||
@@ -47,7 +47,7 @@ Feature: Supplier main board
|
||||
Then the list in the supplier dashboard should not be displayed anymore
|
||||
And the list should be marked as closed
|
||||
|
||||
@javascript @broken
|
||||
@javascript
|
||||
Scenario: Selecting a specific section limits the result to the lists and orders of those sections
|
||||
Given there is an active list and order
|
||||
And I am signed in as supplier
|
||||
@@ -62,7 +62,7 @@ Feature: Supplier main board
|
||||
Then I should see the list and the new list
|
||||
And I should see the order and the new order
|
||||
|
||||
@javascript @broken
|
||||
@javascript
|
||||
Scenario: Selecting a specific section and jumping towards section view
|
||||
Given there is an active list and order
|
||||
And I am signed in as supplier
|
||||
@@ -71,7 +71,7 @@ Feature: Supplier main board
|
||||
And I click on the section main board section jumper
|
||||
Then I should be redirected to the supplier section view
|
||||
|
||||
@javascript @broken
|
||||
@javascript
|
||||
Scenario: Update table number if table chanes
|
||||
Given there is an active list and order
|
||||
And I am signed in as supplier
|
||||
|
||||
@@ -51,6 +51,7 @@ step "the list on the supplier dashboard should be marked as in need of payment"
|
||||
end
|
||||
|
||||
step "the supplier dashboard list should display the updated price" do
|
||||
sleep 0.5
|
||||
el = find(".list-row-#{@list.id} .total_list_amount")
|
||||
# original order is 3 * 2.11 = 6.33
|
||||
# new order price = 5 * 2.22 = 11.10
|
||||
@@ -160,7 +161,5 @@ end
|
||||
|
||||
step "the supplier placed orders counter should be reduced" do
|
||||
sleep 0.5
|
||||
binding.pry
|
||||
puts page.driver.error_messages
|
||||
find('.supplier-orders-placed-count-number').text.should == "10"
|
||||
end
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ RSpec.configure do |config|
|
||||
OmniAuth.config.add_mock :facebook, {
|
||||
info: {
|
||||
nickname: 'Joey',
|
||||
name: "Facebook Joe",
|
||||
name: "Facebook Joe",
|
||||
first_name: "Facebook Joe"
|
||||
},
|
||||
credentials: {
|
||||
|
||||
Reference in New Issue
Block a user