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