diff --git a/app/assets/javascripts/supplier/app/controllers/index_controller.js.coffee b/app/assets/javascripts/supplier/app/controllers/index_controller.js.coffee index a4466a9c..4c267c0a 100644 --- a/app/assets/javascripts/supplier/app/controllers/index_controller.js.coffee +++ b/app/assets/javascripts/supplier/app/controllers/index_controller.js.coffee @@ -1,18 +1,18 @@ Qsupplier.App.IndexController = Ember.ObjectController.extend needs: ['application'] active_lists: (-> - if @get('active_section_id') - @get('lists').filter (l)=>( l.get('section.id') == @get('active_section_id') && l.get('state') == 'active' ) + if @get('active_section.id') + @get('lists').filter (l)=>( l.get('section.id') == @get('active_section.id') && l.get('state') == 'active' ) else @get('lists').filterProperty('state', 'active') - ).property('lists.@each.state', 'active_section_id') + ).property('lists.@each.state', 'active_section.id') active_orders: (-> - if @get('active_section_id') - @get('orders').filter (o)=>( o.get('section.id') == @get('active_section_id') && o.get('needs_supplier_attention') ) + if @get('active_section.id') + @get('orders').filter (o)=>( o.get('section.id') == @get('active_section.id') && o.get('needs_supplier_attention') ) else @get('orders').filter (o)->( o.get('needs_supplier_attention') ) - ).property('orders.@each.state', 'active_section_id') + ).property('orders.@each.state', 'active_section.id') markListAsHelped: (id)-> if list = Qsupplier.App.List.findCached(id) diff --git a/app/assets/javascripts/supplier/app/controllers/list_controller.js.coffee b/app/assets/javascripts/supplier/app/controllers/list_controller.js.coffee new file mode 100644 index 00000000..c25726c5 --- /dev/null +++ b/app/assets/javascripts/supplier/app/controllers/list_controller.js.coffee @@ -0,0 +1,6 @@ +Qsupplier.App.ListController = Ember.ObjectController.extend + needs: ['application', 'lists', 'list'] #wtf? list, otherwise an Ember error + list: (-> @get('model')).property('model') + showTotal: (-> + if @get('list.orders.length') && @get('list.orders.length') > 1 then true else false + ).property('list.orders.length') diff --git a/app/assets/javascripts/supplier/app/controllers/lists_controller.js.coffee b/app/assets/javascripts/supplier/app/controllers/lists_controller.js.coffee deleted file mode 100644 index 61f4be90..00000000 --- a/app/assets/javascripts/supplier/app/controllers/lists_controller.js.coffee +++ /dev/null @@ -1,4 +0,0 @@ -Qsupplier.App.ListsController = Ember.ArrayController.extend - dateChanged: (-> - @set('model', @store.find('list', date: @get('date'))) - ).observes('date') diff --git a/app/assets/javascripts/supplier/app/controllers/lists_index_controller.js.coffee b/app/assets/javascripts/supplier/app/controllers/lists_index_controller.js.coffee new file mode 100644 index 00000000..e5c27a30 --- /dev/null +++ b/app/assets/javascripts/supplier/app/controllers/lists_index_controller.js.coffee @@ -0,0 +1,8 @@ +Qsupplier.App.ListsIndexController = Ember.ArrayController.extend + dateChanged: (-> + if @get('date') + @set('model', @store.find('list', date: @get('date'))) + else + @set('model', @store.find('list')) + ).observes('date') + lists: (-> @get('model')).property('model') diff --git a/app/assets/javascripts/supplier/app/controllers/sections_index_controller.js.coffee b/app/assets/javascripts/supplier/app/controllers/sections_index_controller.js.coffee index 32c47820..2570cabb 100644 --- a/app/assets/javascripts/supplier/app/controllers/sections_index_controller.js.coffee +++ b/app/assets/javascripts/supplier/app/controllers/sections_index_controller.js.coffee @@ -1,5 +1,5 @@ Qsupplier.App.SectionsIndexController = Ember.ArrayController.extend - needs: ['application', 'sections'] + needs: ['application', 'sections', 'index'] sections: (-> @get('controllers.sections.model')).property('controllers.sections.model') sectionQrCodesUrl: ((a,b,c)-> debugger @@ -8,3 +8,7 @@ Qsupplier.App.SectionsIndexController = Ember.ArrayController.extend newPath: Routes.new_suppliers_section_path() qrPath: (section_id)-> Routes.qr_codes_suppliers_tables_path section_id: section_id + actions: + showDashboardOrders: (section)-> + @transitionToRoute('index').then => + @get('controllers.index').set 'active_section', section diff --git a/app/assets/javascripts/supplier/app/models/join_request.js.coffee b/app/assets/javascripts/supplier/app/models/join_request.js.coffee new file mode 100644 index 00000000..e3a4e631 --- /dev/null +++ b/app/assets/javascripts/supplier/app/models/join_request.js.coffee @@ -0,0 +1,4 @@ +attr = DS.attr +Qsupplier.App.JoinRequest= DS.Model.extend + list: DS.belongsTo('list') + user: DS.belongsTo('user') diff --git a/app/assets/javascripts/supplier/app/models/list.js.coffee b/app/assets/javascripts/supplier/app/models/list.js.coffee index 8e11b53a..1a9521c8 100644 --- a/app/assets/javascripts/supplier/app/models/list.js.coffee +++ b/app/assets/javascripts/supplier/app/models/list.js.coffee @@ -4,6 +4,7 @@ Qsupplier.App.List = DS.Model.extend needs_help: attr 'boolean' needs_payment: attr 'boolean' user_requests_closing: attr('boolean') + users: DS.hasMany('user') is_paid: attr 'boolean' has_active_orders: attr 'boolean' price: attr 'number' @@ -28,6 +29,9 @@ Qsupplier.App.List = DS.Model.extend @set 'needs_payment', true markIsPaid: -> @set 'needs_payment', false + total: (-> + @get('orders').getEach('total').reduce(((sum, total) -> sum + total), 0) + ).property('orders.@each.total') close: -> @markClosed() @@ -36,3 +40,4 @@ Qsupplier.App.List = DS.Model.extend is_helped: -> @markHelped() $.post Routes.supplier_mark_list_as_helped_path(), list_id: @id + sorted_orders: (-> @get('orders').sortBy('created_at').reverseObjects()).property('orders.@each.isLoaded') diff --git a/app/assets/javascripts/supplier/app/models/user.js.coffee b/app/assets/javascripts/supplier/app/models/user.js.coffee index c3c844b1..f3d68aaa 100644 --- a/app/assets/javascripts/supplier/app/models/user.js.coffee +++ b/app/assets/javascripts/supplier/app/models/user.js.coffee @@ -1,4 +1,6 @@ attr = DS.attr Qsupplier.App.User= DS.Model.extend - uid: attr 'string' - #active_list: DS.belongsTo('list') + facebook_id: attr('string') + email: attr('string') + list: DS.belongsTo('list') # in ember scope not many to many (yet) + join_requests: DS.hasMany('join_request') diff --git a/app/assets/javascripts/supplier/app/routes/index_route.js.coffee b/app/assets/javascripts/supplier/app/routes/index_route.js.coffee index a1e2feb9..8b17125d 100644 --- a/app/assets/javascripts/supplier/app/routes/index_route.js.coffee +++ b/app/assets/javascripts/supplier/app/routes/index_route.js.coffee @@ -10,6 +10,7 @@ Qsupplier.App.IndexRoute = Ember.Route.extend #lists: @store.filter 'list', (l)-> l.get('state') == 'active' # DOES NOT WORK!!!! (yet) # use filter to create a scope on all the records lists: @store.filter 'list', -> true + # mayby @store.all 'list' will work better!!!! (2014-04-24 a more experienced benjamin :) orders: @store.filter 'order', -> true sections: @store.find 'section' setupController: (controller, model)-> diff --git a/app/assets/javascripts/supplier/app/routes/lists_route.js.coffee b/app/assets/javascripts/supplier/app/routes/lists_index_route.js.coffee similarity index 61% rename from app/assets/javascripts/supplier/app/routes/lists_route.js.coffee rename to app/assets/javascripts/supplier/app/routes/lists_index_route.js.coffee index d8f1aeba..f88b4d2a 100644 --- a/app/assets/javascripts/supplier/app/routes/lists_route.js.coffee +++ b/app/assets/javascripts/supplier/app/routes/lists_index_route.js.coffee @@ -1,4 +1,4 @@ -Qsupplier.App.ListsRoute = Ember.Route.extend +Qsupplier.App.ListsIndexRoute = Ember.Route.extend #model: -> @store.find 'list' setupController: (controller, model)-> - controller.set 'date', (new Date()).toISOString().substr(0,10) + controller.set 'date', (new Date()).toISOString().substr(0,10) unless controller.get('date') diff --git a/app/assets/javascripts/supplier/app/templates/_list_content.emblem b/app/assets/javascripts/supplier/app/templates/_list_content.emblem new file mode 100644 index 00000000..16e52e94 --- /dev/null +++ b/app/assets/javascripts/supplier/app/templates/_list_content.emblem @@ -0,0 +1,19 @@ +.display-row + .display-label=t 'attributes.list.created_at' + .display-field=time list.created_at +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 list.sorted_orders + .list-order-container class=order.state + = order.display + span.currency= currency order.total + span.created_at= time order.created_at + if showTotal + .list-orders-total.total + = t 'total' + span.currency= currency list.total +else + p + span=t 'active_list.no_orders_explanation' diff --git a/app/assets/javascripts/supplier/app/templates/index.emblem b/app/assets/javascripts/supplier/app/templates/index.emblem index 26039855..f5079aca 100644 --- a/app/assets/javascripts/supplier/app/templates/index.emblem +++ b/app/assets/javascripts/supplier/app/templates/index.emblem @@ -1,6 +1,6 @@ .page-header - div.pull-right - '{{view 'Qsupplier.App.HomeSectionSelectorView' content=controller.sections prompt=controllers.application.supplier.name}} + div.dashboard-section-selection + '{{view 'Qsupplier.App.HomeSectionSelectorView' selectionBinding="controller.active_section" content=controller.sections prompt=controllers.application.supplier.name}} '{{view 'Qsupplier.App.HomeSectionJumperView'}} h3 {{t 'active_lists.title'}} .well diff --git a/app/assets/javascripts/supplier/app/templates/list.emblem b/app/assets/javascripts/supplier/app/templates/list.emblem new file mode 100644 index 00000000..0549adfe --- /dev/null +++ b/app/assets/javascripts/supplier/app/templates/list.emblem @@ -0,0 +1,5 @@ +.row + h2=t 'models.list' + partial "list_content" + link-to 'lists' + span Go to lists diff --git a/app/assets/javascripts/supplier/app/templates/lists.emblem b/app/assets/javascripts/supplier/app/templates/lists.emblem index 2c3bd05e..26191258 100644 --- a/app/assets/javascripts/supplier/app/templates/lists.emblem +++ b/app/assets/javascripts/supplier/app/templates/lists.emblem @@ -1,26 +1 @@ -h1=t 'models.plural.list' -Qsupplier.App.ListDisplayDateSelector valueBinding=date -if controller.model - table.table - thead - tr - th.state=t 'attributes.list.state' - th.boolean=t 'attributes.list.needs_help' - th.boolean=t 'attributes.list.needs_payment' - th.timestamp=t 'attributes.list.closed_at' - th.table_number=t 'models.table' - th.currentcy=t 'attributes.list.price' - th.timestamp=t 'attributes.list.created_at' - tbody - each list in controller - tr - td.state=state 'list' list.state - td.boolean.needs_help=boolean list.needs_help - td.boolean.needs_payment=boolean list.needs_payment - td.timestamp=time list.closed_at - td.table_number 7 - td.currency=currency list.price - td.timestamp=time list.created_at -else - .row - .panel=t 'list.none_found' += outlet diff --git a/app/assets/javascripts/supplier/app/templates/lists/index.emblem b/app/assets/javascripts/supplier/app/templates/lists/index.emblem new file mode 100644 index 00000000..a5aff500 --- /dev/null +++ b/app/assets/javascripts/supplier/app/templates/lists/index.emblem @@ -0,0 +1,28 @@ +h1=t 'models.plural.list' +Qsupplier.App.ListDisplayDateSelector valueBinding="date" +if lists + table.table + thead + tr + th.state=t 'attributes.list.state' + th.boolean=t 'attributes.list.needs_help' + th.boolean=t 'attributes.list.needs_payment' + th.timestamp=t 'attributes.list.closed_at' + th.table_number=t 'models.table' + th.currentcy=t 'attributes.list.price' + th.timestamp=t 'attributes.list.created_at' + tbody + each list in lists + tr + td.state + link-to 'list' list.id + = state 'list' list.state + td.boolean.needs_help=boolean list.needs_help + td.boolean.needs_payment=boolean list.needs_payment + td.timestamp=time list.closed_at + td.table_number 7 + td.currency=currency list.price + td.timestamp=time list.created_at +else + .row + .panel=t 'list.none_found' diff --git a/app/assets/javascripts/supplier/app/templates/section.emblem b/app/assets/javascripts/supplier/app/templates/section.emblem index 452d3973..61f4d8a5 100644 --- a/app/assets/javascripts/supplier/app/templates/section.emblem +++ b/app/assets/javascripts/supplier/app/templates/section.emblem @@ -1,5 +1,5 @@ .section-tabs-container - link-to 'sections' | b + link-to 'sections' class="goto-sections-index-tab-header": span each section in sections view Qsupplier.App.SectionTabHeaderView context=section .section-manage-tables.pull-right diff --git a/app/assets/javascripts/supplier/app/templates/sections/index.emblem b/app/assets/javascripts/supplier/app/templates/sections/index.emblem index fd89621a..3b5de10d 100644 --- a/app/assets/javascripts/supplier/app/templates/sections/index.emblem +++ b/app/assets/javascripts/supplier/app/templates/sections/index.emblem @@ -31,6 +31,7 @@ if sections /td.currency=currency list.price /td.timestamp=time list.created_at td.actions + a.section-dashboard-orders{action showDashboardOrders section}: span a.table-qr-codes{path qr_codes_suppliers_tables section_id=section.id} span else diff --git a/app/assets/javascripts/supplier/app/views/home_section_jumper_view.js.coffee b/app/assets/javascripts/supplier/app/views/home_section_jumper_view.js.coffee index 1ab7a715..fd9ee5b6 100644 --- a/app/assets/javascripts/supplier/app/views/home_section_jumper_view.js.coffee +++ b/app/assets/javascripts/supplier/app/views/home_section_jumper_view.js.coffee @@ -1,11 +1,9 @@ Qsupplier.App.HomeSectionJumperView = Ember.View.extend tagName: 'a' classNames: ['main-board-section-jumper'] - attributeBindings: ['href'] - #href: (-> Routes.suppliers_section_path(@get('controller.active_section_id') || 'nothing')).property('controller.active_section_id') href: '#' - isVisible: (-> !!@get('controller.active_section_id') ).property('controller.active_section_id') - template: Ember.Handlebars.compile('=>') + isVisible: (-> !!@get('controller.active_section.id') ).property('controller.active_section.id') + template: Ember.Handlebars.compile('') click: (e)-> e.preventDefault() - @get('controller').transitionToRoute 'section', @get('controller.active_section_id') + @get('controller').transitionToRoute 'section', @get('controller.active_section.id') diff --git a/app/assets/javascripts/supplier/app/views/home_section_selector_view.js.coffee b/app/assets/javascripts/supplier/app/views/home_section_selector_view.js.coffee index 24bbfb8d..d5082a27 100644 --- a/app/assets/javascripts/supplier/app/views/home_section_selector_view.js.coffee +++ b/app/assets/javascripts/supplier/app/views/home_section_selector_view.js.coffee @@ -3,6 +3,6 @@ HomeSectionOption = Ember.SelectOption.extend Qsupplier.App.HomeSectionSelectorView = Ember.Select.extend classNames: 'section_selector' optionView: HomeSectionOption - valueBinding: 'controller.active_section_id' + #valueBinding: 'controller.active_section_id' optionValuePath: 'content.id' optionLabelPath: 'select_label' 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 1285fa64..3b924779 100644 --- a/app/assets/javascripts/user/app/controllers/list_controller.js.coffee +++ b/app/assets/javascripts/user/app/controllers/list_controller.js.coffee @@ -1,2 +1,5 @@ App.ListController = Ember.ObjectController.extend list: (-> @get('model')).property('model') + showTotal: (-> + if @get('list.orders.length') && @get('list.orders.length') > 1 then true else false + ).property('list.orders.length') 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 22dc5aba..c22af117 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 @@ -4,6 +4,8 @@ App.ProductOrdersController = Ember.ArrayController.extend #Math.round(Math.random()*100) @get('model').getEach('total').reduce(((sum, total) -> sum + total), 0) ).property('model.@each.quantity') + product_orders: (->@get('model')).property('model') + showTotal: (-> if @get('model.length') && @get('model.length') > 1 then true else false ).property('model.length') actions: clearProductOrders: -> #TODO: make clearing of unpersisted product orders diff --git a/app/assets/javascripts/user/app/templates/_list_content.emblem b/app/assets/javascripts/user/app/templates/_list_content.emblem index f85512b8..c2ebea8a 100644 --- a/app/assets/javascripts/user/app/templates/_list_content.emblem +++ b/app/assets/javascripts/user/app/templates/_list_content.emblem @@ -7,7 +7,7 @@ if list.orders = order.display span.currency= currency order.total span.created_at= time order.created_at - if displayTotal + if showTotal .list-orders-total.total = t 'total' span.currency= currency model.total diff --git a/app/assets/javascripts/user/app/templates/product_orders.emblem b/app/assets/javascripts/user/app/templates/product_orders.emblem index 476a23a6..af30c606 100644 --- a/app/assets/javascripts/user/app/templates/product_orders.emblem +++ b/app/assets/javascripts/user/app/templates/product_orders.emblem @@ -4,7 +4,7 @@ if modelDisabled .clearfix .panel ul.product-orders - each product_order in controller + each product_order in product_orders li.product_order = product_order.quantity | x @@ -14,8 +14,9 @@ if modelDisabled span.currency=currency product_order.total else li= t 'product_orders.no_orders' - li.total - = t 'product_orders.total' - span.right.currency=currency orderTotal -if model - a.tiny.button.right{action orderProducts} href="#"= t 'product_orders.order_button' + if showTotal + li.total + = t 'product_orders.total' + span.right.currency=currency orderTotal +if product_orders + a.order-selected-products-button{action orderProducts} href="#"= t 'product_orders.order_button' diff --git a/app/assets/stylesheets/supplier/foundation1/form_actions.css.sass b/app/assets/stylesheets/supplier/foundation1/_form_actions.css.sass similarity index 94% rename from app/assets/stylesheets/supplier/foundation1/form_actions.css.sass rename to app/assets/stylesheets/supplier/foundation1/_form_actions.css.sass index 4b310f20..878cab0d 100644 --- a/app/assets/stylesheets/supplier/foundation1/form_actions.css.sass +++ b/app/assets/stylesheets/supplier/foundation1/_form_actions.css.sass @@ -1,5 +1,3 @@ -@import font-awesome -@import ./foundation_and_overrides .form-actions .form-action-submit +button($bg: $button-submit-color, $padding: $button-sml) diff --git a/app/assets/stylesheets/supplier/foundation1/foundation_and_overrides.css.sass b/app/assets/stylesheets/supplier/foundation1/_foundation_and_overrides.css.sass similarity index 100% rename from app/assets/stylesheets/supplier/foundation1/foundation_and_overrides.css.sass rename to app/assets/stylesheets/supplier/foundation1/_foundation_and_overrides.css.sass diff --git a/app/assets/stylesheets/supplier/foundation1/menu_main.css.sass b/app/assets/stylesheets/supplier/foundation1/_menu_main.css.sass similarity index 96% rename from app/assets/stylesheets/supplier/foundation1/menu_main.css.sass rename to app/assets/stylesheets/supplier/foundation1/_menu_main.css.sass index 82465def..49878d86 100644 --- a/app/assets/stylesheets/supplier/foundation1/menu_main.css.sass +++ b/app/assets/stylesheets/supplier/foundation1/_menu_main.css.sass @@ -1,6 +1,3 @@ -@import constants -@import font-awesome -@import foundation_and_overrides header.top-menu height: 90px background-color: transparent diff --git a/app/assets/stylesheets/supplier/foundation1/menu_side.css.sass b/app/assets/stylesheets/supplier/foundation1/_menu_side.css.sass similarity index 91% rename from app/assets/stylesheets/supplier/foundation1/menu_side.css.sass rename to app/assets/stylesheets/supplier/foundation1/_menu_side.css.sass index e0396574..f8a929b4 100644 --- a/app/assets/stylesheets/supplier/foundation1/menu_side.css.sass +++ b/app/assets/stylesheets/supplier/foundation1/_menu_side.css.sass @@ -1,4 +1,3 @@ -@import constants aside.side-menu background-color: #444 position: fixed diff --git a/app/assets/stylesheets/supplier/foundation1/product_categories.css.sass b/app/assets/stylesheets/supplier/foundation1/_product_categories.css.sass similarity index 96% rename from app/assets/stylesheets/supplier/foundation1/product_categories.css.sass rename to app/assets/stylesheets/supplier/foundation1/_product_categories.css.sass index bee7500f..a4590397 100644 --- a/app/assets/stylesheets/supplier/foundation1/product_categories.css.sass +++ b/app/assets/stylesheets/supplier/foundation1/_product_categories.css.sass @@ -1,4 +1,3 @@ -@import font-awesome #product-category-list list-style: none li diff --git a/app/assets/stylesheets/supplier/foundation1/products_preview.css.sass b/app/assets/stylesheets/supplier/foundation1/_products_preview.css.sass similarity index 90% rename from app/assets/stylesheets/supplier/foundation1/products_preview.css.sass rename to app/assets/stylesheets/supplier/foundation1/_products_preview.css.sass index df30bbe3..8e4a4219 100644 --- a/app/assets/stylesheets/supplier/foundation1/products_preview.css.sass +++ b/app/assets/stylesheets/supplier/foundation1/_products_preview.css.sass @@ -1,4 +1,3 @@ -@import ./foundation_and_overrides .products_preview-date .products_preview-time-container float: left diff --git a/app/assets/stylesheets/supplier/foundation1/_qconstants.css.sass b/app/assets/stylesheets/supplier/foundation1/_qconstants.css.sass new file mode 100644 index 00000000..1a3502fa --- /dev/null +++ b/app/assets/stylesheets/supplier/foundation1/_qconstants.css.sass @@ -0,0 +1,7 @@ +//$qbrown: #634227 +$qbrown: #853d15 +$qbrown-active: lighten($qbrown, 20%) +$green: #7BB459 //Heineken +//$wood: image-url('textures/wood001-vertical.jpg') +$wood: image-url('textures/theme1.jpg') +$background-brown: #57351f diff --git a/app/assets/stylesheets/supplier/foundation1/dashboard.css.sass b/app/assets/stylesheets/supplier/foundation1/_qdashboard.css.sass similarity index 78% rename from app/assets/stylesheets/supplier/foundation1/dashboard.css.sass rename to app/assets/stylesheets/supplier/foundation1/_qdashboard.css.sass index 91ee5536..bc1c9c16 100644 --- a/app/assets/stylesheets/supplier/foundation1/dashboard.css.sass +++ b/app/assets/stylesheets/supplier/foundation1/_qdashboard.css.sass @@ -1,5 +1,6 @@ -@import foundation_and_overrides - +.dashboard-section-selection + float: right + white-space: nowrap .active-lists-table width: 100% .mark_list_as_helped diff --git a/app/assets/stylesheets/supplier/foundation1/displays.css.sass b/app/assets/stylesheets/supplier/foundation1/_qdisplays.css.sass similarity index 93% rename from app/assets/stylesheets/supplier/foundation1/displays.css.sass rename to app/assets/stylesheets/supplier/foundation1/_qdisplays.css.sass index 75a9dc26..989ab917 100644 --- a/app/assets/stylesheets/supplier/foundation1/displays.css.sass +++ b/app/assets/stylesheets/supplier/foundation1/_qdisplays.css.sass @@ -1,5 +1,3 @@ -@import ./foundation_and_overrides - .display-row @extend .row .display-label diff --git a/app/assets/stylesheets/supplier/foundation1/forms.css.sass b/app/assets/stylesheets/supplier/foundation1/_qforms.css.sass similarity index 96% rename from app/assets/stylesheets/supplier/foundation1/forms.css.sass rename to app/assets/stylesheets/supplier/foundation1/_qforms.css.sass index 6062a462..65742f9d 100644 --- a/app/assets/stylesheets/supplier/foundation1/forms.css.sass +++ b/app/assets/stylesheets/supplier/foundation1/_qforms.css.sass @@ -1,5 +1,3 @@ -@import ./foundation_and_overrides - .form-row @extend .row .form-label diff --git a/app/assets/stylesheets/supplier/base1-shared/icons.css.sass b/app/assets/stylesheets/supplier/foundation1/_qicons.css.sass similarity index 100% rename from app/assets/stylesheets/supplier/base1-shared/icons.css.sass rename to app/assets/stylesheets/supplier/foundation1/_qicons.css.sass diff --git a/app/assets/stylesheets/supplier/foundation1/_qlists.css.sass b/app/assets/stylesheets/supplier/foundation1/_qlists.css.sass new file mode 100644 index 00000000..379d0f4c --- /dev/null +++ b/app/assets/stylesheets/supplier/foundation1/_qlists.css.sass @@ -0,0 +1,36 @@ +td.boolean + +table-fit + &.needs_help + .boolean-true + @extend .fa + @extend .fa-exclamation + &.needs_payment + .boolean-true + @extend .fa + @extend .fa-money +.list-orders-container + .currency + float: right + list-style: none + $padding: 6px 0 6px 35px + .list-order-container + background-position: left center + background-repeat: no-repeat + +grid-column(12) + padding: $padding + border-bottom: 1px solid #eee + &.active + background-image: image-url('icons/order-check.png') + &.delivered + background-image: image-url('icons/order-doublecheck.png') + .created_at + float: right + padding-right: 20px + padding-left: 10px + .list-orders-total + +grid-column(12) + padding: $padding + border-top: 2px solid #444 + font-weight: bold + + diff --git a/app/assets/stylesheets/supplier/foundation1/_qsections.css.sass b/app/assets/stylesheets/supplier/foundation1/_qsections.css.sass new file mode 100644 index 00000000..e69de29b diff --git a/app/assets/stylesheets/supplier/foundation1/structure.css.sass b/app/assets/stylesheets/supplier/foundation1/_qstructure.css.sass similarity index 92% rename from app/assets/stylesheets/supplier/foundation1/structure.css.sass rename to app/assets/stylesheets/supplier/foundation1/_qstructure.css.sass index 6afdfa31..51f64c9b 100644 --- a/app/assets/stylesheets/supplier/foundation1/structure.css.sass +++ b/app/assets/stylesheets/supplier/foundation1/_qstructure.css.sass @@ -1,7 +1,4 @@ $side-spacing: 0px -@import constants -@import ./foundation_and_overrides -@import font-awesome .supplier-is-closed +alert($bg: $secondary-color) .close diff --git a/app/assets/stylesheets/supplier/foundation1/tables.css.sass b/app/assets/stylesheets/supplier/foundation1/_qtables.css.sass similarity index 80% rename from app/assets/stylesheets/supplier/foundation1/tables.css.sass rename to app/assets/stylesheets/supplier/foundation1/_qtables.css.sass index d2efefac..f8a78fa8 100644 --- a/app/assets/stylesheets/supplier/foundation1/tables.css.sass +++ b/app/assets/stylesheets/supplier/foundation1/_qtables.css.sass @@ -1,6 +1,3 @@ -@import constants -@import ./foundation_and_overrides -@import font-awesome table &.table // Bootstrap behaviour @@ -36,3 +33,10 @@ table span @extend .fa @extend .fa-times +.section-dashboard-orders + +button($bg: $secondary-color) + +button-icon-only + margin-right: 0.7rem + span + @extend .fa + @extend .fa-list-alt diff --git a/app/assets/stylesheets/supplier/base1-shared/section-tab-header.css.sass b/app/assets/stylesheets/supplier/foundation1/_section_tab_headers.css.sass similarity index 81% rename from app/assets/stylesheets/supplier/base1-shared/section-tab-header.css.sass rename to app/assets/stylesheets/supplier/foundation1/_section_tab_headers.css.sass index 7dad190d..8666d185 100644 --- a/app/assets/stylesheets/supplier/base1-shared/section-tab-header.css.sass +++ b/app/assets/stylesheets/supplier/foundation1/_section_tab_headers.css.sass @@ -24,3 +24,10 @@ content: '' display: block clear: left + .goto-sections-index-tab-header + float: left + span + @extend .fa + @extend .fa-share + @extend .fa-lg + @extend .fa-rotate-270 diff --git a/app/assets/stylesheets/supplier/foundation1/application.css b/app/assets/stylesheets/supplier/foundation1/application.css deleted file mode 100644 index 28915405..00000000 --- a/app/assets/stylesheets/supplier/foundation1/application.css +++ /dev/null @@ -1,9 +0,0 @@ -/* -*= require ./foundation_and_overrides -*= require 'jquery-ui-1.8.23.custom.css' -*= require qtip -*= require_directory ../base1-shared -*= require pickdate -*= require_directory . -*= require_self -*/ diff --git a/app/assets/stylesheets/supplier/foundation1/application.css.sass b/app/assets/stylesheets/supplier/foundation1/application.css.sass new file mode 100644 index 00000000..8f859b6e --- /dev/null +++ b/app/assets/stylesheets/supplier/foundation1/application.css.sass @@ -0,0 +1,18 @@ +//= require qtip +//= require_directory ../base1-shared +//= require pickdate +@import ./qconstants +@import ./foundation_and_overrides +@import ./qstructure +@import ./qicons +@import ./qdashboard +@import ./qdisplays +@import ./form_actions +@import ./qforms +@import ./menu_main +@import ./menu_side +@import ./product_categories +@import ./products_preview +@import ./qtables +@import ./section_tab_headers +@import ./qlists diff --git a/app/assets/stylesheets/supplier/foundation1/lists.css.sass b/app/assets/stylesheets/supplier/foundation1/lists.css.sass deleted file mode 100644 index 5a34643b..00000000 --- a/app/assets/stylesheets/supplier/foundation1/lists.css.sass +++ /dev/null @@ -1,12 +0,0 @@ -@import font-awesome -@import ./foundation_and_overrides -td.boolean - +table-fit - &.needs_help - .boolean-true - @extend .fa - @extend .fa-exclamation - &.needs_payment - .boolean-true - @extend .fa - @extend .fa-money diff --git a/app/assets/stylesheets/user/foundation/_qproduct_orders.css.sass b/app/assets/stylesheets/user/foundation/_qproduct_orders.css.sass index 0b3e9a3a..8fb6536f 100644 --- a/app/assets/stylesheets/user/foundation/_qproduct_orders.css.sass +++ b/app/assets/stylesheets/user/foundation/_qproduct_orders.css.sass @@ -15,3 +15,6 @@ ul.product-orders .icon @extend .fa @extend .fa-times +.order-selected-products-button + float: right + +button($padding: $button-tny) diff --git a/app/controllers/suppliers/lists_controller.rb b/app/controllers/suppliers/lists_controller.rb index 385d2ddf..4c2261db 100644 --- a/app/controllers/suppliers/lists_controller.rb +++ b/app/controllers/suppliers/lists_controller.rb @@ -21,7 +21,7 @@ module Suppliers respond_to do |format| format.html # index.html.erb - format.json { render json: @lists, each_serializer: ListSerializer } + format.json { render json: @lists, each_serializer: SupplierListSerializer } end end @@ -64,7 +64,7 @@ module Suppliers if params[:old_style] then render json: @list.with_orders_as_json else - render json: @list + render json: @list, serializer: SupplierListSerializer end end end diff --git a/app/serializers/supplier_list_serializer.rb b/app/serializers/supplier_list_serializer.rb new file mode 100644 index 00000000..91197775 --- /dev/null +++ b/app/serializers/supplier_list_serializer.rb @@ -0,0 +1,19 @@ +class SupplierListSerializer < Qwaiter::Serializer + # user ids for facebook pictures + self.root = :list + embed :ids, include: true + attributes :extended_version, :state, :needs_help, :needs_payment, :user_requests_closing, :is_paid, :price, + :table_id, :table_number, :section_id, :user_ids, :supplier_id, :closed_at + has_many :orders + #has_many :product_categories + has_one :table, serializer: SupplierTableSerializer + has_many :join_requests + has_many :users, serializer: SupplierUserSerializer + + #def has_active_orders + #object.has_active_orders? + #end + def extended_version + true + end +end diff --git a/app/serializers/supplier_supplier_serializer.rb b/app/serializers/supplier_supplier_serializer.rb new file mode 100644 index 00000000..cf9037d1 --- /dev/null +++ b/app/serializers/supplier_supplier_serializer.rb @@ -0,0 +1,9 @@ +class SupplierSupplierSerializer < Qwaiter::Serializer + self.root = :supplier + attributes :extended_version, :open, :name + + def extended_version + false + end + +end diff --git a/app/serializers/supplier_table_serializer.rb b/app/serializers/supplier_table_serializer.rb new file mode 100644 index 00000000..8ffc09a2 --- /dev/null +++ b/app/serializers/supplier_table_serializer.rb @@ -0,0 +1,6 @@ +class SupplierTableSerializer < Qwaiter::Serializer + self.root = :table + embed :ids, include: true + attributes :number, :width, :height, :position_x, :position_y, :section_id, :occupied, :needs_help + has_one :supplier, serializer: SupplierSupplierSerializer +end diff --git a/app/serializers/supplier_user_serializer.rb b/app/serializers/supplier_user_serializer.rb new file mode 100644 index 00000000..4b5a27ec --- /dev/null +++ b/app/serializers/supplier_user_serializer.rb @@ -0,0 +1,4 @@ +class SupplierUserSerializer < Qwaiter::Serializer + self.root = :user + attributes :email, :facebook_id +end diff --git a/app/serializers/user_list_serializer.rb b/app/serializers/user_list_serializer.rb index c1c4e565..16de2237 100644 --- a/app/serializers/user_list_serializer.rb +++ b/app/serializers/user_list_serializer.rb @@ -1,7 +1,7 @@ class UserListSerializer < Qwaiter::Serializer # user ids for facebook pictures #embed :ids - attributes :state, :needs_help, :needs_payment, :user_requests_closing, :is_paid, :price, :table_id, :table_number, :section_id, :user_ids, :supplier_name, :closed_at + attributes :state, :needs_help, :needs_payment, :user_requests_closing, :is_paid, :price, :table_id, :table_number, :section_id, :user_ids, :supplier_name, :closed_at, :supplier_id #def has_active_orders #object.has_active_orders? diff --git a/app/views/suppliers/lists/show.html.slim b/app/views/suppliers/lists/show.html.slim index 22bc91ab..e70042d7 100644 --- a/app/views/suppliers/lists/show.html.slim +++ b/app/views/suppliers/lists/show.html.slim @@ -1,35 +1,37 @@ -.page-header= title t('supplier.lists.show.title', list: List.model_name.human) -dl.dl-horizontal - dt= List.human_attribute_name(:created_at) - dd= l @list.created_at, format: :short - dt= t('supplier.lists.show.users') - dd= @list.users.map(&:supplier_name).join(', ') -.display-row - .display-label - span data-t='attributes.list.created_at' - .display-field - span data-time=@list.created_at.iso8601 -.well - table#list-table.table.list-table - thead - tr - th= Order.model_name.human - th.currency= Product.human_attribute_name(:price) - tbody - tr - td colspan=2 = slider_image - tfoot - tr - td - td.currency - strong.list-total -script#list-order-template[type="text/html"]= render 'supplier/list_order.mustache' -.form-actions - = link_to t("helpers.links.back"), suppliers_lists_path(date: @list.created_at.strftime('%Y-%m-%d')), class: 'btn' - ' - = link_to t('helpers.links.edit'), [:edit, :suppliers, @list], class: 'btn btn-info' -- content_for :footer do - javascript: - jQuery(function(){ - Qsupplier.load_list('#{@list.id}'); - }) +- content_for :head do + = javascript_include_tag 'supplier/app/application' +/.page-header= title t('supplier.lists.show.title', list: List.model_name.human) +/dl.dl-horizontal + /dt= List.human_attribute_name(:created_at) + /dd= l @list.created_at, format: :short + /dt= t('supplier.lists.show.users') + /dd= @list.users.map(&:supplier_name).join(', ') +/.display-row + /.display-label + /span data-t='attributes.list.created_at' + /.display-field + /span data-time=@list.created_at.iso8601 +/.well + /table#list-table.table.list-table + /thead + /tr + /th= Order.model_name.human + /th.currency= Product.human_attribute_name(:price) + /tbody + /tr + /td colspan=2 = slider_image + /tfoot + /tr + /td + /td.currency + /strong.list-total +/script#list-order-template[type="text/html"]= render 'supplier/list_order.mustache' +/.form-actions + /= link_to t("helpers.links.back"), suppliers_lists_path(date: @list.created_at.strftime('%Y-%m-%d')), class: 'btn' + /' + /= link_to t('helpers.links.edit'), [:edit, :suppliers, @list], class: 'btn btn-info' +/- content_for :footer do + /javascript: + /jQuery(function(){ + /Qsupplier.load_list('#{@list.id}'); + /}) diff --git a/config/initializers/symbol_to_json.rb b/config/initializers/symbol_to_json.rb new file mode 100644 index 00000000..84594e9c --- /dev/null +++ b/config/initializers/symbol_to_json.rb @@ -0,0 +1,9 @@ +class Symbol + def to_json(*) + to_s + end + + def as_json(*) + to_s + end +end diff --git a/config/locales/user.en.yml b/config/locales/user.en.yml index eb821d59..db12c46e 100644 --- a/config/locales/user.en.yml +++ b/config/locales/user.en.yml @@ -1,5 +1,6 @@ en: user: + total: Total messages: cannot_order_on_non_active_list: You cannot place an order on a closed list no_active_list: There is no active list diff --git a/config/locales/user.nl.yml b/config/locales/user.nl.yml index dd0d011b..d29b9273 100644 --- a/config/locales/user.nl.yml +++ b/config/locales/user.nl.yml @@ -1,5 +1,6 @@ nl: user: + total: Totaal messages: cannot_order_on_non_active_list: Je kan niet bestellen op een gesloten lijst no_active_list: Er is momenteel geen lijst actief diff --git a/spec/acceptance_steps/users/order_products_steps.rb b/spec/acceptance_steps/users/order_products_steps.rb index 54701a36..9e6feda8 100644 --- a/spec/acceptance_steps/users/order_products_steps.rb +++ b/spec/acceptance_steps/users/order_products_steps.rb @@ -7,12 +7,12 @@ end step "the user clicks on the order product button :product_name" do |product_name| @last_product = instance_variable_get product_name.underscore.gsub(/\s/, '_').prepend('@') - button = find ".order-product-#{@last_product.id}" + button = find ".order-product-#{@last_product.id} .add-product-to-list" button.click end step "the user clicks on the user order button" do - find('#active-order-table .btn-primary').click + find('.order-selected-products-button').click sleep 1 end diff --git a/spec/models/product_category_spec.rb b/spec/models/product_category_spec.rb index fbc9d6fb..727c39f7 100644 --- a/spec/models/product_category_spec.rb +++ b/spec/models/product_category_spec.rb @@ -1,14 +1,36 @@ require 'spec_helper' describe ProductCategory do + let(:all_week){ Array.new(7, 1) } + let(:show_saturday){ [0,0,0,0,0,0,1] } + let(:show_sunday){ [1,0,0,0,0,0,0] } + describe '#week_days' do let(:product_category) { create :product_category } subject { product_category } - let(:default) { Array.new(7, 1) } + let(:default) { all_week } its(:week_days) { should == default } it "typecasts strings into integers" do subject.week_days = Array.new(7, "0") subject.week_days.should == Array.new(7, 0) end end + + describe '#for_supplier_in_time' do + subject{ described_class } + let(:supplier){ create :supplier, time_zone: 'Tijuana', night_offset: 150 } + + it 'works for a normal product category' do + c1 = create :product_category, supplier: supplier, name: 'Lunch', full_day: true, week_days: all_week + c2 = create :product_category, supplier: supplier, name: 'Happy hour', full_day: false, week_days: all_week, start_from: 1320, end_on: 1380 # from 22 to 23 hour + subject.for_supplier_in_time(supplier, Time.now.beginning_of_day + 1300.minutes).should == [c1] + subject.for_supplier_in_time(supplier, Time.now.beginning_of_day + 1350.minutes).should == [c1, c2] + end + + it 'finds sunday morning products on saturday categories' do + c1 = create :product_category, supplier: supplier, name: 'Lunch', full_day: true, week_days: show_saturday + c2 = create :product_category, supplier: supplier, name: 'Sunday special', full_day: true, week_days: show_sunday + end + + end end diff --git a/spec/symbol_spec.rb b/spec/symbol_spec.rb new file mode 100644 index 00000000..2dcccf83 --- /dev/null +++ b/spec/symbol_spec.rb @@ -0,0 +1,11 @@ +require 'spec_helper' + +describe Symbol do + it 'to_json becomes a string in json format' do + :abc.to_json.should == 'abc' + end + + it 'as_json becomes a string in json format' do + :abc.as_json.should == 'abc' + end +end