Supplier main board section selector
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
Qsupplier.App = Ember.Application.create
|
||||
LOG_TRANSITIONS: true
|
||||
rootElement: '#app'
|
||||
rootElement: '#ember-app-container'
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
Qsupplier.App.ApplicationController = Ember.Controller.extend
|
||||
init: ->
|
||||
#@set 'supplier', @store.createRecord('supplier', name: 'kkkl')
|
||||
@set 'supplier', @store.find('supplier', 'current')
|
||||
@@ -1,17 +1,18 @@
|
||||
Qsupplier.App.IndexController = Ember.ObjectController.extend
|
||||
needs: ['application']
|
||||
active_lists: (->
|
||||
if @get('sectionId')
|
||||
@get('lists').filter (l)=>( l.get('section.id') == @get('sectionId') && 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', 'sectionId')
|
||||
).property('lists.@each.state', 'active_section_id')
|
||||
|
||||
active_orders: (->
|
||||
if @get('sectionId')
|
||||
@get('orders').filter (o)=>( o.get('section.id') == @get('sectionId') && 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', 'sectionId')
|
||||
).property('orders.@each.state', 'active_section_id')
|
||||
|
||||
markListAsHelped: (id)->
|
||||
if list = Qsupplier.App.List.findCached(id)
|
||||
@@ -30,4 +31,3 @@ Qsupplier.App.IndexController = Ember.ObjectController.extend
|
||||
$.post('/supplier/mark_order_in_process', order_id: id)
|
||||
if order = Qsupplier.App.Order.findCached(id)
|
||||
order.set('state', 'active')
|
||||
sectionId: ''
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
attr = DS.attr
|
||||
Qsupplier.App.Supplier = DS.Model.extend
|
||||
name: attr 'string'
|
||||
@@ -11,9 +11,10 @@ Qsupplier.App.IndexRoute = Ember.Route.extend
|
||||
# use filter to create a scope on all the records
|
||||
lists: @store.filter 'list', -> true
|
||||
orders: @store.filter 'order', -> true
|
||||
sections: @store.find 'section'
|
||||
setupController: (controller, model)->
|
||||
controller.set('model', model)
|
||||
$('#section_selector').on 'change', (-> controller.set('sectionId', $(this).val()))
|
||||
#$('#section_selector').on 'change', (-> controller.set('sectionId', $(this).val()))
|
||||
#controller.set 'lists', @store.all('list')
|
||||
#controller.set 'lists', Qsupplier.App.List.all() #.filterProperty('state', 'active')
|
||||
#controller.set 'orders', Qsupplier.App.Order.all()
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
.page-header
|
||||
div.pull-right
|
||||
'{{view 'Qsupplier.App.HomeSectionSelectorView' content=controller.sections prompt=controllers.application.supplier.name}}
|
||||
'{{view 'Qsupplier.App.HomeSectionJumperView'}}
|
||||
h3 {{t 'active_lists.title'}}
|
||||
.well
|
||||
table.active-lists-table.table
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
Qsupplier.App.HomeSectionJumperView = Ember.View.extend
|
||||
tagName: 'a'
|
||||
attributeBindings: ['href']
|
||||
href: (-> Routes.suppliers_section_path(@get('controller.active_section_id') || 'nothing')).property('controller.active_section_id')
|
||||
isVisible: (-> !!@get('controller.active_section_id') ).property('controller.active_section_id')
|
||||
template: Ember.Handlebars.compile('=>')
|
||||
@@ -0,0 +1,8 @@
|
||||
HomeSectionOption = Ember.SelectOption.extend
|
||||
select_label: (-> "- #{@get('content.title')}").property('content.title')
|
||||
Qsupplier.App.HomeSectionSelectorView = Ember.Select.extend
|
||||
classNames: 'section_selector'
|
||||
optionView: HomeSectionOption
|
||||
valueBinding: 'controller.active_section_id'
|
||||
optionValuePath: 'content.id'
|
||||
optionLabelPath: 'select_label'
|
||||
@@ -146,7 +146,7 @@ root.Qsupplier=
|
||||
)
|
||||
|
||||
load_active_lists: () ->
|
||||
$.get('/supplier/active_lists.json?section_id='+($('#section_selector').val() || ''), (res) =>
|
||||
$.get('/supplier/active_lists.json?section_id='+($('.section_selector').val() || ''), (res) =>
|
||||
body = $('#active-lists-table tbody')
|
||||
body.find('tr').remove()
|
||||
foot = $('#active-lists-table tfoot')
|
||||
@@ -161,7 +161,7 @@ root.Qsupplier=
|
||||
)
|
||||
|
||||
load_active_orders: () ->
|
||||
$.get('/supplier/active_orders.json?section_id='+($('#section_selector').val() || ''), (res) =>
|
||||
$.get('/supplier/active_orders.json?section_id='+($('.section_selector').val() || ''), (res) =>
|
||||
body = $('#active-orders-table tbody')
|
||||
body.html('')
|
||||
foot = $('#active-orders-table tfoot')
|
||||
|
||||
@@ -11,6 +11,12 @@ class SupplierController < ApplicationController
|
||||
@supplier = current_supplier
|
||||
end
|
||||
|
||||
def current
|
||||
respond_to do |format|
|
||||
format.json { render json: {supplier: current_supplier.as_json} }
|
||||
end
|
||||
end
|
||||
|
||||
# POST /supplier/settings
|
||||
def update
|
||||
@supplier = current_supplier
|
||||
|
||||
@@ -88,6 +88,17 @@ class Supplier
|
||||
save
|
||||
end
|
||||
|
||||
def serializable_hash(*)
|
||||
{
|
||||
id: id,
|
||||
name: name
|
||||
}
|
||||
end
|
||||
|
||||
def as_json(*)
|
||||
serializable_hash
|
||||
end
|
||||
|
||||
|
||||
# Find a user by its confirmation token and try to confirm it.
|
||||
# If no user is found, returns a new user with an error.
|
||||
|
||||
@@ -71,7 +71,7 @@ html lang="en"
|
||||
.row= yield :row
|
||||
.row
|
||||
.span12
|
||||
#app
|
||||
#ember-app-container
|
||||
script#alert-template[type="text/html"]= mustache_template 'supplier/alert'
|
||||
= yield :footer
|
||||
javascript:
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
- 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')
|
||||
- content_for :footer do
|
||||
javascript:
|
||||
$(function(){
|
||||
|
||||
Reference in New Issue
Block a user