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