progress
This commit is contained in:
@@ -3,5 +3,4 @@ App.ListIndexEntryComponent = Ember.Component.extend
|
||||
classNames: ['lists-overview-entry']
|
||||
classNameBindings: ['content.active:active']
|
||||
click: ->
|
||||
debugger
|
||||
@get('controller').transitionToRoute 'list', @get('list')
|
||||
@get('targetObject').transitionToRoute 'list', @get('list')
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
App.ListsIndexController = Ember.Controller.extend App.PaginationModule,
|
||||
App.ListsIndexController = Ember.Controller.extend #App.PaginationModule,
|
||||
lists: (->@get('model').sortBy('created_at').reverse()).property('model.[]')
|
||||
|
||||
@@ -19,3 +19,4 @@ App.TableController = Ember.Controller.extend
|
||||
Ember.$.post("#{$data_host}/user/join_occupied_table.json", table_id: @get('model.id'))
|
||||
@set 'globals.join_request_sent', true # keeps the button deactivated
|
||||
#setupProductOrders: (-> @set('unordered_product_orders', @store.peekAll('product_order'))).on('init')
|
||||
#openDebugger: Ember.computed 'model.id', (-> debugger; true)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#= require handlebars
|
||||
#= require ember
|
||||
#= require ember-data
|
||||
#= require active-model-adapter
|
||||
# require active-model-adapter
|
||||
#= require_directory ./modifications
|
||||
#= require ./app
|
||||
#= require shared-ember-helpers/all
|
||||
|
||||
@@ -6,9 +6,11 @@ App.Product = DS.Model.extend
|
||||
position: attr('number', defaultValue: 0)
|
||||
active: attr 'boolean', defaultValue: true
|
||||
image: attr()
|
||||
product_category: DS.belongsTo('product-category')
|
||||
product_orders: DS.hasMany('product-order')
|
||||
product_variants: DS.hasMany 'product-variant'
|
||||
|
||||
product_category: DS.belongsTo('product-category', async: false)
|
||||
product_orders: DS.hasMany('product-order', async: false)
|
||||
product_variants: DS.hasMany 'product-variant', async: false
|
||||
|
||||
sorted_product_variants: Ember.computed 'product_variants.@each.name', 'product_variants.@each.position', ->
|
||||
@get('product_variants').sortBy('position')
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
attr = DS.attr
|
||||
App.ProductCategory = DS.Model.extend
|
||||
name: attr('string')
|
||||
products: DS.hasMany('product')
|
||||
supplier: DS.belongsTo('supplier')
|
||||
active_on_sunday: attr('boolean', defaultValue: true)
|
||||
active_on_monday: attr('boolean', defaultValue: true)
|
||||
active_on_tuesday: attr('boolean', defaultValue: true)
|
||||
@@ -13,7 +11,10 @@ App.ProductCategory = DS.Model.extend
|
||||
full_day: attr 'boolean', defaultValue: true
|
||||
start_from: attr('number')
|
||||
end_on: attr('number')
|
||||
position: attr('number')
|
||||
position: attr('number', defaultValue: 0)
|
||||
collapsed: attr('boolean', defaultValue: false)
|
||||
|
||||
products: DS.hasMany('product', async: false)
|
||||
supplier: DS.belongsTo('supplier', async: false)
|
||||
|
||||
sorted_products: (-> @get('products').sortBy('position') ).property('products.@each.position')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
DS.Model.reopen
|
||||
#created_at: DS.attr('date')
|
||||
#updated_at: DS.attr('date')
|
||||
created_at: DS.attr('date')
|
||||
updated_at: DS.attr('date')
|
||||
eraseRecord: ->
|
||||
#@clearRelationships()
|
||||
@transitionTo('deleted.saved')
|
||||
|
||||
@@ -9,5 +9,3 @@ App.ActiveListRoute = Ember.Route.extend App.ResetScroll
|
||||
#@transitionTo 'table', table_id
|
||||
#else
|
||||
#controller.redirect_to 'index', message: 'the_list_has_been_closed'
|
||||
#setupController: (controller, model)->
|
||||
#debugger
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
App.ListRoute = Ember.Route.extend App.ResetScroll,
|
||||
model: (options)->
|
||||
@store.findRecord 'list', options.list_id
|
||||
afterModel: (model)->
|
||||
model.reload() unless model.is_extended_version()
|
||||
#afterModel: (model)->
|
||||
# model.reload() unless model.is_extended_version()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
App.ListsRoute = Ember.Route.extend App.ResetScroll,
|
||||
App.ListsIndexRoute = Ember.Route.extend App.ResetScroll,
|
||||
model: ->
|
||||
@store.findAll 'list'
|
||||
@store.query('list', page: 1, per_page: 2)
|
||||
setupController: (controller, model)->
|
||||
@_super(controller, model)
|
||||
controller.set('alreadyLoaded', true)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
link-to 'index' class="top-menu-logo with-list"
|
||||
= image-tag 'user/logo-small.png'
|
||||
= menu-item route="active_list"
|
||||
= menu-item route="table" route_param=globals.active_list.table.id
|
||||
= menu-item route="table" route_param=globals.active_list.table
|
||||
= menu-item-list-needs-help
|
||||
= menu-item-list-needs-payment
|
||||
else
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
span.created_at=time list.created_at
|
||||
span.price.currency= currency list.price
|
||||
span.state= list.state
|
||||
span.name= list.supplier.name
|
||||
|
||||
@@ -17,3 +17,5 @@
|
||||
.large-6.columns= new-product-orders-list table=model
|
||||
else
|
||||
.large12= menu-product-categories product_categories=model.supplier.product_categories orderProducts=false
|
||||
if openDebugger
|
||||
span Debugger active
|
||||
|
||||
@@ -5,10 +5,10 @@ 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.reject!{|l| l.id == params[:exclude_list]} if params[:exclude_list].present?
|
||||
lists.reject!{|l| l.id == current_user.active_list_id } if current_user && current_user.active_list_id.present? # see spec Loading lists and switching to the order products view works, lists loading may unlink active list orders
|
||||
#lists.reject!{|l| l.id == params[:exclude_list]} if params[:exclude_list].present?
|
||||
#lists.reject!{|l| l.id == current_user.active_list_id } if current_user && current_user.active_list_id.present? # see spec Loading lists and switching to the order products view works, lists loading may unlink active list orders
|
||||
lists.include_relation(:users, :supplier)
|
||||
render json: JSONAPI::Serializer.serialize(lists, serializer: Users::ListSerializer, include: %w[supplier users], is_collection: true, meta: {total_pages: lists.total_pages, page: lists.current_page}) #, root: :lists
|
||||
render json: JSONAPI::Serializer.serialize(lists, serializer: Users::ListSerializer, include: %w[supplier users], is_collection: true, meta: {total_pages: lists.total_count, page: lists.current_page}) #, root: :lists
|
||||
end
|
||||
|
||||
#EMBER
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Users::ListSerializer < Qwaiter::UserBaseSerializer
|
||||
class Users::ListSerializer
|
||||
include Qwaiter::UserBaseSerializer
|
||||
# user ids for facebook pictures
|
||||
#self.root = :list
|
||||
attributes :state, :needs_help, :needs_payment, :user_requests_closing,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Users::OrderSerializer < Qwaiter::UserBaseSerializer
|
||||
class Users::OrderSerializer
|
||||
include Qwaiter::UserBaseSerializer
|
||||
attributes :state #, :list_id, :section_id, :table_id #, :price
|
||||
|
||||
has_many :product_orders, serializer: Users::ProductOrderSerializer
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Users::ProductCategorySerializer < Qwaiter::UserBaseSerializer
|
||||
class Users::ProductCategorySerializer
|
||||
include Qwaiter::UserBaseSerializer
|
||||
attributes :name, :supplier_id, :active_on_sunday, :active_on_monday, :active_on_tuesday, :active_on_wednesday,
|
||||
:active_on_thursday, :active_on_friday, :active_on_saturday, :full_day, :start_from, :end_on,
|
||||
:position
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Used for user ember1
|
||||
class Users::ProductOrderSerializer < Qwaiter::UserBaseSerializer
|
||||
class Users::ProductOrderSerializer
|
||||
include Qwaiter::UserBaseSerializer
|
||||
attributes :quantity, :price, :product_name, :product_variant
|
||||
# belongs_to :product #DO NOT USE THIS, THIS IS NOT NEEDED
|
||||
has_one :order, serializer: Users::OrderSerializer
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Users::ProductSerializer < Qwaiter::UserBaseSerializer
|
||||
class Users::ProductSerializer
|
||||
include Qwaiter::UserBaseSerializer
|
||||
attributes :name, :price, :description, :image, :code, :position, :visible, :active, :product_category_id
|
||||
|
||||
has_many :product_variants, serializer: Users::ProductVariantSerializer
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
class Users::ProductVariantSerializer < Qwaiter::UserBaseSerializer
|
||||
class Users::ProductVariantSerializer
|
||||
include Qwaiter::UserBaseSerializer
|
||||
attributes :name
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Users::SupplierSerializer < Qwaiter::UserBaseSerializer
|
||||
#self.root = :supplier
|
||||
class Users::SupplierSerializer
|
||||
include Qwaiter::UserBaseSerializer
|
||||
attributes :open, :name
|
||||
has_many :product_categories, serializer: Users::ProductCategorySerializer
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Users::TableSerializer < Qwaiter::UserBaseSerializer
|
||||
#self.root = :table
|
||||
class Users::TableSerializer
|
||||
include Qwaiter::UserBaseSerializer
|
||||
attributes :number, :width, :height, :position_x, :position_y, :section_id, :occupied #, :supplier_id #, :alist_id
|
||||
has_one :supplier, serializer: Users::SupplierSerializer
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Users::UserSerializer < Qwaiter::UserBaseSerializer
|
||||
#self.root = :user
|
||||
class Users::UserSerializer
|
||||
include Qwaiter::UserBaseSerializer
|
||||
attributes :email, :provider, :uid, :name, :avatar
|
||||
|
||||
def name
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
class Qwaiter::UserBaseSerializer
|
||||
module Qwaiter::UserBaseSerializer
|
||||
extend ActiveSupport::Concern
|
||||
include JSONAPI::Serializer
|
||||
class_attribute :related_link_for
|
||||
|
||||
def self.related_link_for(*attributes)
|
||||
self.related_link_for = attributes
|
||||
included do
|
||||
class_attribute :related_link_for_attributes
|
||||
attribute :created_at
|
||||
attribute :updated_at
|
||||
end
|
||||
|
||||
def base_url
|
||||
@@ -22,15 +23,22 @@ class Qwaiter::UserBaseSerializer
|
||||
|
||||
#alias_method :default_relationship_related_link, :relationship_related_link
|
||||
def relationship_related_link(attribute_name)
|
||||
super if related_link_for.include?(attribute_name)
|
||||
#super if related_link_for_attributes.include?(attribute_name)
|
||||
super
|
||||
end
|
||||
|
||||
def relationship_self_link(attribute_name)
|
||||
end
|
||||
|
||||
def self.attributes(*attrs)
|
||||
module ClassMethods
|
||||
def attributes(*attrs)
|
||||
attrs.each do |attr|
|
||||
attribute attr
|
||||
end
|
||||
end
|
||||
|
||||
def related_link_for(*attributes)
|
||||
self.related_link_for_attributes = attributes
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user