User app refactor
This commit is contained in:
@@ -1,4 +1 @@
|
||||
App.ListsIndexController = Ember.ArrayController.extend App.PaginationModule,
|
||||
actions:
|
||||
showList: (list)->
|
||||
@transitionToRoute 'list', list
|
||||
App.ListsIndexController = Ember.ArrayController.extend App.PaginationModule
|
||||
|
||||
@@ -4,7 +4,6 @@ App.List = DS.Model.extend
|
||||
needs_help: attr('boolean')
|
||||
needs_payment: attr('boolean')
|
||||
user_requests_closing: attr('boolean')
|
||||
supplier_name: attr('string')
|
||||
state: attr('string')
|
||||
price: attr('number')
|
||||
closed_at: DS.attr('date')
|
||||
@@ -24,3 +23,4 @@ App.List = DS.Model.extend
|
||||
total: (->
|
||||
@get('relevant_orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
|
||||
).property('relevant_orders.@each.total')
|
||||
active: (-> @get('state') is 'active' ).property('state')
|
||||
|
||||
@@ -8,6 +8,7 @@ App.Supplier= DS.Model.extend
|
||||
|
||||
orders: DS.hasMany('order')
|
||||
product_categories: DS.hasMany('product_category')
|
||||
lists: DS.hasMany('list')
|
||||
|
||||
is_extended_version: ->
|
||||
@get('extended_version')
|
||||
@@ -16,5 +17,3 @@ App.Supplier= DS.Model.extend
|
||||
return false unless @get('open')
|
||||
true
|
||||
).property('open')
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
.row
|
||||
h2=t 'models.plural.list'
|
||||
each list in controller
|
||||
.lists-overview-entry{action "showList" list}
|
||||
span.created_at=time list.created_at
|
||||
span.price.currency= currency list.price
|
||||
span.name= list.supplier_name
|
||||
hr
|
||||
each list in controller: App.ListIndexView contentBinding='list'
|
||||
.clearfix
|
||||
if hasMore
|
||||
button{action "showMore"}=t 'lists.show_more'
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
span.created_at=time list.created_at
|
||||
span.price.currency= currency list.price
|
||||
span.name= list.supplier.name
|
||||
@@ -0,0 +1,5 @@
|
||||
App.ListIndexView = Ember.View.extend
|
||||
templateName: 'lists/list_entry'
|
||||
classNames: ['lists-overview-entry']
|
||||
classNameBindings: ['content.active:active']
|
||||
click: -> @get('controller').transitionToRoute 'list', @get('content')
|
||||
@@ -6,3 +6,4 @@ $green: #7BB459 //Heineken
|
||||
$wood: image-url('theme1/wall-bg.jpg')
|
||||
$background-brown: #57351f
|
||||
$current-color: #ff0
|
||||
$active-color: #f70
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
.lists-overview-entry
|
||||
+grid-column(12)
|
||||
cursor: pointer
|
||||
border-bottom: 1px solid #ddd
|
||||
margin-bottom: 12px
|
||||
@media #{$medium-only}
|
||||
+grid-column(6)
|
||||
@media #{$large-up}
|
||||
@@ -11,6 +13,8 @@
|
||||
float: right
|
||||
clear: right
|
||||
+panel($padding: 4px)
|
||||
&.active
|
||||
border: 1px solid $active-color
|
||||
.list-orders-container
|
||||
$padding: 6px 0 6px 35px
|
||||
border-top: 2px solid #555
|
||||
|
||||
@@ -55,8 +55,8 @@ header.top-menu
|
||||
color: $current-color
|
||||
border-color: $current-color
|
||||
&.callout
|
||||
color: #f70
|
||||
border-color: #f70
|
||||
color: $active-color
|
||||
border-color: $active-color
|
||||
@media #{$medium-only}
|
||||
margin-left: 8px
|
||||
@media #{$small-only}
|
||||
|
||||
@@ -5,7 +5,8 @@ module Users
|
||||
#lists = current_user.lists.include_relation(:supplier, :table)
|
||||
lists = List.for_user(current_user, page: params[:page], per_page: params[:per_page].presence || 25)
|
||||
#lists.include_relation(:supplier)
|
||||
lists.include_relation(:users, :orders, :supplier, :table)
|
||||
lists.reject!{|l| l.id == params[:exclude_list]} if params[:exclude_list].present?
|
||||
lists.include_relation(:users, :orders, :supplier)
|
||||
render json: lists, each_serializer: UserListSerializer, meta: {total_pages: lists.total_pages, page: lists.current_page} #, root: :lists
|
||||
end
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class UserExtendedListSerializer < Qwaiter::Serializer
|
||||
end
|
||||
has_many :orders
|
||||
#has_many :product_categories
|
||||
has_one :table, serializer: UserExtendedTableSerializer
|
||||
has_one :table, serializer: UserExtendedTableSerializer # this one add a lot of stuff
|
||||
has_many :join_requests
|
||||
has_many :users, serializer: UserUserSerializer
|
||||
#has_one :supplier # added by other resource
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class UserListSerializer < Qwaiter::Serializer
|
||||
# user ids for facebook pictures
|
||||
embed :ids
|
||||
embed :ids, include: true
|
||||
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
|
||||
@@ -9,6 +9,7 @@ class UserListSerializer < Qwaiter::Serializer
|
||||
def supplier_name
|
||||
object.supplier.name
|
||||
end
|
||||
has_many :users
|
||||
has_many :users, serializer: UserUserSerializer
|
||||
has_many :orders
|
||||
has_one :supplier, serializer: UserSupplierSerializer
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user