working ember... again
This commit is contained in:
@@ -11,8 +11,8 @@ gem 'rack-cors', :require => 'rack/cors'
|
||||
|
||||
gem 'jquery-rails'
|
||||
gem 'jquery-ui-rails'
|
||||
gem 'ember-source' #, github: 'emberjs/ember.js', require: 'ember/source'
|
||||
gem 'ember-rails'
|
||||
gem 'ember-source'
|
||||
gem 'slim-rails'
|
||||
# Gems used only for assets and not required
|
||||
# in production environments by default.
|
||||
@@ -40,9 +40,11 @@ gem 'simply_stored' , github: 'bterkuile/simply_stored'
|
||||
gem 'orm_adapter', github: 'bterkuile/orm_adapter'
|
||||
gem 'devise', '3.1.0' #, '2.0.4'
|
||||
gem 'devise_simply_stored', github: 'bterkuile/devise_simply_stored'
|
||||
gem "omniauth-facebook"
|
||||
gem 'simple_form'
|
||||
gem 'active_decorator' #, path: '/Users/bterkuile/companytools/development/rails/components/active_decorator'
|
||||
gem 'cmtool', github: 'bterkuile/cmtool'
|
||||
#gem 'cmtool', github: 'bterkuile/cmtool'
|
||||
gem 'cmtool', path: './../cmtool'
|
||||
gem 'kaminari'
|
||||
|
||||
gem 'rqrcode'
|
||||
|
||||
+40
-19
@@ -1,21 +1,3 @@
|
||||
GIT
|
||||
remote: git://github.com/bterkuile/cmtool.git
|
||||
revision: fd158660ada56158796c91df162672ddc74799d8
|
||||
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
|
||||
|
||||
GIT
|
||||
remote: git://github.com/bterkuile/couch_potato.git
|
||||
revision: 7712a8d12c319f2e165733800795acbb599638d2
|
||||
@@ -47,6 +29,23 @@ GIT
|
||||
couch_potato (>= 0.2.15)
|
||||
rest-client (>= 1.4.2)
|
||||
|
||||
PATH
|
||||
remote: ./../cmtool
|
||||
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
|
||||
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
@@ -109,7 +108,7 @@ GEM
|
||||
chunky_png (1.2.8)
|
||||
climate_control (0.0.3)
|
||||
activesupport (>= 3.0)
|
||||
cocaine (0.5.1)
|
||||
cocaine (0.5.2)
|
||||
climate_control (>= 0.0.3, < 1.0)
|
||||
coderay (1.0.9)
|
||||
coffee-rails (3.2.2)
|
||||
@@ -173,6 +172,8 @@ GEM
|
||||
factory_girl_rails (4.2.1)
|
||||
factory_girl (~> 4.2.0)
|
||||
railties (>= 3.0.0)
|
||||
faraday (0.8.7)
|
||||
multipart-post (~> 1.1)
|
||||
faye (0.8.9)
|
||||
cookiejar (>= 0.3.0)
|
||||
em-http-request (>= 0.3.0)
|
||||
@@ -198,8 +199,10 @@ GEM
|
||||
haml (>= 3.1, < 4.1)
|
||||
railties (>= 3.1, < 4.1)
|
||||
handlebars-source (1.0.12)
|
||||
hashie (1.2.0)
|
||||
hike (1.2.3)
|
||||
http_parser.rb (0.6.0.beta.2)
|
||||
httpauth (0.1)
|
||||
i18n (0.6.1)
|
||||
journey (1.0.4)
|
||||
jquery-rails (3.0.4)
|
||||
@@ -211,6 +214,8 @@ GEM
|
||||
js-routes (0.9.0)
|
||||
rails (>= 3.2)
|
||||
json (1.8.0)
|
||||
jwt (0.1.8)
|
||||
multi_json (>= 1.5)
|
||||
kaminari (0.14.1)
|
||||
actionpack (>= 3.0.0)
|
||||
activesupport (>= 3.0.0)
|
||||
@@ -227,8 +232,23 @@ GEM
|
||||
subexec (~> 0.2.1)
|
||||
mini_portile (0.5.1)
|
||||
multi_json (1.8.0)
|
||||
multipart-post (1.2.0)
|
||||
nokogiri (1.6.0)
|
||||
mini_portile (~> 0.5.0)
|
||||
oauth2 (0.8.0)
|
||||
faraday (~> 0.8)
|
||||
httpauth (~> 0.1)
|
||||
jwt (~> 0.1.4)
|
||||
multi_json (~> 1.0)
|
||||
rack (~> 1.2)
|
||||
omniauth (1.1.1)
|
||||
hashie (~> 1.2)
|
||||
rack
|
||||
omniauth-facebook (1.4.1)
|
||||
omniauth-oauth2 (~> 1.1.0)
|
||||
omniauth-oauth2 (1.1.0)
|
||||
oauth2 (~> 0.8.0)
|
||||
omniauth (~> 1.0)
|
||||
paperclip (3.5.1)
|
||||
activemodel (>= 3.0.0)
|
||||
activesupport (>= 3.0.0)
|
||||
@@ -370,6 +390,7 @@ DEPENDENCIES
|
||||
launchy
|
||||
letter_opener
|
||||
mini_magick
|
||||
omniauth-facebook
|
||||
orm_adapter!
|
||||
pry-rails
|
||||
quiet_assets
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#= require handlebars
|
||||
#= require ember
|
||||
#= require ember-data
|
||||
#= require_directory ./modifications
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
Qsupplier.App.IndexController = Ember.ObjectController.extend
|
||||
active_lists: (->
|
||||
if @get('sectionId')
|
||||
@get('lists').filter (l)=>( l.get('section_id') == @get('sectionId') && l.get('state') == 'active' )
|
||||
@get('lists').filter (l)=>( l.get('section.id') == @get('sectionId') && l.get('state') == 'active' )
|
||||
else
|
||||
@get('lists').filterProperty('state', 'active')
|
||||
).property('lists.@each.state', 'sectionId')
|
||||
|
||||
active_orders: (->
|
||||
if @get('sectionId')
|
||||
@get('orders').filter (o)=>( o.get('section_id') == @get('sectionId') && o.get('needs_supplier_attention') )
|
||||
@get('orders').filter (o)=>( o.get('section.id') == @get('sectionId') && o.get('needs_supplier_attention') )
|
||||
else
|
||||
@get('orders').filter (o)->( o.get('needs_supplier_attention') )
|
||||
).property('orders.@each.state', 'sectionId')
|
||||
|
||||
markListAsHelped: (id)->
|
||||
list = Qsupplier.App.List.find(id)
|
||||
list = Qsupplier.App.List.findCached(id)
|
||||
list.set('needs_help', false)
|
||||
$.post '/supplier/mark_list_as_helped', {list_id: id}
|
||||
|
||||
closeList: (id)->
|
||||
list = Qsupplier.App.List.find(id)
|
||||
list = Qsupplier.App.List.findCached(id)
|
||||
list.set('state', 'closed')
|
||||
$.post '/supplier/close_list', {list_id: id}
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@ Qsupplier.App.List = DS.Model.extend
|
||||
has_active_orders: attr 'boolean'
|
||||
price: attr 'number'
|
||||
table_number: attr 'number'
|
||||
table: DS.belongsTo('Qsupplier.App.Table', inverse: 'active_list')
|
||||
orders: DS.hasMany('Qsupplier.App.Order')
|
||||
section: DS.belongsTo('Qsupplier.App.Section')
|
||||
table: DS.belongsTo('table', inverse: 'active_list')
|
||||
orders: DS.hasMany('order')
|
||||
section: DS.belongsTo('section')
|
||||
section_id: attr('string')
|
||||
close: ->
|
||||
@get('orders').forEach (order)->
|
||||
order.close()
|
||||
@set('table', null)
|
||||
#@get('orders').forEach (order)->
|
||||
#order.close()
|
||||
#@set('table', null)
|
||||
@set('state', 'closed')
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
attr = DS.attr
|
||||
Qsupplier.App.Order = DS.Model.extend
|
||||
state: attr('string')
|
||||
list: DS.belongsTo('Qsupplier.App.List')
|
||||
list: DS.belongsTo('list')
|
||||
price: attr('number')
|
||||
product_orders: attr('object')
|
||||
section: DS.belongsTo('Qsupplier.App.Section')
|
||||
product_orders: attr()
|
||||
section: DS.belongsTo('section')
|
||||
section_id: attr('string')
|
||||
|
||||
active: (-> @get('state') == 'active').property('state')
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
attr = DS.attr
|
||||
Qsupplier.App.Product = DS.Model.extend
|
||||
order: DS.belongsTo('Qsupplier.App.Order')
|
||||
order: DS.belongsTo('order')
|
||||
|
||||
@@ -3,4 +3,4 @@ Qsupplier.App.Section = DS.Model.extend
|
||||
title: attr 'string'
|
||||
width: attr 'number'
|
||||
height: attr 'number'
|
||||
tables: DS.hasMany('Qsupplier.App.Table')
|
||||
tables: DS.hasMany('table')
|
||||
|
||||
@@ -6,5 +6,8 @@ Qsupplier.App.Table = DS.Model.extend
|
||||
position_x: attr 'number'
|
||||
position_y: attr 'number'
|
||||
occupied: attr 'boolean'
|
||||
section: DS.belongsTo('Qsupplier.App.Section')
|
||||
active_list: DS.belongsTo('Qsupplier.App.List')
|
||||
section: DS.belongsTo('section')
|
||||
active_list: DS.belongsTo('list')
|
||||
#active_list: (->
|
||||
#@get('list')
|
||||
#).property('list')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
DS.JSONTransforms['object'] =
|
||||
deserialize: (serialized)->
|
||||
serialized
|
||||
serialize: (deserialized)->
|
||||
deserialized
|
||||
#DS.JSONTransforms['object'] =
|
||||
#deserialize: (serialized)->
|
||||
#serialized
|
||||
#serialize: (deserialized)->
|
||||
#deserialized
|
||||
|
||||
@@ -4,12 +4,13 @@ DS.Model.reopen
|
||||
DS.Model.reopenClass
|
||||
findCached: (id)->
|
||||
return null unless id
|
||||
@all().findProperty('id', id)
|
||||
@store.all(@toString()).findProperty('id', id)
|
||||
updateOrAdd: (attributes)->
|
||||
if cached = @findCached(attributes.id)
|
||||
cached.setProperties attributes
|
||||
else
|
||||
@find(attributes.id)
|
||||
#@pushByAttriburtes(attributes)
|
||||
@store.find(@, attributes.id)
|
||||
pushByAttriburtes: (attributes)->
|
||||
#store = @all().get('store')
|
||||
|
||||
@@ -17,11 +18,26 @@ DS.Model.reopenClass
|
||||
#code for adding a record by its attributes and having its associations set
|
||||
#@find(attributes.id)
|
||||
|
||||
Ember.get(@, 'relationships').forEach (model, relation)->
|
||||
Ember.get(@, 'relationships').forEach (model, relation)=>
|
||||
relation = relation[0]
|
||||
if relation.kind == 'belongsTo' and attributes["#{relation.name}_id"]
|
||||
attributes[relation.name] = model.find(attributes["#{relation.name}_id"])
|
||||
#delete attributes["#{relation.name}_id"]
|
||||
if relation.kind == 'belongsTo' and id = attributes["#{relation.name}_id"]
|
||||
attributes[relation.name] = id unless attributes[relation.name]
|
||||
|
||||
#store.push @, attributes
|
||||
@createRecord attributes
|
||||
@store.push @toString(), attributes
|
||||
|
||||
#promises = []
|
||||
#association_names = []
|
||||
#Ember.get(@, 'relationships').forEach (model, relation)=>
|
||||
#relation = relation[0]
|
||||
#if relation.kind == 'belongsTo' and id = attributes["#{relation.name}_id"]
|
||||
#attributes[relation.name] = id
|
||||
#promises.push @store.find(relation.name, id)
|
||||
#association_names.push relation.name
|
||||
#Ember.RSVP.all(promises).then (records)->
|
||||
#debugger
|
||||
#for record, i in records
|
||||
##console.log "Setting relation #{relation.name} to #{record.get('id')}"
|
||||
#new_record.set association_names[i], record
|
||||
#attributes[relation.name] =
|
||||
#delete attributes["#{relation.name}_id"]
|
||||
#@createRecord attributes
|
||||
|
||||
@@ -7,4 +7,4 @@ Qsupplier.App.Router.reopen
|
||||
Qsupplier.App.Router.map ->
|
||||
@resource 'sections', ->
|
||||
@resource 'section', path: ':section_id'
|
||||
@resource 'lists', queryParams: ['state']
|
||||
#@resource 'lists', queryParams: ['state']
|
||||
|
||||
@@ -9,8 +9,8 @@ Qsupplier.App.IndexRoute = Ember.Route.extend
|
||||
#orders: Qsupplier.App.Order.find({state: 'active'})
|
||||
#lists: @store.filter 'list', (l)-> l.get('state') == 'active' # DOES NOT WORK!!!! (yet)
|
||||
# use filter to create a scope on all the records
|
||||
lists: Qsupplier.App.List.filter -> true
|
||||
orders: Qsupplier.App.Order.filter -> true
|
||||
lists: @store.filter 'list', -> true
|
||||
orders: @store.filter 'order', -> true
|
||||
setupController: (controller, model)->
|
||||
controller.set('model', model)
|
||||
$('#section_selector').on 'change', (-> controller.set('sectionId', $(this).val()))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Qsupplier.App.SectionsRoute = Ember.Route.extend
|
||||
model: -> Qsupplier.App.Section.find()
|
||||
model: -> @store.find 'section'
|
||||
|
||||
setupController: (controller, collection) ->
|
||||
controller.set 'content', collection
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# http://emberjs.com/guides/models/defining-a-store/
|
||||
|
||||
Qsupplier.App.Store = DS.Store.extend
|
||||
revision: 13
|
||||
adapter: DS.RESTAdapter.create
|
||||
DS.RESTAdapter.reopen
|
||||
namespace: 'supplier'
|
||||
|
||||
Qsupplier.App.ApplicationSerializer = DS.ActiveModelSerializer
|
||||
Qsupplier.App.Store = DS.Store.extend
|
||||
revision: 13
|
||||
adapter: DS.RESTAdapter
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
th.actions
|
||||
tbody
|
||||
each list in controller.active_lists
|
||||
' {{view 'Qsupplier.App.ActiveListView' contentBinding=list}}
|
||||
' {{view 'Qsupplier.App.ActiveListView' contentBinding="list"}}
|
||||
.page-header
|
||||
h3 {{t 'active_orders.title' }}
|
||||
.well
|
||||
@@ -25,4 +25,4 @@
|
||||
th.actions
|
||||
tbody
|
||||
each order in controller.active_orders
|
||||
' {{view 'Qsupplier.App.ActiveOrderView' contentBinding=order}}
|
||||
' {{view 'Qsupplier.App.ActiveOrderView' contentBinding="order"}}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
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"
|
||||
li
|
||||
a data-t='section.tables_view.table_actions.got_to_table' href="suppliers_table_path(@table)"
|
||||
@@ -3,3 +3,4 @@ Qsupplier.App.ActiveOrderView = Ember.View.extend
|
||||
templateName: 'active_order'
|
||||
classNameBindings: ['content.active:active', 'content.delivered:delivered', 'classIdentifier']
|
||||
classIdentifier: (-> "order-row-#{@get('content.id')}").property()
|
||||
didInsertElement: ->
|
||||
|
||||
@@ -12,7 +12,6 @@ Qsupplier.App.SectionTabHeaderView = Ember.View.extend DragNDrop.Droppable,
|
||||
if view.constructor.toString().match(/SectionTableView$/)
|
||||
table = view.get('content')
|
||||
table.set 'section', @content
|
||||
console.log "dirty? #{table.get('isDirty')}"
|
||||
#table.get('transaction').commit()
|
||||
table.save()
|
||||
didInsertElement: ->
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
Qsupplier.App.SectionTableView = Ember.View.extend DragNDrop.Draggable,
|
||||
templateName: 'table'
|
||||
classNames: ['section-table']
|
||||
attributeBindings: ['style']
|
||||
classNameBindings: [
|
||||
'content.active_list:occupied',
|
||||
'controller.editmode:draggable',
|
||||
@@ -8,33 +9,36 @@ Qsupplier.App.SectionTableView = Ember.View.extend DragNDrop.Draggable,
|
||||
'content.active_list.needs_payment:needs_payment',
|
||||
'content.active_list.has_active_orders:active_order'
|
||||
]
|
||||
offsetX: ->
|
||||
(@content.get('position_x') || 0) * @containerWidth() / (@content.get('section').get('width') || 1)
|
||||
offsetX: (->
|
||||
return 0 unless section_width = @get('content.section.width')
|
||||
(@content.get('position_x') || 0) * @containerWidth() / section_width
|
||||
).property('content.section.width', 'content.position_x')
|
||||
offsetY: (->
|
||||
(@content.get('position_y') || 0) * @containerHeight() / (@content.get('section').get('height') || 1)
|
||||
)
|
||||
activeList: (->
|
||||
!!@get('content.active_list_id')
|
||||
).property('content.active_list_id')
|
||||
attributeBindings: ['style']
|
||||
return 0 unless section_height = @get('content.section.height')
|
||||
(@content.get('position_y') || 0) * @containerHeight() / section_height
|
||||
).property('content.section.height', 'content.position_y')
|
||||
|
||||
style: (->
|
||||
"position:absolute;width:83px;height:48px"
|
||||
).property()
|
||||
"position:absolute;width:83px;height:48px;left:#{@get('offsetX')}px;top:#{@get('offsetY')}px"
|
||||
).property('offsetX', 'offsetY')
|
||||
|
||||
draggable: (-> if @get('controller.editmode') then 'true' else 'false' ).property('controller.editmode')
|
||||
placeInSection: ->
|
||||
@$el.css 'left', @offsetX()
|
||||
@$el.css 'top', @offsetY()
|
||||
didInsertElement: ->
|
||||
@$el = $ @get('element')
|
||||
@placeInSection()
|
||||
#@placeInSection()
|
||||
positionChange: (position)->
|
||||
@$el.css 'left', position.left
|
||||
@$el.css 'top', position.top
|
||||
#@$el.css 'left', position.left
|
||||
#@$el.css 'top', position.top
|
||||
@content.setProperties
|
||||
position_x: position.left*@content.get('section').get('width') / @containerWidth()
|
||||
position_y: position.top *@content.get('section').get('height') / @containerHeight()
|
||||
@content.get('transaction').commit()
|
||||
#@content.get('transaction').commit()
|
||||
@content.save()
|
||||
containerWidth: ->
|
||||
$(@get('parentView.element')).width()
|
||||
containerHeight: ->
|
||||
$(@get('parentView.element')).height()
|
||||
click: ->
|
||||
|
||||
@@ -12,3 +12,6 @@ Qsupplier.App.SectionView = Ember.View.extend DragNDrop.Droppable,
|
||||
height = @$el.width() * @get('controller.model.height') / @get('controller.model.width')
|
||||
@$el.css('height', height)
|
||||
).observes('controller.model.height', 'controller.model.width')
|
||||
didInsertElement: ->
|
||||
# the first observable event is triggered without the container having its dimensions
|
||||
@get('controller.model').notifyPropertyChange('width').notifyPropertyChange('height')
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
Qsupplier.App.TableActionsView = Ember.View.extend
|
||||
templateName: 'table_actions'
|
||||
@@ -21,7 +21,6 @@
|
||||
//= require qwaiter
|
||||
//= require ./qsupplier
|
||||
//= require handlebars
|
||||
//= require ./app/application
|
||||
//= require faye
|
||||
//= require ./base
|
||||
//= require qtip
|
||||
|
||||
@@ -48,6 +48,8 @@ root.Qsupplier=
|
||||
$('.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)
|
||||
else if e.event == 'list_helped'
|
||||
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
|
||||
list.set('needs_help', false)
|
||||
@@ -170,7 +172,7 @@ root.Qsupplier=
|
||||
$.post('/supplier/order_is_delivered', {order_id: order_id})
|
||||
|
||||
load_list: (list_id) ->
|
||||
$.get(data_host + '/supplier/lists/'+list_id+'.json', (res) ->
|
||||
$.get(data_host + '/supplier/lists/'+list_id+'.json?old_style=1', (res) ->
|
||||
body = $('#list-table tbody')
|
||||
foot = $('#list-table tfoot')
|
||||
Qsupplier.build_list_table(body, foot, res)
|
||||
|
||||
@@ -72,6 +72,9 @@ private
|
||||
helper_method :event_host
|
||||
|
||||
def show_404
|
||||
render 'dashboard/404', layout: true, status: 404
|
||||
respond_to do |format|
|
||||
format.html { render 'dashboard/404', layout: true, status: 404}
|
||||
format.json { render json: {ok: false}, status: 404 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,10 +33,14 @@ module Suppliers
|
||||
respond_to do |format|
|
||||
format.html {}
|
||||
format.json do
|
||||
if params[:old_style] then
|
||||
render json: @list.with_orders_as_json
|
||||
else
|
||||
render json: @list
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# GET /lists/new
|
||||
# GET /lists/new.json
|
||||
|
||||
@@ -5,9 +5,16 @@ module Suppliers
|
||||
# GET /sections.json
|
||||
def index
|
||||
@sections = current_supplier.sections
|
||||
@sections.include_relation(:table)
|
||||
@active_lists = current_supplier.active_lists
|
||||
@sections.include_relation(:tables)
|
||||
@active_lists = List.active_for_supplier(current_supplier.id)
|
||||
@active_table_ids = @active_lists.map(&:table_id).compact
|
||||
for section in @sections
|
||||
for table in section.tables
|
||||
if active_list = @active_lists.find{|l| l.table_id == table.id}
|
||||
table.active_list = active_list
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||
def passthru
|
||||
show_404
|
||||
# Or alternatively,
|
||||
# raise ActionController::RoutingError.new('Not Found')
|
||||
end
|
||||
|
||||
def facebook
|
||||
@user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)
|
||||
|
||||
if @user.persisted?
|
||||
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook"
|
||||
binding.pry
|
||||
redirect_to user_root_path, :event => :authentication, :current_user => @user
|
||||
else
|
||||
session["devise.facebook_data"] = request.env["omniauth.auth"]
|
||||
redirect_to new_user_registration_url
|
||||
end
|
||||
end
|
||||
|
||||
def failure(env = {})
|
||||
binding.pry
|
||||
end
|
||||
end
|
||||
+4
-1
@@ -96,7 +96,10 @@ class Order
|
||||
|
||||
def close!
|
||||
self.state = 'closed' if placed? || active?
|
||||
save
|
||||
if save
|
||||
broadcast_user user.id, 'order_closed', id: id
|
||||
broadcast_supplier supplier_id, 'order_closed', id: id
|
||||
end
|
||||
end
|
||||
|
||||
def as_json(*args)
|
||||
|
||||
@@ -56,7 +56,7 @@ class Supplier
|
||||
end
|
||||
|
||||
def active_lists(options = {})
|
||||
return @active_lists if @active_lists.present?
|
||||
return @active_lists if @active_lists
|
||||
@active_lists = options[:section_id].present? ? List.active_for_supplier_and_section(self, options[:section_id]) : List.active_for_supplier(id)
|
||||
@active_lists.include_relations(table: :section, orders: {product_orders: :product})
|
||||
@active_lists
|
||||
|
||||
+12
-1
@@ -12,7 +12,7 @@ class Table
|
||||
has_many :lists
|
||||
|
||||
attr_protected :supplier_id
|
||||
attr_accessor :active_list_id
|
||||
attr_accessor :active_list_id, :active_list
|
||||
|
||||
validates :supplier_id, presence: true
|
||||
#validates :list_id, presence: true
|
||||
@@ -68,9 +68,20 @@ class Table
|
||||
end
|
||||
|
||||
def active_list
|
||||
# nil memoizing
|
||||
return @active_list if @active_list_is_set
|
||||
@active_list ||= self.class.database.view(List.active_by_table_id_view(key: id, include_docs: true, reduce: false, limit: 1)).try(:first)
|
||||
end
|
||||
|
||||
def active_list=(val)
|
||||
@active_list_is_set = true
|
||||
@active_list = val
|
||||
end
|
||||
|
||||
def active_list_id
|
||||
@active_list_id || active_list.try(:id)
|
||||
end
|
||||
|
||||
def reserved?
|
||||
false
|
||||
end
|
||||
|
||||
+27
-1
@@ -5,7 +5,14 @@ class User
|
||||
property :active_list_id
|
||||
property :admin, type: :boolean, default: false
|
||||
|
||||
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :token_authenticatable # , :registerable
|
||||
#FACEBOOK
|
||||
property :provider
|
||||
property :uid
|
||||
property :oauth_token
|
||||
property :oauth_expires_at
|
||||
property :auth_data
|
||||
|
||||
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :token_authenticatable, :omniauthable, :omniauth_providers => [:facebook] # , :registerable
|
||||
|
||||
property :authentication_token
|
||||
|
||||
@@ -17,6 +24,25 @@ class User
|
||||
|
||||
view :by_authentication_token, key: :authentication_token
|
||||
view :by_email, key: :email
|
||||
view :by_facebook, key: [:provider, :uid]
|
||||
|
||||
def self.find_for_facebook_oauth(auth_data, user)
|
||||
user = database.view(self.by_facebook(key: [auth_data.provider, auth_data.uid], limit: 1)).first
|
||||
user || create(
|
||||
provider: auth_data.provider,
|
||||
uid: auth_data.uid,
|
||||
name: auth_data.info.nickname,
|
||||
email: auth_data.info.email,
|
||||
password: Devise.friendly_token[0,20],
|
||||
oauth_token: user.oauth_token = auth.credentials.token,
|
||||
oauth_expires_at: Time.at(auth_data.credentials.expires_at),
|
||||
auth_data: auth_data
|
||||
)
|
||||
end
|
||||
|
||||
def self.from_omniauth(auth)
|
||||
binding.pry
|
||||
end
|
||||
|
||||
def list_is_closed!
|
||||
self.active_list_id = nil
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
class ListSerializer < Qwaiter::Serializer
|
||||
embed :ids
|
||||
attributes :state, :needs_help, :needs_payment, :is_paid, :price, :table_id, :table_number, :section_id
|
||||
attributes :state, :needs_help, :needs_payment, :is_paid, :price, :table_id, :table_number, :section_id, :has_active_orders
|
||||
|
||||
def has_active_orders
|
||||
object.has_active_orders?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class SectionSerializer < Qwaiter::Serializer
|
||||
embed :ids, include: true
|
||||
attributes *%i[title path width height]
|
||||
attributes :title, :path, :width, :height
|
||||
has_many :tables
|
||||
end
|
||||
|
||||
@@ -1,7 +1,22 @@
|
||||
class TableSerializer < Qwaiter::Serializer
|
||||
attributes(*%i[number width height position_x position_y section_id occupied active_list_id])
|
||||
embed :ids, include: true
|
||||
attributes :number, :width, :height, :position_x, :position_y, :section_id, :occupied #, :alist_id
|
||||
|
||||
#def list_id
|
||||
#object.active_list_id || object.active_list.try(:id)
|
||||
#end
|
||||
|
||||
#def list
|
||||
#object.active_list
|
||||
#end
|
||||
|
||||
def occupied
|
||||
object.active_list_id.present?
|
||||
end
|
||||
|
||||
def list
|
||||
object.active_list
|
||||
end
|
||||
|
||||
has_one :list, key: :active_list_id
|
||||
end
|
||||
|
||||
@@ -17,6 +17,7 @@ html lang="en"
|
||||
link href="/images/apple-touch-icon.png" rel="apple-touch-icon-precomposed"
|
||||
link href="/favicon.ico" rel="shortcut icon"
|
||||
= render 'suppliers/application/head'
|
||||
= javascript_include_tag "supplier/application"
|
||||
= yield :head
|
||||
|
||||
body
|
||||
@@ -75,7 +76,6 @@ html lang="en"
|
||||
.row
|
||||
.span12
|
||||
#app
|
||||
= javascript_include_tag "supplier/application"
|
||||
script#alert-template[type="text/html"]= mustache_template 'supplier/alert'
|
||||
= yield :footer
|
||||
javascript:
|
||||
|
||||
@@ -1,25 +1,10 @@
|
||||
- content_for :head do
|
||||
= javascript_include_tag 'supplier/app/application'
|
||||
.pull-right
|
||||
= select_tag('current_section_selector', options_for_select([[current_supplier.name, '']] + current_supplier.sections.map{|s| ["- #{s.title}", s.id]}, params[:section_id]), id: :section_selector)
|
||||
a.icon-arrow-right.go-to-tables-view.hide href=tables_view_suppliers_section_path('0000')
|
||||
/= render template: 'supplier/active_lists'
|
||||
/= render template: 'supplier/active_orders'
|
||||
- content_for :footer do
|
||||
javascript:
|
||||
$(function(){
|
||||
$('#section_selector').change(function(){
|
||||
Qsupplier.load_active_orders();
|
||||
Qsupplier.load_active_lists();
|
||||
var el = $(this);
|
||||
var linker = $(this).siblings('a');
|
||||
if(el.val()){
|
||||
linker.show();
|
||||
linker.attr('href', linker.attr('href').replace(/\/[^\/]+\/tables_view/, '/'+el.val()+'/tables_view'));
|
||||
//linker.attr('href', linker.attr('href').replace(/\/[^\/]+(\.html?)$/, '/'+el.val()+'$1'));
|
||||
}else{
|
||||
linker.hide();
|
||||
}
|
||||
}).change();
|
||||
Qsupplier.load_active_orders()
|
||||
Qsupplier.load_active_lists()
|
||||
Qsupplier.watch_events();
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
tbody
|
||||
- @sections.each do |section|
|
||||
tr
|
||||
td.link= link_to section.title, [:tables_view, :suppliers, section]
|
||||
td.link= link_to section.title, [:suppliers, section]
|
||||
td.table-info
|
||||
span.table-count= section.tables.size
|
||||
span.active-table-count= (@active_table_ids & section.tables.map(&:id)).size
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
- model_class = Section
|
||||
- content_for :head do
|
||||
= javascript_include_tag 'supplier/app/application'
|
||||
.page-header
|
||||
h1 data-t='section.show.title'
|
||||
dl.dl-horizontal.show-list
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
- model_class = Section
|
||||
- content_for :row do
|
||||
- content_for :head do
|
||||
= javascript_include_tag 'supplier/app/application'
|
||||
/- content_for :row do
|
||||
.span12.section-title= @section.title
|
||||
.span12
|
||||
.well.section-tables-container.section-tables-active
|
||||
@@ -13,7 +15,7 @@
|
||||
span.needs_payment.icon-flag
|
||||
span.needs_help.icon-bell
|
||||
span.active_order.icon-glass
|
||||
#section-table-menu-container.hide
|
||||
/#section-table-menu-container.hide
|
||||
- @tables.each do |table|
|
||||
.section-table-menu-content class="section-table-menu-#{table.id} section-table-list-#{table.active_list_id}"
|
||||
button.btn.btn-info.list-is-helped.hide Question answered!
|
||||
|
||||
@@ -22,7 +22,7 @@ div.page-header= title :index, model_class
|
||||
tr
|
||||
td.link= link_to table.number, [:suppliers, table]
|
||||
td.link= link_to_if table.section.present?, table.section.try(:title), tables_view_suppliers_section_path(table.section)
|
||||
td.timestamp data-time=table.created_at.utc.iso8601
|
||||
td.timestamp data-time=table.created_at.try(:utc).try(:iso8601)
|
||||
td.actions
|
||||
= link_to t('helpers.links.edit'), [:edit, :suppliers, table], class: 'btn btn-mini', data: {t: 'helpers.links.edit'}
|
||||
'
|
||||
|
||||
@@ -14,6 +14,8 @@ Qwaiter::Application.configure do
|
||||
# Log error messages when you accidentally call methods on nil
|
||||
config.whiny_nils = true
|
||||
|
||||
config.ember.variant = :development
|
||||
|
||||
# Show full error reports and disable caching
|
||||
config.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = false
|
||||
|
||||
@@ -226,12 +226,19 @@ Devise.setup do |config|
|
||||
# config.navigational_formats = ['*/*', :html]
|
||||
|
||||
# The default HTTP method used to sign out a resource. Default is :delete.
|
||||
config.sign_out_via = :delete
|
||||
config.sign_out_via = [:delete, :get]
|
||||
|
||||
# ==> OmniAuth
|
||||
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
||||
# up on your models and hooks.
|
||||
# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
|
||||
if Rails.env.production?
|
||||
config.omniauth :facebook, "505160086210072", "fcc474a3fb13c6bcc0f7c83a92ad1b17",
|
||||
scope: 'email,user_birthday,publish_stream'
|
||||
else
|
||||
config.omniauth :facebook, "168928633304849", "22bc53e1a390c1e62d004195c55fe336",
|
||||
scope: 'email,user_birthday,publish_stream'
|
||||
end
|
||||
|
||||
# ==> Warden configuration
|
||||
# If you want to use other strategies, that are not supported by Devise, or
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
Qwaiter::Application.routes.draw do
|
||||
devise_for :users
|
||||
devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks" }
|
||||
devise_for :suppliers
|
||||
devise_for :administrators
|
||||
namespace :admin do
|
||||
@@ -107,7 +107,7 @@ Qwaiter::Application.routes.draw do
|
||||
get '/select_qrcode' => 'dashboard#select_qrcode'
|
||||
get '/table_qr_image' => 'dashboard#table_qr_image', as: :table_qr_image
|
||||
|
||||
mount Cmtool::Engine => '/cmtool'
|
||||
#mount Cmtool::Engine => '/cmtool'
|
||||
#match "/:action", controller: 'dashboard'
|
||||
|
||||
# The priority is based upon order of creation:
|
||||
|
||||
@@ -37,6 +37,7 @@ Feature: Supplier main board
|
||||
|
||||
When a new order on a table in another section is created
|
||||
And I wait 1 second
|
||||
And I open the debugger
|
||||
Then the new list should appear in the supplier dashboard
|
||||
And the new order on a table in another section should be present in the supplier dashboard
|
||||
|
||||
|
||||
@@ -8,6 +8,11 @@ step "I click on translation :translation" do |translation_key|
|
||||
text = I18n.t(translation_key)
|
||||
click_on text
|
||||
end
|
||||
|
||||
step "I wait :number second/seconds" do |number|
|
||||
sleep number.to_f
|
||||
end
|
||||
|
||||
step "I open the debugger" do
|
||||
binding.pry
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user