diff --git a/app/assets/javascripts/supplier/app/components/menu-product.js.coffee b/app/assets/javascripts/supplier/app/components/menu-product.js.coffee index 4ac87b69..8c558f89 100644 --- a/app/assets/javascripts/supplier/app/components/menu-product.js.coffee +++ b/app/assets/javascripts/supplier/app/components/menu-product.js.coffee @@ -50,7 +50,11 @@ App.MenuProductComponent = Ember.Component.extend removeProductVariant: (product_variant)-> product_variant.destroyRecord() didInsertElement: -> - @set 'editMode', true if @get('product.isNew') + if @get('product.isNew') + @set 'editMode', true + Ember.run.later => + @$('input:first').focus() + , 300 namePlaceholder: (-> t "attributes.product.name").property() pricePlaceholder: (-> t "attributes.product.price").property() codePlaceholder: (-> t "attributes.product.code").property() diff --git a/app/assets/javascripts/supplier/app/components/sections-header.js.coffee b/app/assets/javascripts/supplier/app/components/sections-header.js.coffee index d652b487..4b27f94f 100644 --- a/app/assets/javascripts/supplier/app/components/sections-header.js.coffee +++ b/app/assets/javascripts/supplier/app/components/sections-header.js.coffee @@ -1,6 +1,6 @@ App.SectionsHeaderComponent = Ember.Component.extend classNames: ['sections-switcher-container', 'main-section-header'] - sections: (-> @get('targetObject.store').peekAll('section') ).property() + sections: Ember.computed -> @store.peekAll('section') actions: setSection: (section)-> if section and section is @get('active_section') diff --git a/app/assets/javascripts/supplier/app/controllers/index_controller.js.coffee b/app/assets/javascripts/supplier/app/controllers/index.js.coffee similarity index 75% rename from app/assets/javascripts/supplier/app/controllers/index_controller.js.coffee rename to app/assets/javascripts/supplier/app/controllers/index.js.coffee index ab66192d..e501a8ef 100644 --- a/app/assets/javascripts/supplier/app/controllers/index_controller.js.coffee +++ b/app/assets/javascripts/supplier/app/controllers/index.js.coffee @@ -1,14 +1,15 @@ App.IndexController = Ember.Controller.extend show_lists: true show_orders: true - lists: (-> @store.peekAll('list')).property() + loading_data: true + lists: Ember.computed -> @store.peekAll('list') orders: Ember.computed -> @store.peekAll('order') - sections: (-> @store.peekAll('section')).property() - active_section: Ember.computed.alias 'globals.active_section' - active_lists: Ember.computed 'lists.@each.state', 'active_section.id', 'lists.@each.table', -> + sections: Ember.computed -> @store.peekAll('section') + #active_section: Ember.computed.alias 'globals.active_section' + active_lists: Ember.computed 'lists.@each.state', 'globals.active_section.id', 'lists.@each.table', -> @get('orders') # trigger orders, otherwise observers are not initialized/triggered (active_orders) - if section_id = @get('active_section.id') - lists = @get('lists').filter (l)=>( l.get('section.id') == section_id && l.get('state') == 'active' ) + if section_id = @get('globals.active_section.id') + lists = @get('lists').filter (l)=>( l.get('table.section.id') == section_id && l.get('state') == 'active' ) else lists = @get('lists').filterBy('state', 'active') lists.sortBy('created_at') # Not reversed, oldest on top, start with oldest order first, work your way down :-) Customer happyness diff --git a/app/assets/javascripts/supplier/app/controllers/menu_controller.js.coffee b/app/assets/javascripts/supplier/app/controllers/menu_controller.js.coffee index 578803c5..7dd4f834 100644 --- a/app/assets/javascripts/supplier/app/controllers/menu_controller.js.coffee +++ b/app/assets/javascripts/supplier/app/controllers/menu_controller.js.coffee @@ -27,4 +27,5 @@ App.MenuController = Ember.Controller.extend model: @store.createRecord('product_category', position: @get('product_categories.length')) close: -> @get('model').deleteRecord() addProduct: (product_category)-> - product_category.get('products').addObject @store.createRecord 'product', position: product_category.get('products.length') + product = @store.createRecord 'product', position: product_category.get('products.length') + product_category.get('products').addObject product diff --git a/app/assets/javascripts/supplier/app/controllers/modals/employee_edit.js.coffee b/app/assets/javascripts/supplier/app/controllers/modals/employee_edit.js.coffee index cd1a7aab..8b4addda 100644 --- a/app/assets/javascripts/supplier/app/controllers/modals/employee_edit.js.coffee +++ b/app/assets/javascripts/supplier/app/controllers/modals/employee_edit.js.coffee @@ -14,6 +14,8 @@ App.modals.EmployeeEditController = App.modals.BaseController.extend '#8A2BE2' '#458B00' '#EEAD0E' + '#FF1493' + '#8B0A50' ] ).property() actions: diff --git a/app/assets/javascripts/supplier/app/controllers/modals/section_area.js.coffee b/app/assets/javascripts/supplier/app/controllers/modals/section_area.js.coffee index 0bae523c..e4f1929e 100644 --- a/app/assets/javascripts/supplier/app/controllers/modals/section_area.js.coffee +++ b/app/assets/javascripts/supplier/app/controllers/modals/section_area.js.coffee @@ -11,6 +11,8 @@ App.modals.SectionAreaController = App.modals.BaseController.extend '#8A2BE2' '#458B00' '#EEAD0E' + '#FF1493' + '#8B0A50' ] ).property() actions: diff --git a/app/assets/javascripts/supplier/app/controllers/orders-display.js.coffee b/app/assets/javascripts/supplier/app/controllers/orders-display.js.coffee index 89fc2731..a006281d 100644 --- a/app/assets/javascripts/supplier/app/controllers/orders-display.js.coffee +++ b/app/assets/javascripts/supplier/app/controllers/orders-display.js.coffee @@ -2,5 +2,5 @@ App.OrdersDisplayController = Ember.Controller.extend sections: Ember.computed -> @store.peekAll('section') orders: Ember.computed 'model.[]', 'globals.active_section.id', -> orders = @get('model').filterBy('needs_supplier_attention') - orders = orders.filterBy('list.section.id', id) if id = @get('globals.active_section.id') + orders = orders.filterBy('list.table.section.id', id) if id = @get('globals.active_section.id') orders.sortBy('created_at') # Not reversed, oldest on top, start with oldest order first :-) Customer happyness diff --git a/app/assets/javascripts/supplier/app/initializers/globals.js.coffee b/app/assets/javascripts/supplier/app/initializers/globals.js.coffee index 13b3b9d8..b26e3333 100644 --- a/app/assets/javascripts/supplier/app/initializers/globals.js.coffee +++ b/app/assets/javascripts/supplier/app/initializers/globals.js.coffee @@ -4,6 +4,7 @@ Globals = Ember.Object.extend isDragging: false active_section: null flash_message: '' + modal_active: false locale: Qstorage.getItem('locale') App.initializer name: 'injectCurrent' diff --git a/app/assets/javascripts/supplier/app/models/list.js.coffee b/app/assets/javascripts/supplier/app/models/list.js.coffee index a097e624..b83794c8 100644 --- a/app/assets/javascripts/supplier/app/models/list.js.coffee +++ b/app/assets/javascripts/supplier/app/models/list.js.coffee @@ -12,10 +12,9 @@ App.List = DS.Model.extend closed_at: DS.attr('date') users: DS.hasMany('user', async: false) #table_number: attr 'number' - table: DS.belongsTo('table', inverse: 'active_list', async: false) # should be async, but synchroneously loading now fails with JSONAPI, this seems to work + table: DS.belongsTo('table', inverse: 'active_list', async: true) # should be async, but synchroneously loading now fails with JSONAPI, this seems to work #users: DS.hasMany('user', inverse: 'active_list') orders: DS.hasMany('order', async: false) - section: DS.belongsTo('section', async: false) # should be async, but synchroneously loading now fails with JSONAPI, this seems to work # COMPUTED PROPERTIES active: Ember.computed.equal 'state', 'active' diff --git a/app/assets/javascripts/supplier/app/models/table.js.coffee b/app/assets/javascripts/supplier/app/models/table.js.coffee index 36893a15..a7e2bc45 100644 --- a/app/assets/javascripts/supplier/app/models/table.js.coffee +++ b/app/assets/javascripts/supplier/app/models/table.js.coffee @@ -6,7 +6,7 @@ App.Table = DS.Model.extend position_x: attr 'number' position_y: attr 'number' # occupied: attr 'boolean' - section: DS.belongsTo('section') + section: DS.belongsTo('section', async: false) #active_list: DS.belongsTo('list', key: 'active_list') active_list: DS.belongsTo('list', async: true) #list: DS.belongsTo('list') diff --git a/app/assets/javascripts/supplier/app/models/user.js.coffee b/app/assets/javascripts/supplier/app/models/user.js.coffee index 77e2efbc..e2bb2a0b 100644 --- a/app/assets/javascripts/supplier/app/models/user.js.coffee +++ b/app/assets/javascripts/supplier/app/models/user.js.coffee @@ -4,7 +4,7 @@ App.User= DS.Model.extend uid: attr('string') provider: attr('string') avatar: attr('string') - list: DS.belongsTo('list') # in ember scope not many to many (yet) + lists: DS.hasMany('list') # in ember scope not many to many (yet) join_requests: DS.hasMany('join_request') avatar_tag: Ember.computed 'avatar', 'name', -> avatar = @get('avatar') || "#{$asset_path}/supplier/unknown-avatar.png" diff --git a/app/assets/javascripts/supplier/app/routes/application.js.coffee.erb b/app/assets/javascripts/supplier/app/routes/application.js.coffee.erb index 23634c42..c1199d6f 100644 --- a/app/assets/javascripts/supplier/app/routes/application.js.coffee.erb +++ b/app/assets/javascripts/supplier/app/routes/application.js.coffee.erb @@ -17,7 +17,8 @@ App.ApplicationRoute = Ember.Route.extend #@sections = @store.findAll 'section' #Ember.RSVP.all([@product_categories, @sections]).then (results)=> @supplier.reload().then => - @store.query('list', state: 'active') #.then (lists) -> lists.invoke('get', 'table') + @store.query('list', state: 'active').then => #.then (lists) -> lists.invoke('get', 'table') + @controllerFor('index').set 'loading_data', false #@lists = @store.peekAll 'list' # product_categories = controller.set 'product_categories', @store.peekAll('product_category') #@store.findAll 'order', state: 'active' included in list @@ -76,11 +77,13 @@ App.ApplicationRoute = Ember.Route.extend outlet: 'modal' view: 'modal' controller: controller + @set 'globals.modal_active', true closeModal: -> @disconnectOutlet outlet: 'modal' parentView: 'application' + @set 'globals.modal_active', false confirm: (options = {})-> @send 'openModal', 'confirm', model: Ember.Object.create @@ -131,7 +134,7 @@ App.ApplicationRoute = Ember.Route.extend @store.pushPayload(data.payload) if order_id = data.payload.data.id order = @store.peekRecord('order', order_id) - return if @get('globals.active_section.id') and order.get('list.section.id') isnt @get('globals.active_section.id') + return if @get('globals.active_section.id') and order.get('list.table.section.id') isnt @get('globals.active_section.id') @set 'globals.flash_message', order.get('display_with_table') try ion.sound.play('water_droplet') new_list: (data)-> diff --git a/app/assets/javascripts/supplier/app/templates/components/menu-product.emblem b/app/assets/javascripts/supplier/app/templates/components/menu-product.emblem index 60269c8a..b079aeea 100644 --- a/app/assets/javascripts/supplier/app/templates/components/menu-product.emblem +++ b/app/assets/javascripts/supplier/app/templates/components/menu-product.emblem @@ -34,7 +34,7 @@ if editMode = t 'product_variant.add_product_variant' else if showProduct - .row + .row.show-menu-product-row .small-3.columns span= product.name = errors product.errors.name includeAttribute="product" diff --git a/app/assets/javascripts/supplier/app/templates/dashboard/active-list.emblem b/app/assets/javascripts/supplier/app/templates/dashboard/active-list.emblem index 11e16c11..d131acda 100644 --- a/app/assets/javascripts/supplier/app/templates/dashboard/active-list.emblem +++ b/app/assets/javascripts/supplier/app/templates/dashboard/active-list.emblem @@ -11,6 +11,6 @@ span.currency=currency list.total .actions = button-mark-list-helped content=list - = button-remove-list-needs-payment content=list + /= button-remove-list-needs-payment content=list = button-close-list content=list = button-show-list content=list diff --git a/app/assets/javascripts/supplier/app/templates/dashboard/active-order.emblem b/app/assets/javascripts/supplier/app/templates/dashboard/active-order.emblem index 424c7b90..1540b7c0 100644 --- a/app/assets/javascripts/supplier/app/templates/dashboard/active-order.emblem +++ b/app/assets/javascripts/supplier/app/templates/dashboard/active-order.emblem @@ -8,6 +8,7 @@ = link-to 'section' order.list.table.section class="link-to-section" span=order.list.table.section.title span.currency=currency order.total + .show-list-button-container= button-show-list content=order.list span.time= time order.created_at format="HH:mm" .actions = button-mark-order-active order=order diff --git a/app/assets/javascripts/supplier/app/templates/index.emblem b/app/assets/javascripts/supplier/app/templates/index.emblem index e8762160..2141a91b 100644 --- a/app/assets/javascripts/supplier/app/templates/index.emblem +++ b/app/assets/javascripts/supplier/app/templates/index.emblem @@ -1,37 +1,40 @@ -.row: .small-12.columns - = sections-header active_section=globals.active_section - if (can "manage" globals.current_supplier) - unless globals.current_supplier.open - .alert-box.alert.radius data-alert=true - = t 'supplier.you_are_currently_closed_alert' - a{ action "markSupplierOpen" }= t 'supplier.open_for_orders' - .page-header - if active_lists.length - h3.dashboard-lists-header{action "toggleDashboardLists"} - if show_lists - span.icon - else - span.icon.collapsed - =t 'active_lists.title' - span= list_number_info - else - h3=t 'dashboard.active_lists.no_lists' - if show_lists_table - .active-lists-table - each active_lists as |list| - = dashboard-active-list list=list - .page-header - if active_orders.length - h3.dashboard-orders-header{action "toggleDashboardOrders"} - if show_orders - span.icon - else - span.icon.collapsed - =t 'active_orders.title' - span= order_number_info - else - h3= t 'dashboard.active_orders.no_orders' - if show_orders_table - .active-orders-table - each active_orders as |order| - = dashboard-active-order order=order +if loading_data + .row: .small-12.columns: .panel: span.loading +else + .row: .small-12.columns + = sections-header active_section=globals.active_section + if (can "manage" globals.current_supplier) + unless globals.current_supplier.open + .alert-box.alert.radius data-alert=true + = t 'supplier.you_are_currently_closed_alert' + a{ action "markSupplierOpen" }= t 'supplier.open_for_orders' + .page-header + if active_lists.length + h3.dashboard-lists-header{action "toggleDashboardLists"} + if show_lists + span.icon + else + span.icon.collapsed + =t 'active_lists.title' + span= list_number_info + else + h3=t 'dashboard.active_lists.no_lists' + if show_lists_table + .active-lists-table + each active_lists as |list| + = dashboard-active-list list=list + .page-header + if active_orders.length + h3.dashboard-orders-header{action "toggleDashboardOrders"} + if show_orders + span.icon + else + span.icon.collapsed + =t 'active_orders.title' + span= order_number_info + else + h3= t 'dashboard.active_orders.no_orders' + if show_orders_table + .active-orders-table + each active_orders as |order| + = dashboard-active-order order=order diff --git a/app/assets/javascripts/supplier/app/templates/list/_content.emblem b/app/assets/javascripts/supplier/app/templates/list/_content.emblem index deb4ea41..b0ba1bdd 100644 --- a/app/assets/javascripts/supplier/app/templates/list/_content.emblem +++ b/app/assets/javascripts/supplier/app/templates/list/_content.emblem @@ -17,9 +17,10 @@ if list.active .display-field = button-change-list-table list=list .display-row - .display-label   + .display-label.show-for-medium-up   .display-field = button-mark-list-helped content=list + = button-remove-list-needs-payment content=list = button-close-list content=list = users-buttons users=list.users if list.sorted_orders diff --git a/app/assets/stylesheets/supplier/foundation1/components/_menu-products.sass b/app/assets/stylesheets/supplier/foundation1/components/_menu-products.sass index e00ab57f..dc71f3ce 100644 --- a/app/assets/stylesheets/supplier/foundation1/components/_menu-products.sass +++ b/app/assets/stylesheets/supplier/foundation1/components/_menu-products.sass @@ -26,7 +26,7 @@ .time-range color: rgb(39, 6, 121) .edit-product-category-button - +push-button($bg: $secondary-color, $padding: 5px) + +push-button($bg: $secondary-color) color: $warning-color font-size: 0.7em vertical-align: top @@ -35,7 +35,7 @@ @extend .fa-lg @extend .fa-edit .add-product-product_category-button - +push-button($bg: $secondary-color) + +push-button($bg: $primary-color) font-size: 0.7em position: absolute right: 10px @@ -51,7 +51,8 @@ color: #444 .time-range color: rgb(39, 6, 121) - +.show-menu-product-row + padding: 4px 0 .menu-product-container &.inactive color: #777 @@ -70,10 +71,10 @@ font-weight: bold .edit-product-action +push-button($bg: $secondary-color) - padding: 4px - font-size: 0.7em + font-size: 0.9em span - @extend .fa, .fa-edit + @extend .fa + @extend .fa-edit .rollback-product-action +push-button($bg: $secondary-color) color: $warning-color diff --git a/app/assets/stylesheets/supplier/foundation1/resources/_dashboard.sass b/app/assets/stylesheets/supplier/foundation1/resources/_dashboard.sass index 769f7319..4734e670 100644 --- a/app/assets/stylesheets/supplier/foundation1/resources/_dashboard.sass +++ b/app/assets/stylesheets/supplier/foundation1/resources/_dashboard.sass @@ -43,6 +43,8 @@ +active-list-div .link-to-section +active-list-div + .show-list-button-container + +active-list-div(right) .currency +active-list-div font-weight: bold diff --git a/app/serializers/suppliers/list_serializer.rb b/app/serializers/suppliers/list_serializer.rb index f62fd19e..5cc5145c 100644 --- a/app/serializers/suppliers/list_serializer.rb +++ b/app/serializers/suppliers/list_serializer.rb @@ -6,5 +6,4 @@ class Suppliers::ListSerializer has_many :join_requests, serializer: Suppliers::JoinRequestSerializer has_many :users, serializer: Suppliers::UserSerializer has_one :table, serializer: Suppliers::TableSerializer - has_one :section, serializer: Suppliers::SectionSerializer end