diff --git a/app/assets/javascripts/user/app/controllers/application_controller.js.coffee b/app/assets/javascripts/user/app/controllers/application_controller.js.coffee index 109b78ff..bb996d46 100644 --- a/app/assets/javascripts/user/app/controllers/application_controller.js.coffee +++ b/app/assets/javascripts/user/app/controllers/application_controller.js.coffee @@ -45,9 +45,6 @@ App.ApplicationController = Ember.Controller.extend @setCurrentList -> @transitionToRoute 'active_list' - #getProducts: (options = {})-> - #@store.find('product_category', options).then (product_categories)=> - #@controllerFor('list_products').set 'model', product_categories setCurrentList: (callback)-> success = (list)=> #@store.find('list', 'current').deleteRecord() # gets not replaced, buty stays as dummy diff --git a/app/assets/javascripts/user/app/controllers/list_controller.js.coffee b/app/assets/javascripts/user/app/controllers/list_controller.js.coffee index a5222f3b..1285fa64 100644 --- a/app/assets/javascripts/user/app/controllers/list_controller.js.coffee +++ b/app/assets/javascripts/user/app/controllers/list_controller.js.coffee @@ -1 +1,2 @@ -App.ListController = Ember.ObjectController.extend {} +App.ListController = Ember.ObjectController.extend + list: (-> @get('model')).property('model') diff --git a/app/assets/javascripts/user/app/controllers/list_products_controller.js.coffee b/app/assets/javascripts/user/app/controllers/list_products_controller.js.coffee deleted file mode 100644 index 7a6da434..00000000 --- a/app/assets/javascripts/user/app/controllers/list_products_controller.js.coffee +++ /dev/null @@ -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 diff --git a/app/assets/javascripts/user/app/controllers/list_products_for_table_controller.js.coffee b/app/assets/javascripts/user/app/controllers/list_products_for_table_controller.js.coffee deleted file mode 100644 index 051ac346..00000000 --- a/app/assets/javascripts/user/app/controllers/list_products_for_table_controller.js.coffee +++ /dev/null @@ -1 +0,0 @@ -App.ListProductsForTableController = Ember.ArrayController.extend {} diff --git a/app/assets/javascripts/user/app/controllers/product_orders_controller.js.coffee b/app/assets/javascripts/user/app/controllers/product_orders_controller.js.coffee index a3e2a2c3..5833e1f8 100644 --- a/app/assets/javascripts/user/app/controllers/product_orders_controller.js.coffee +++ b/app/assets/javascripts/user/app/controllers/product_orders_controller.js.coffee @@ -16,7 +16,12 @@ App.ProductOrdersController = Ember.ArrayController.extend order.get('product_orders').pushObjects(new_product_orders) order.save().then (response)=> 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)=> new_product_orders.invoke 'eraseRecord' @redirect_to 'index', message: 'order_could_not_be_processed' diff --git a/app/assets/javascripts/user/app/controllers/select_qrcode_controller.js.coffee b/app/assets/javascripts/user/app/controllers/select_qrcode_controller.js.coffee index ff15c2a4..cc82c6b8 100644 --- a/app/assets/javascripts/user/app/controllers/select_qrcode_controller.js.coffee +++ b/app/assets/javascripts/user/app/controllers/select_qrcode_controller.js.coffee @@ -9,7 +9,7 @@ App.SelectQrcodeController = Ember.Controller.extend @redirect_to 'user_root', message: 'table_is_from_other_supplier' else if res.current_table_id == table._id #nothing has changed, show product list - @redirect_to 'list_products' + @redirect_to 'table', table._id else if res.current_table_id != table._id if res.occupied @redirect_to 'user_root', message: 'table_is_occupied' @@ -25,13 +25,12 @@ App.SelectQrcodeController = Ember.Controller.extend title: t('move_table.confirmation_title') body: t('move_table.confirmation_body') 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 - @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 - @redirect_to 'list_products', {message: 'move_table.moved_to_another_table'} - ) + @redirect_to 'table', table._id, message: 'move_table.moved_to_another_table' cancel: => - @redirect_to 'list_products' + @redirect_to 'table', res.current_table_id else @redirect_to 'table', table._id diff --git a/app/assets/javascripts/user/app/controllers/table_controller.js.coffee b/app/assets/javascripts/user/app/controllers/table_controller.js.coffee index 9c166bf6..b74b0b56 100644 --- a/app/assets/javascripts/user/app/controllers/table_controller.js.coffee +++ b/app/assets/javascripts/user/app/controllers/table_controller.js.coffee @@ -25,4 +25,6 @@ App.TableController = Ember.ObjectController.extend joinOccupiedTable: -> #@secured => $.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') diff --git a/app/assets/javascripts/user/app/models/list.js.coffee b/app/assets/javascripts/user/app/models/list.js.coffee index 924996d0..e973d0b6 100644 --- a/app/assets/javascripts/user/app/models/list.js.coffee +++ b/app/assets/javascripts/user/app/models/list.js.coffee @@ -4,6 +4,7 @@ App.List = DS.Model.extend needs_help: attr('boolean') needs_payment: attr('boolean') supplier_name: attr('string') + state: attr('string') price: attr('number') extended_version: attr('boolean') supplier_orders_in_process_count: attr('number') diff --git a/app/assets/javascripts/user/app/models/product_category.js.coffee b/app/assets/javascripts/user/app/models/product_category.js.coffee index a288dd22..ceb83d62 100644 --- a/app/assets/javascripts/user/app/models/product_category.js.coffee +++ b/app/assets/javascripts/user/app/models/product_category.js.coffee @@ -3,3 +3,4 @@ App.ProductCategory = DS.Model.extend name: attr('string') products: DS.hasMany('product') supplier: DS.belongsTo('supplier') + collapsed: attr('boolean', defaultValue: false) diff --git a/app/assets/javascripts/user/app/router.js.coffee b/app/assets/javascripts/user/app/router.js.coffee index b56ea5e4..f65aefc9 100644 --- a/app/assets/javascripts/user/app/router.js.coffee +++ b/app/assets/javascripts/user/app/router.js.coffee @@ -8,8 +8,6 @@ App.Router.map -> @route 'select_qrcode' @route 'obtain_token' @route 'active_list' - @route 'list_products' - @route 'list_products_for_table', path: '/list_products/:table_id' @route 'table', path: '/tables/:table_id' @resource 'join_requests' @resource 'lists', -> diff --git a/app/assets/javascripts/user/app/routes/list_products_for_table_route.js.coffee b/app/assets/javascripts/user/app/routes/list_products_for_table_route.js.coffee deleted file mode 100644 index 48b3ac02..00000000 --- a/app/assets/javascripts/user/app/routes/list_products_for_table_route.js.coffee +++ /dev/null @@ -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 diff --git a/app/assets/javascripts/user/app/routes/list_products_route.js.coffee b/app/assets/javascripts/user/app/routes/list_products_route.js.coffee deleted file mode 100644 index 5d410144..00000000 --- a/app/assets/javascripts/user/app/routes/list_products_route.js.coffee +++ /dev/null @@ -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') diff --git a/app/assets/javascripts/user/app/templates/_list_content.emblem b/app/assets/javascripts/user/app/templates/_list_content.emblem new file mode 100644 index 00000000..e2afd2c3 --- /dev/null +++ b/app/assets/javascripts/user/app/templates/_list_content.emblem @@ -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' diff --git a/app/assets/javascripts/user/app/templates/active_list.emblem b/app/assets/javascripts/user/app/templates/active_list.emblem index 36fbd574..43f9e306 100644 --- a/app/assets/javascripts/user/app/templates/active_list.emblem +++ b/app/assets/javascripts/user/app/templates/active_list.emblem @@ -1,25 +1,7 @@ .row h2=t 'active_list.title' if list - each user in list.users - 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' - + partial "list_content" else p span=t 'active_list.not_active.message' diff --git a/app/assets/javascripts/user/app/templates/list.emblem b/app/assets/javascripts/user/app/templates/list.emblem index c8eb9ec1..0549adfe 100644 --- a/app/assets/javascripts/user/app/templates/list.emblem +++ b/app/assets/javascripts/user/app/templates/list.emblem @@ -1,10 +1,5 @@ .row h2=t 'models.list' - p Hoi - = controller - if model.is_extended_version - h3 Extended - else - h3 Not extended + partial "list_content" link-to 'lists' span Go to lists diff --git a/app/assets/javascripts/user/app/templates/list_products.emblem b/app/assets/javascripts/user/app/templates/list_products.emblem deleted file mode 100644 index eda52b34..00000000 --- a/app/assets/javascripts/user/app/templates/list_products.emblem +++ /dev/null @@ -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' diff --git a/app/assets/javascripts/user/app/templates/list_products_for_table.emblem b/app/assets/javascripts/user/app/templates/list_products_for_table.emblem deleted file mode 100644 index 6083ae05..00000000 --- a/app/assets/javascripts/user/app/templates/list_products_for_table.emblem +++ /dev/null @@ -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 diff --git a/app/assets/javascripts/user/app/templates/product_orders.emblem b/app/assets/javascripts/user/app/templates/product_orders.emblem index a00f417f..476a23a6 100644 --- a/app/assets/javascripts/user/app/templates/product_orders.emblem +++ b/app/assets/javascripts/user/app/templates/product_orders.emblem @@ -1,16 +1,16 @@ hr.hide-for-medium-up -if model +if modelDisabled a.tiny.button.right{action clearProductOrders} href="#" × .clearfix .panel ul.product-orders each product_order in controller - li + li.product_order = product_order.quantity | x = product_order.product.name - a.product_order-remove.right{action removeProductOrder product_order} - span.fa.fa-close.fa-lg x + button.product_order-remove.right{action removeProductOrder product_order} + span.icon span.currency=currency product_order.total else li= t 'product_orders.no_orders' diff --git a/app/assets/javascripts/user/app/templates/table.emblem b/app/assets/javascripts/user/app/templates/table.emblem index 7312e961..dc87099b 100644 --- a/app/assets/javascripts/user/app/templates/table.emblem +++ b/app/assets/javascripts/user/app/templates/table.emblem @@ -15,13 +15,19 @@ each product_category in supplier.product_categories if product_category.products 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 - ul.product_category-products - each product in product_category.products - li - a{action addProduct product}= product.name - span.right.currency=currency product.price + unless product_category.collapsed + 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' else .large12 diff --git a/app/assets/stylesheets/user/foundation/foundation_and_overrides.css.sass b/app/assets/stylesheets/user/foundation/foundation_and_overrides.css.sass index a1a587d5..537ef495 100644 --- a/app/assets/stylesheets/user/foundation/foundation_and_overrides.css.sass +++ b/app/assets/stylesheets/user/foundation/foundation_and_overrides.css.sass @@ -1,3 +1,6 @@ +@mixin button-icon-only + padding: 2px 5px + margin: 0 // Foundation by ZURB // foundation.zurb.com // Licensed under MIT Open Source @@ -58,6 +61,7 @@ // $primary-color: #008CBA; $primary-color: green // $secondary-color: #e7e7e7; +$secondary-color: #d7d7d7 // $alert-color: #f04124; // $success-color: #43AC6A; // $warning-color: #f08a24; diff --git a/app/assets/stylesheets/user/foundation/product-orders.css.sass b/app/assets/stylesheets/user/foundation/product-orders.css.sass index 3596f76b..420442a1 100644 --- a/app/assets/stylesheets/user/foundation/product-orders.css.sass +++ b/app/assets/stylesheets/user/foundation/product-orders.css.sass @@ -1,13 +1,19 @@ +@import foundation_and_overrides +@import font-awesome ul.product-orders list-style: none li border-bottom: 1px solid #ccc + padding: 5px 0 &.total border-bottom: none border-top: 4px solid #333 font-weight: bold .product_order-remove - color: black - background-color: #bbb - padding: 0px 5px + +button-style($bg:$secondary-color) + +button-icon-only + //+button-size($padding:$button-tny) margin-left: 5px + .icon + @extend .fa + @extend .fa-times diff --git a/app/assets/stylesheets/user/foundation/product_categories.css.sass b/app/assets/stylesheets/user/foundation/product_categories.css.sass index e3eaf8b1..e16dbe08 100644 --- a/app/assets/stylesheets/user/foundation/product_categories.css.sass +++ b/app/assets/stylesheets/user/foundation/product_categories.css.sass @@ -1,2 +1,12 @@ +@import font-awesome ul.product_category-products 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