End of day commit

This commit is contained in:
2013-10-16 18:22:29 +02:00
parent 2f41560591
commit b5a84a2858
26 changed files with 46239 additions and 58 deletions
@@ -14,14 +14,12 @@ Qsupplier.App.IndexController = Ember.ObjectController.extend
).property('orders.@each.state', 'sectionId')
markListAsHelped: (id)->
list = Qsupplier.App.List.findCached(id)
list.set('needs_help', false)
$.post '/supplier/mark_list_as_helped', {list_id: id}
if list = Qsupplier.App.List.findCached(id)
list.is_helped()
closeList: (id)->
list = Qsupplier.App.List.findCached(id)
list.set('state', 'closed')
$.post '/supplier/close_list', {list_id: id}
if list = Qsupplier.App.List.findCached(id)
list.close()
markOrderDelivered: (id)->
$.post('/supplier/order_is_delivered', order_id: id)
@@ -1,13 +1,15 @@
Qsupplier.App.SectionController = Ember.ObjectController.extend
#width: -> $('.section-tables-active').width()
#height: -> $('.section-tables-active').height()
dummy: -> 3
editmode: false
makeEditable: -> @set('editmode', true)
finishEditable: ->
finishEditable: ->
@set('editmode', false)
@get('model').save()
addTables: ->
$('#add-tables-modal').modal()
arrangeTables: ->
$('#arrange-tables-modal').modal()
actions:
markListAsHelped: (list) -> list.is_helped() if list
closeList: (list)-> list.close() if list
textures: ['wood1', 'wood2']
@@ -11,8 +11,25 @@ Qsupplier.App.List = DS.Model.extend
orders: DS.hasMany('order')
section: DS.belongsTo('section')
section_id: attr('string')
close: ->
#@get('orders').forEach (order)->
#order.close()
#@set('table', null)
active: ( -> @get('state') == 'active' ).property('state')
markClosed: ->
@set('state', 'closed')
@set 'has_active_orders', false
@markHelped()
@markIsPaid()
markHelped: ->
@set 'needs_help', false
markNeedsHelp: ->
@set 'needs_help', true
markNeedsPayment: ->
@set 'needs_payment', true
markIsPaid: ->
@set 'needs_payment', false
close: ->
@markClosed()
$.post Routes.supplier_close_list_path(), list_id: @id
is_helped: ->
@markHelped()
$.post Routes.supplier_mark_list_as_helped_path(), list_id: @id
@@ -17,5 +17,5 @@ Qsupplier.App.Order = DS.Model.extend
@get('product_orders').map((po)-> "#{po.product_name} (#{po.quantity})").join(',')
).property('product_orders')
close: ->
@set('state', 'closed')
markClosed: ->
@set 'state', 'closed'
@@ -7,10 +7,19 @@ DS.Model.reopenClass
@store.all(@toString()).findProperty('id', id)
updateOrAdd: (attributes)->
if cached = @findCached(attributes.id)
# update relations if needed
Ember.get(@, 'relationships').forEach (model, relation)=>
relation = relation[0]
if relation.kind == 'belongsTo'
if id = attributes["#{relation.name}_id"]
@store.find(relation.name, id).then (relation_object)->
cached.set relation.name, relation_object
cached.setProperties attributes
cached
else
#@pushByAttriburtes(attributes)
@store.find(@, attributes.id)
#@store.find(@, attributes.id)
@pushByAttriburtes(attributes)
pushByAttriburtes: (attributes)->
#store = @all().get('store')
@@ -1,10 +1,18 @@
.section-manage-tables.pull-right
if editmode
.btn-group
a.btn.dropdown-toggle data-toggle="dropdown" href="#"
a.btn.dropdown-toggle data-toggle="dropdown" href="#section-background"
span Background
span.caret
ul#section-background.dropdown-menu
each texture in textures
li
a{ action setTexture texture } {{texture}}
.btn-group
a.btn.dropdown-toggle data-toggle="dropdown" href="#section-actions"
span Action
span.caret
ul.dropdown-menu
ul#section-actions.dropdown-menu
li
a{action addTables} {{t 'section.add_tables.button_label'}}
li
@@ -3,3 +3,13 @@
span.needs_payment.icon-flag
span.needs_help.icon-bell
span.active_order.icon-glass
div class="table-actions table-actions-#{unbound table.id}"
.title {{table.number}}
if table.active_list.needs_help
.table-action-row
button{ action markListAsHelped table.active_list } class="btn btn-info btn-small list-is-helped-button-#{unbound table.active_list.id}" {{t "list.is_helped_button"}}
if table.active_list
.table-action-row
button{ action closeList table.active_list } class="btn btn-warning btn-small close-list" {{t 'list.close_list'}}
/.table-action-row
a href="suppliers_table_path(@table)" {{t 'section.tables_view.table_actions.got_to_table'}}
@@ -1,7 +1,6 @@
ul
if content.list.needs_help
li
button.btn.btn-info.btn-small id="list-is-helped-button-#{content.list.id}" onclick="Qsupplier.mark_list_as_helped('{{content.list.id}}')" {{t "list.is_helped_button"}}
button.btn.btn-warning.btn-small class="of-list-#{content.list.id}" onclick="Qsupplier.close_list('#{content.list.id}')" data-t="list.close_list"
if content.list.needs_help
li
a data-t='section.tables_view.table_actions.got_to_table' href="suppliers_table_path(@table)"
button.btn.btn-info.btn-small id="list-is-helped-button-#{content.list.id}" onclick="Qsupplier.mark_list_as_helped('{{content.list.id}}')" {{t "list.is_helped_button"}}
button.btn.btn-warning.btn-small class="of-list-#{content.list.id}" onclick="Qsupplier.close_list('#{content.list.id}')" data-t="list.close_list"
li
a data-t='section.tables_view.table_actions.got_to_table' href="suppliers_table_path(@table)" {{t 'section.tables_view.table_actions.got_to_table'}}
@@ -3,12 +3,16 @@ Qsupplier.App.SectionTableView = Ember.View.extend DragNDrop.Draggable,
classNames: ['section-table']
attributeBindings: ['style']
classNameBindings: [
'content.active_list:occupied',
'content.active_list.active:occupied',
'controller.editmode:draggable',
'content.active_list.needs_help:needs_help',
'content.active_list.needs_payment:needs_payment',
'content.active_list.has_active_orders:active_order'
'content.active_list.has_active_orders:active_order',
'uniqueClass'
]
uniqueClass: (->
"section-table-#{@get('content.id')}"
).property('content.id')
offsetX: (->
return 0 unless section_width = @get('content.section.width')
(@content.get('position_x') || 0) * @containerWidth() / section_width
@@ -41,4 +45,25 @@ Qsupplier.App.SectionTableView = Ember.View.extend DragNDrop.Draggable,
$(@get('parentView.element')).width()
containerHeight: ->
$(@get('parentView.element')).height()
click: ->
#click: ->
#@$('.table-actions').show()
didInsertElement: ->
@$el = @$(@get('element'))
#@$('.table-actions').hide()
#title = @$('.table-actions .title').clone()
content = @$('.table-actions')
#@$('.table-actions .title').remove()
content.hide()
@$el.on 'click', =>
content.toggle()
#@$el.qtip
#content:
#text: content
#title: title.html()
#style:
#classes: 'qtip-wiki qtip-light qtip-shadow'
#show: 'click'
#hide:
#fixed: true
#delay: 500
#prerender: true
@@ -1,2 +1,3 @@
Qsupplier.App.TableActionsView = Ember.View.extend
Qsupplier.App.TableActionsView = Ember.Component.extend
tagName: 'ul'
templateName: 'table_actions'
@@ -16,7 +16,7 @@
// require bootstrap-tooltip
// require bootstrap-popover
// require bootstrap-typeahead
//= require bootstrap
// require bootstrap
//= require js-routes
//= require qwaiter
//= require ./qsupplier
@@ -13,20 +13,20 @@ root.Qsupplier=
$('.section-table-list-'+order.list_id()).addClass('active_order')
else if(e.event == 'list_needs_help')
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
list.set('needs_help', true)
list.markNeedsHelp()
# old stuff
$('#list-needs-help-indicator-'+e.data.id).removeClass('hide')
$('#list-is-helped-button-'+e.data.id).removeClass('hide')
$('.section-table-list-'+e.data.id).addClass('needs_help')
else if(e.event == 'list_needs_payment')
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
list.set('needs_payment', true)
list.markNeedsPayment()
# old stuff
$('#list-needs-payment-indicator-'+e.data.id).removeClass('hide')
$('.section-table-list-'+e.data.id).addClass('needs_payment')
else if(e.event == 'list_is_paid')
if list = Qsupplier.App.List.findCached(e.data.id)
list.set('needs_payment', false)
list.markIsPaid()
else if e.event == 'list_update'
Qsupplier.App.List.updateOrAdd(e.data.list) if Qsupplier.App
# old stuff
@@ -43,16 +43,17 @@ root.Qsupplier=
table.addClass('active_order') if list.has_active_orders()
else if e.event == 'list_closed'
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
list.close()
list.markClosed()
$('.list-row-'+e.data.id).remove()
$('.of-list-'+e.data.id).remove()
table_list_class = 'section-table-list-'+e.data.id
$('.'+table_list_class).removeClass('occupied needs_help needs_payment active_order').removeClass(table_list_class)
else if e.event == 'order_closed'
order.close() if Qsupplier.App and order = Qsupplier.App.Order.findCached(e.data.id)
order.markClosed() if Qsupplier.App and order = Qsupplier.App.Order.findCached(e.data.id)
else if e.event == 'list_helped'
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
list.set('needs_help', false)
list.markHelped()
list_id = e.data.id
$('#list-needs-help-indicator-'+list_id).addClass('hide')
$('#list-is-helped-button-'+list_id).addClass('hide')
@@ -64,6 +65,9 @@ root.Qsupplier=
$('.order-row-'+e.data.id).remove()
$('.section-table-list-'+e.data.list_id).removeClass('active_order')
else if e.event == 'list_changed_table'
Qsupplier.App && Qsupplier.App.List.updateOrAdd(e.data.list)
# old stuff
list = new List(e.data.list)
list_row = $('.list-row-'+list.id())
list_row.find('.table_number').text(list.table_number()).addClass('changed')
@@ -32,6 +32,20 @@
float: right
.action-button-container
margin-right: -20px
.table-actions
display: none
position: absolute
left: 100%
top: 0
width: 140px
text-align: center
background-color: white
border: 1px solid #aaa
padding-bottom: 10px
.title
background-color: #aaa
.table-action-row
margin-top: 10px
&.section-tables-active
position: relative
padding: 0
@@ -0,0 +1,49 @@
Feature: Supplier section view
@javascript
Scenario: the section view displays tables and keeps their status information
Given there is an active list and order
And I am signed in as supplier
When I visit the supplier section path
Then the section table should be positioned in the section
And the section table should be marked as having an active order
And the section table should be marked as occupied
And the section table should not be marked as in need of help
When the list is marked as in need of help
# waiting here only needed in old style implementation
And I wait 1 second
Then the section table should be marked as in need of help
When I click on section table as a supplier
Then A popup having table options should appear in supplier section area
When I click on the mark list as helped in the section table popup as supplier
And I wait 1 second
Then the section table should not be marked as in need of help
And the section table popup should no longer have the mark list as helped button
When the list is marked as in need of payment
Then the section table should be marked as in need of payment
When I click on the close list button in the section table table popup
And I wait 1 second
Then the section table should not have any active list markings anymore
And the list should be marked as closed
#@javascript
@broken
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
And a new order on a table in another section is created
Then I should see the list and the new list
And I should see the order and the new order
When I select the section in the supplier dashboard
Then I should see the list and order but not the new list and new order
When I select the new section in the supplier dashboard
Then I should see the new list and new order but not the list and order
When I reset the section selector in the supplier dashboard
Then I should see the list and the new list
And I should see the order and the new order
@@ -1,5 +1,5 @@
step 'there is a confirmed and open supplier' do
@supplier_password = 'secret1'
@supplier = create :supplier, email: 'supplier@qwaiter.com', password: @supplier_password, confirmation_token: 'abc', confirmed_at: Time.now.utc, open: true
@section = create :section, title: 'Room', supplier: @supplier
@section = create :section, title: 'Room', supplier: @supplier, width: 8, height: 8
end
@@ -1,7 +1,7 @@
step "there is an active list and order" do
@user ||= create :user
step 'there is a confirmed and open supplier'
@table = create :table, supplier: @supplier, section: @section
@table = create :table, supplier: @supplier, section: @section, position_x: 2, position_y: 2
@section.should be_present
@list = create :list, state: 'active', supplier: @supplier, table: @table, section: @section, user_ids: [@user.id]
@product = create :product, price: 2.22, supplier: @supplier
@@ -5,3 +5,7 @@ end
step "I visit the supplier root path" do
visit '/supplier' unless page.current_path == '/supplier'
end
step "I visit the supplier section path" do
visit "/supplier/sections/#{@section.id}"
end
@@ -0,0 +1,66 @@
step "the section table should be positioned in the section" do
table = page.find(".section-table-#{@table.id}")
left = table['style'].to_s.match(/left:(\d+)/)
left.should be_present
left[1].to_i.should > 10
top = table['style'].to_s.match(/top:(\d+)/)
top.should be_present
top[1].to_i.should > 10
end
step "the section table should be marked as having an active order" do
table = page.find(".section-table-#{@table.id}")
table['class'].should include 'active_order'
end
step "the section table should be marked as occupied" do
table = page.find(".section-table-#{@table.id}")
table['class'].should include 'occupied'
end
step "the section table should be marked as in need of help" do
table = page.find(".section-table-#{@table.id}")
table['class'].should include 'needs_help'
end
step "the section table should not be marked as in need of help" do
table = page.find(".section-table-#{@table.id}")
table['class'].should_not include 'needs_help'
end
step "I click on section table as a supplier" do
table = page.find(".section-table-#{@table.id}")
table.click
end
step "the section table should be marked as in need of payment" do
page.should have_selector(".section-table-#{@table.id}.needs_payment")
end
step "A popup having table options should appear in supplier section area" do
page.should have_selector(".table-actions-#{@table.id}")
end
step "I click on the mark list as helped in the section table popup as supplier" do
btn = page.find(".list-is-helped-button-#{@list.id}")
btn.click
end
step "the section table popup should no longer have the mark list as helped button" do
page.should_not have_selector(".list-is-helped-button-#{@list.id}")
end
step "I click on the close list button in the section table table popup" do
table = page.find(".section-table-#{@table.id}")
table.click
page.find(".table-actions-#{@table.id} .close-list").click
end
step "the section table should not have any active list markings anymore" do
table = page.find(".section-table-#{@table.id}")
css_class = table['class']
css_class.should_not include 'needs_help'
css_class.should_not include 'occupied'
css_class.should_not include 'active_order'
css_class.should_not include 'needs_payment'
end
+2 -1
View File
@@ -33,11 +33,12 @@ RSpec.configure do |config|
config.mock_with :rspec
config.include FactoryGirl::Syntax::Methods
config.include FactoryAttributesFor
config.include Devise::TestHelpers, :type => :controller
config.include Devise::TestHelpers, type: :controller
config.include EndWithMatcher
config.include Features::BasicHelpers, type: :feature
#config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = true
config.filter_run_excluding broken: true
config.render_views = true
# Use color in STDOUT
+4
View File
@@ -0,0 +1,4 @@
def show_page
save_page Rails.root.join( 'public', 'capybara.html' )
%x(launchy http://localhost:3000/capybara.html)
end
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+15 -17
View File
@@ -1,17 +1,15 @@
/*!
* qTip2 - Pretty powerful tooltips - v2.0.1-35-
/*
* qTip2 - Pretty powerful tooltips - v2.1.1
* http://qtip2.com
*
* Copyright (c) 2013 Craig Michael Thompson
* Released under the MIT, GPL licenses
* http://jquery.org/license
*
* Date: Sun Mar 10 2013 03:07 GMT+0000
* Plugins: svg ajax tips modal viewport imagemap ie6
* Date: Thu Jul 11 2013 02:03 GMT+0100+0100
* Plugins: tips modal viewport svg imagemap ie6
* Styles: basic css3
*/
/* Core qTip styles */
.qtip{
position: absolute;
left: -28000px;
@@ -75,7 +73,6 @@
display: block;
text-indent: -1000em;
direction: ltr;
vertical-align: middle;
}
.qtip-icon, .qtip-icon .ui-icon{
@@ -89,6 +86,7 @@
width: 18px;
height: 14px;
line-height: 14px;
text-align: center;
text-indent: 0;
font: normal bold 10px/13px Tahoma,sans-serif;
@@ -97,7 +95,6 @@
background: transparent none no-repeat -100em -100em;
}
/* Applied to 'focused' tooltips e.g. most recently displayed/interacted with */
.qtip-focus{}
@@ -130,6 +127,7 @@
}
/*! Light tooltip style */
.qtip-light{
background-color: white;
@@ -234,7 +232,7 @@
}
/* Add shadows to your tooltips in: FF3+, Chrome 2+, Opera 10.6+, IE9+, Safari 2+ */
.qtip-shadow{
-webkit-box-shadow: 1px 1px 3px 1px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 1px 1px 3px 1px rgba(0, 0, 0, 0.15);
@@ -251,9 +249,9 @@
}
.qtip-rounded .qtip-titlebar{
-moz-border-radius: 5px 5px 0 0;
-webkit-border-radius: 5px 5px 0 0;
border-radius: 5px 5px 0 0;
-moz-border-radius: 4px 4px 0 0;
-webkit-border-radius: 4px 4px 0 0;
border-radius: 4px 4px 0 0;
}
/* Youtube tooltip style */
@@ -391,12 +389,12 @@
}
.qtip-tipsy .qtip-titlebar{
padding: 6px 35px 0 10;
padding: 6px 35px 0 10px;
background-color: transparent;
}
.qtip-tipsy .qtip-content{
padding: 6px 10;
padding: 6px 10px;
}
.qtip-tipsy .qtip-icon{
@@ -564,7 +562,7 @@
}
/* Tips plugin */
.qtip .qtip-tip{
margin: 0 auto;
overflow: hidden;
@@ -595,7 +593,7 @@
display: inline-block;
visibility: visible;
}
/* Modal plugin */
#qtip-overlay{
position: fixed;
left: -10000em;
@@ -619,7 +617,7 @@
}
/* IE6 Modal plugin fix */
.qtipmodal-ie6fix{
position: absolute !important;
}
+1 -1
View File
@@ -3538,4 +3538,4 @@ IE6.initialize = 'render';
}));
}( window, document ));
}( window, document ));