Make user app better and more simple :happy:
This commit is contained in:
@@ -45,9 +45,6 @@ App.ApplicationController = Ember.Controller.extend
|
|||||||
@setCurrentList ->
|
@setCurrentList ->
|
||||||
@transitionToRoute 'active_list'
|
@transitionToRoute 'active_list'
|
||||||
|
|
||||||
#getProducts: (options = {})->
|
|
||||||
#@store.find('product_category', options).then (product_categories)=>
|
|
||||||
#@controllerFor('list_products').set 'model', product_categories
|
|
||||||
setCurrentList: (callback)->
|
setCurrentList: (callback)->
|
||||||
success = (list)=>
|
success = (list)=>
|
||||||
#@store.find('list', 'current').deleteRecord() # gets not replaced, buty stays as dummy
|
#@store.find('list', 'current').deleteRecord() # gets not replaced, buty stays as dummy
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
App.ListController = Ember.ObjectController.extend {}
|
App.ListController = Ember.ObjectController.extend
|
||||||
|
list: (-> @get('model')).property('model')
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
App.ListProductsController = Ember.ArrayController.extend
|
|
||||||
actions:
|
|
||||||
addProduct: (product)->
|
|
||||||
if existing = @store.all('product_order').find((po)-> po.get('product') == product and not po.get('order'))
|
|
||||||
existing.increment()
|
|
||||||
else
|
|
||||||
@store.createRecord 'product_order', product: product
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
App.ListProductsForTableController = Ember.ArrayController.extend {}
|
|
||||||
@@ -16,7 +16,12 @@ App.ProductOrdersController = Ember.ArrayController.extend
|
|||||||
order.get('product_orders').pushObjects(new_product_orders)
|
order.get('product_orders').pushObjects(new_product_orders)
|
||||||
order.save().then (response)=>
|
order.save().then (response)=>
|
||||||
new_product_orders.invoke 'eraseRecord'
|
new_product_orders.invoke 'eraseRecord'
|
||||||
@transitionToRoute 'active_list'
|
if @get('controllers.application.list')
|
||||||
|
@transitionToRoute 'active_list'
|
||||||
|
else
|
||||||
|
# Get list info from the server
|
||||||
|
@get('controllers.application').setCurrentList ->
|
||||||
|
@transitionToRoute 'active_list'
|
||||||
, (jqXHR)=>
|
, (jqXHR)=>
|
||||||
new_product_orders.invoke 'eraseRecord'
|
new_product_orders.invoke 'eraseRecord'
|
||||||
@redirect_to 'index', message: 'order_could_not_be_processed'
|
@redirect_to 'index', message: 'order_could_not_be_processed'
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ App.SelectQrcodeController = Ember.Controller.extend
|
|||||||
@redirect_to 'user_root', message: 'table_is_from_other_supplier'
|
@redirect_to 'user_root', message: 'table_is_from_other_supplier'
|
||||||
else if res.current_table_id == table._id
|
else if res.current_table_id == table._id
|
||||||
#nothing has changed, show product list
|
#nothing has changed, show product list
|
||||||
@redirect_to 'list_products'
|
@redirect_to 'table', table._id
|
||||||
else if res.current_table_id != table._id
|
else if res.current_table_id != table._id
|
||||||
if res.occupied
|
if res.occupied
|
||||||
@redirect_to 'user_root', message: 'table_is_occupied'
|
@redirect_to 'user_root', message: 'table_is_occupied'
|
||||||
@@ -25,13 +25,12 @@ App.SelectQrcodeController = Ember.Controller.extend
|
|||||||
title: t('move_table.confirmation_title')
|
title: t('move_table.confirmation_title')
|
||||||
body: t('move_table.confirmation_body')
|
body: t('move_table.confirmation_body')
|
||||||
ok: =>
|
ok: =>
|
||||||
$.post(data_host + '/user/move_table.json', $.extend({table_id: table._id}, @authentication_object), (res2)=>
|
Ember.$.post '/user/move_table.json', table_id: table._id, (res2)=>
|
||||||
if res2.occupied
|
if res2.occupied
|
||||||
@redirect_to 'user_root', {message: 'move_table.cannot_move_to_occupied_tabe'}
|
@redirect_to 'user_root', message: 'move_table.cannot_move_to_occupied_tabe'
|
||||||
else
|
else
|
||||||
@redirect_to 'list_products', {message: 'move_table.moved_to_another_table'}
|
@redirect_to 'table', table._id, message: 'move_table.moved_to_another_table'
|
||||||
)
|
|
||||||
cancel: =>
|
cancel: =>
|
||||||
@redirect_to 'list_products'
|
@redirect_to 'table', res.current_table_id
|
||||||
else
|
else
|
||||||
@redirect_to 'table', table._id
|
@redirect_to 'table', table._id
|
||||||
|
|||||||
@@ -25,4 +25,6 @@ App.TableController = Ember.ObjectController.extend
|
|||||||
joinOccupiedTable: ->
|
joinOccupiedTable: ->
|
||||||
#@secured =>
|
#@secured =>
|
||||||
$.post('/user/join_occupied_table.json', table_id: @get('model.id'))
|
$.post('/user/join_occupied_table.json', table_id: @get('model.id'))
|
||||||
@set 'join_request_sent', true
|
@set 'join_request_sent', true # keeps the button deactivated
|
||||||
|
toggleProductCategory: (product_category)->
|
||||||
|
product_category.set 'collapsed', not product_category.get('collapsed')
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ App.List = DS.Model.extend
|
|||||||
needs_help: attr('boolean')
|
needs_help: attr('boolean')
|
||||||
needs_payment: attr('boolean')
|
needs_payment: attr('boolean')
|
||||||
supplier_name: attr('string')
|
supplier_name: attr('string')
|
||||||
|
state: attr('string')
|
||||||
price: attr('number')
|
price: attr('number')
|
||||||
extended_version: attr('boolean')
|
extended_version: attr('boolean')
|
||||||
supplier_orders_in_process_count: attr('number')
|
supplier_orders_in_process_count: attr('number')
|
||||||
|
|||||||
@@ -3,3 +3,4 @@ App.ProductCategory = DS.Model.extend
|
|||||||
name: attr('string')
|
name: attr('string')
|
||||||
products: DS.hasMany('product')
|
products: DS.hasMany('product')
|
||||||
supplier: DS.belongsTo('supplier')
|
supplier: DS.belongsTo('supplier')
|
||||||
|
collapsed: attr('boolean', defaultValue: false)
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ App.Router.map ->
|
|||||||
@route 'select_qrcode'
|
@route 'select_qrcode'
|
||||||
@route 'obtain_token'
|
@route 'obtain_token'
|
||||||
@route 'active_list'
|
@route 'active_list'
|
||||||
@route 'list_products'
|
|
||||||
@route 'list_products_for_table', path: '/list_products/:table_id'
|
|
||||||
@route 'table', path: '/tables/:table_id'
|
@route 'table', path: '/tables/:table_id'
|
||||||
@resource 'join_requests'
|
@resource 'join_requests'
|
||||||
@resource 'lists', ->
|
@resource 'lists', ->
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
App.ListProductsForTableRoute = Ember.Route.extend {}
|
|
||||||
#setupController: (controller)->
|
|
||||||
#controller.secured ->
|
|
||||||
#src = '/user/list_products_for_table.json'
|
|
||||||
#data = {}
|
|
||||||
#$.getJSON(data_host + src, $.extend(@authentication_object, data)).then (res) =>
|
|
||||||
#if res.not_present
|
|
||||||
#@redirect_to 'index', message: 'the_list_has_been_closed'
|
|
||||||
#return
|
|
||||||
#for pc in res.categories
|
|
||||||
#product_category = @store.createRecord 'product_category',
|
|
||||||
#name: pc.name
|
|
||||||
#for pp in pc.products
|
|
||||||
#pp.id = pp._id
|
|
||||||
#pp.product_category = product_category
|
|
||||||
#product = @store.createRecord 'product', pp
|
|
||||||
#controller.set 'model', @store.all('product_category')
|
|
||||||
#debugger
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
App.ListProductsRoute = Ember.Route.extend
|
|
||||||
model: ->
|
|
||||||
@store.all 'product_category'
|
|
||||||
#setupController: (controller)->
|
|
||||||
#controller.secured ->
|
|
||||||
#src = '/user/list_products.json'
|
|
||||||
#data = {}
|
|
||||||
#$.getJSON(data_host + src, $.extend(@authentication_object, data)).then (res) =>
|
|
||||||
#if res.not_present
|
|
||||||
#@redirect_to 'index', message: 'the_list_has_been_closed'
|
|
||||||
#return
|
|
||||||
#for pc in res.categories
|
|
||||||
#product_category = @store.createRecord 'product_category',
|
|
||||||
#name: pc.name
|
|
||||||
#for pp in pc.products
|
|
||||||
#pp.id = pp._id
|
|
||||||
#pp.product_category = product_category
|
|
||||||
#product = @store.createRecord 'product', pp
|
|
||||||
#controller.set 'model', @store.all('product_category')
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
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 orders
|
||||||
|
.list-order-container class=order.state
|
||||||
|
= order.display
|
||||||
|
span.currency= currency order.total
|
||||||
|
if displayTotal
|
||||||
|
.list-orders-total.total
|
||||||
|
= t 'total'
|
||||||
|
span.currency= currency model.total
|
||||||
|
else
|
||||||
|
p
|
||||||
|
span=t 'active_list.no_orders_explanation'
|
||||||
|
br
|
||||||
|
link-to 'list_products' class="button"
|
||||||
|
span=t 'list_products.title'
|
||||||
@@ -1,25 +1,7 @@
|
|||||||
.row
|
.row
|
||||||
h2=t 'active_list.title'
|
h2=t 'active_list.title'
|
||||||
if list
|
if list
|
||||||
each user in list.users
|
partial "list_content"
|
||||||
img.facebook-image src="http://graph.facebook.com/#{unbound user.facebook_id}/picture?type=square"
|
|
||||||
if list.orders
|
|
||||||
.list-orders-container
|
|
||||||
each order in orders
|
|
||||||
.list-order-container class=order.state
|
|
||||||
= order.display
|
|
||||||
span.currency= currency order.total
|
|
||||||
if displayTotal
|
|
||||||
.list-orders-total.total
|
|
||||||
= t 'total'
|
|
||||||
span.currency= currency model.total
|
|
||||||
else
|
|
||||||
p
|
|
||||||
span=t 'active_list.no_orders_explanation'
|
|
||||||
br
|
|
||||||
link-to 'list_products' class="button"
|
|
||||||
span=t 'list_products.title'
|
|
||||||
|
|
||||||
else
|
else
|
||||||
p
|
p
|
||||||
span=t 'active_list.not_active.message'
|
span=t 'active_list.not_active.message'
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
.row
|
.row
|
||||||
h2=t 'models.list'
|
h2=t 'models.list'
|
||||||
p Hoi
|
partial "list_content"
|
||||||
= controller
|
|
||||||
if model.is_extended_version
|
|
||||||
h3 Extended
|
|
||||||
else
|
|
||||||
h3 Not extended
|
|
||||||
link-to 'lists'
|
link-to 'lists'
|
||||||
span Go to lists
|
span Go to lists
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
.row
|
|
||||||
.large-6.columns
|
|
||||||
each product_category in controller
|
|
||||||
if product_category.products
|
|
||||||
hr
|
|
||||||
h4= product_category.name
|
|
||||||
hr
|
|
||||||
ul.product_category-products
|
|
||||||
each product in product_category.products
|
|
||||||
li
|
|
||||||
a{action addProduct product}= product.name
|
|
||||||
span.right.currency=currency product.price
|
|
||||||
.large-6.columns= render 'product_orders'
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
h2= List products for table
|
|
||||||
/.row
|
|
||||||
.large-6.columns
|
|
||||||
each product_category in controller
|
|
||||||
hr
|
|
||||||
h4= product_category.name
|
|
||||||
hr
|
|
||||||
each product in product_category.products
|
|
||||||
a{action addProduct product}= product.name
|
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
hr.hide-for-medium-up
|
hr.hide-for-medium-up
|
||||||
if model
|
if modelDisabled
|
||||||
a.tiny.button.right{action clearProductOrders} href="#" ×
|
a.tiny.button.right{action clearProductOrders} href="#" ×
|
||||||
.clearfix
|
.clearfix
|
||||||
.panel
|
.panel
|
||||||
ul.product-orders
|
ul.product-orders
|
||||||
each product_order in controller
|
each product_order in controller
|
||||||
li
|
li.product_order
|
||||||
= product_order.quantity
|
= product_order.quantity
|
||||||
| x
|
| x
|
||||||
= product_order.product.name
|
= product_order.product.name
|
||||||
a.product_order-remove.right{action removeProductOrder product_order}
|
button.product_order-remove.right{action removeProductOrder product_order}
|
||||||
span.fa.fa-close.fa-lg x
|
span.icon
|
||||||
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'
|
||||||
|
|||||||
@@ -15,13 +15,19 @@
|
|||||||
each product_category in supplier.product_categories
|
each product_category in supplier.product_categories
|
||||||
if product_category.products
|
if product_category.products
|
||||||
hr
|
hr
|
||||||
h4= product_category.name
|
h4.product_category-title{action toggleProductCategory product_category}
|
||||||
|
if product_category.collapsed
|
||||||
|
span.icon.collapsed
|
||||||
|
else
|
||||||
|
span.icon
|
||||||
|
= product_category.name
|
||||||
hr
|
hr
|
||||||
ul.product_category-products
|
unless product_category.collapsed
|
||||||
each product in product_category.products
|
ul.product_category-products
|
||||||
li
|
each product in product_category.products
|
||||||
a{action addProduct product}= product.name
|
li
|
||||||
span.right.currency=currency product.price
|
a{action addProduct product}= product.name
|
||||||
|
span.right.currency=currency product.price
|
||||||
.large-6.columns= render 'product_orders'
|
.large-6.columns= render 'product_orders'
|
||||||
else
|
else
|
||||||
.large12
|
.large12
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
@mixin button-icon-only
|
||||||
|
padding: 2px 5px
|
||||||
|
margin: 0
|
||||||
// Foundation by ZURB
|
// Foundation by ZURB
|
||||||
// foundation.zurb.com
|
// foundation.zurb.com
|
||||||
// Licensed under MIT Open Source
|
// Licensed under MIT Open Source
|
||||||
@@ -58,6 +61,7 @@
|
|||||||
// $primary-color: #008CBA;
|
// $primary-color: #008CBA;
|
||||||
$primary-color: green
|
$primary-color: green
|
||||||
// $secondary-color: #e7e7e7;
|
// $secondary-color: #e7e7e7;
|
||||||
|
$secondary-color: #d7d7d7
|
||||||
// $alert-color: #f04124;
|
// $alert-color: #f04124;
|
||||||
// $success-color: #43AC6A;
|
// $success-color: #43AC6A;
|
||||||
// $warning-color: #f08a24;
|
// $warning-color: #f08a24;
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
|
@import foundation_and_overrides
|
||||||
|
@import font-awesome
|
||||||
ul.product-orders
|
ul.product-orders
|
||||||
list-style: none
|
list-style: none
|
||||||
li
|
li
|
||||||
border-bottom: 1px solid #ccc
|
border-bottom: 1px solid #ccc
|
||||||
|
padding: 5px 0
|
||||||
&.total
|
&.total
|
||||||
border-bottom: none
|
border-bottom: none
|
||||||
border-top: 4px solid #333
|
border-top: 4px solid #333
|
||||||
font-weight: bold
|
font-weight: bold
|
||||||
.product_order-remove
|
.product_order-remove
|
||||||
color: black
|
+button-style($bg:$secondary-color)
|
||||||
background-color: #bbb
|
+button-icon-only
|
||||||
padding: 0px 5px
|
//+button-size($padding:$button-tny)
|
||||||
margin-left: 5px
|
margin-left: 5px
|
||||||
|
.icon
|
||||||
|
@extend .fa
|
||||||
|
@extend .fa-times
|
||||||
|
|||||||
@@ -1,2 +1,12 @@
|
|||||||
|
@import font-awesome
|
||||||
ul.product_category-products
|
ul.product_category-products
|
||||||
list-style: none
|
list-style: none
|
||||||
|
.product_category-title
|
||||||
|
cursor: pointer
|
||||||
|
.icon
|
||||||
|
@extend .fa
|
||||||
|
@extend .fa-arrow-down
|
||||||
|
color: #ccc
|
||||||
|
padding-right: 10px
|
||||||
|
&.collapsed
|
||||||
|
@extend .fa-arrow-right
|
||||||
|
|||||||
Reference in New Issue
Block a user