Waiter app progress

This commit is contained in:
2015-03-24 18:40:55 +01:00
parent 90a2a2087b
commit 792a31edfd
11 changed files with 72 additions and 22 deletions
@@ -0,0 +1,7 @@
attr = DS.attr
App.Employee= DS.Model.extend
name: attr 'string'
email: attr 'string'
manager: attr 'boolean', defaultValue: false
active: attr 'boolean', defaultValue: true
color: attr 'string', defaultValue: '#3a87ad'
@@ -0,0 +1,28 @@
attr = DS.attr
App.Supplier = DS.Model.extend
name: attr 'string'
email: attr 'string'
time_zone: attr 'string'
address: attr 'string'
house_number: attr 'number'
house_number_addition: attr 'string'
postal_code: attr 'string'
city: attr 'string'
open: attr 'boolean'
country: attr 'string'
facebook_promotion_url: attr 'string'
iens_profile: attr 'string'
lat: attr 'number'
lng: attr 'number'
week_starts_on_monday: attr 'boolean'
product_categories: DS.hasMany 'product_category'
orders_in_process_count: attr('number')
orders_placed_count: attr('number')
close: ->
$.post Routes.mark_as_closed_suppliers_supplier_path(@id), =>
@set 'open', false
open_the_place: ->
$.post Routes.mark_as_open_suppliers_supplier_path(@id), =>
@set 'open', true
@@ -1,3 +1,10 @@
App.ApplicationRoute = Ember.Route.extend
setupController: ->
beforeModel: ->
@supplier = @store.push 'supplier', supplier_object
@employee = @store.push 'employee', employee_object
@supplier.reload().then =>
#@store.find('list', state: 'active')
setupController: (controller, model)->
controller.set 'supplier', @supplier
controller.set 'employee', @employee
@controllerFor('product_categories').set 'model', @store.find('product_category')
@@ -1,5 +1,5 @@
.row
.twelve.columns
h1 Qwaiter
h1= supplier.name
hr
.waiter-application-container= outlet
@@ -0,0 +1,8 @@
class Waiter::SectionsController < Waiter::ApplicationController
def index
sections = current_supplier.sections.include_relation(:tables)
render json: sections, each_serializer: Waiter::SectionSerializer
end
end
@@ -0,0 +1,7 @@
class Waiter::SuppliersController < Waiter::ApplicationController
def show
@supplier = Supplier.find(params[:id])
head 404 and return unless @supplier.employee_ids.include?(current_employee.id)
render json: @supplier, serializer: Waiter::SupplierSerializer
end
end
-16
View File
@@ -4,14 +4,6 @@ class WaiterController < ApplicationController
end
def sections
sections = current_supplier.sections.include_relation(:tables)
respond_to do |format|
format.html { redirect_to '/waiter'}
format.json { render json: sections, each_serializer: Waiter::SectionSerializer }
end
end
def product_categories
respond_to do |format|
format.html { redirect_to '/waiter'}
@@ -25,12 +17,4 @@ class WaiterController < ApplicationController
@list.place_order products: params[:order], employee: current_employee
render nothing: true
end
def current_supplier
@current_supplier ||= Supplier.first
end
def current_employee
@current_employee ||= current_supplier.employees.first
end
end
+2 -1
View File
@@ -1,4 +1,5 @@
class Waiter::SectionSerializer < Qwaiter::Serializer
self.root = :section
root 'section'
attributes :title, :path, :width, :height
has_many :tables, serializer: Waiter::TableSerializer
end
@@ -0,0 +1,5 @@
class Waiter::SupplierSerializer < Qwaiter::Serializer
root 'supplier'
attributes :open, :name, :lat, :lng, :time_zone, :address, :house_number, :house_number_addition, :postal_code, :city, :country,
:facebook_promotion_url, :iens_profile, :week_starts_on_monday, :orders_in_process_count, :orders_placed_count
end
+1
View File
@@ -6,6 +6,7 @@ html lang="en"
meta name="viewport" content="width=device-width, initial-scale=1.0"
title= waiter_page_title
/= stylesheet_link_tag "waiter/application", media: "all"
= render 'suppliers/application/head'
= stylesheet_link_tag "waiter/application"
= javascript_include_tag "vendor/modernizr"
= javascript_include_tag "waiter/application"