Poltergeist in the green, and resourceful refactor
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
class Employees::Ability
|
||||||
|
include CanCan::Ability
|
||||||
|
def initialize(employee)
|
||||||
|
can :read, Supplier
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,15 +1,7 @@
|
|||||||
class Ability
|
class Suppliers::Ability
|
||||||
attr_reader :resource
|
|
||||||
include CanCan::Ability
|
include CanCan::Ability
|
||||||
def initialize(resource)
|
def initialize(employee)
|
||||||
@resource = resource
|
if employee.manager?
|
||||||
case resource
|
|
||||||
when Employee then supplier_authorization
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def supplier_authorization
|
|
||||||
if resource.settings.manager?
|
|
||||||
can :manage, :all
|
can :manage, :all
|
||||||
#cam :mark_as_open, Supplier
|
#cam :mark_as_open, Supplier
|
||||||
else
|
else
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
Ember.Handlebars.helper 't', (path, params..., options)->
|
Ember.Handlebars.helper 't', (path, params..., options)->
|
||||||
|
toptions = options.hash
|
||||||
|
if params.length and typeof(params[0].serialize) is 'function'
|
||||||
|
$.extend toptions, params[0].serialize()
|
||||||
text = t(path, options.hash)
|
text = t(path, options.hash)
|
||||||
tag = if options.hash.bare then text else "<span data-t='#{path}' data-t-attributes='#{JSON.stringify(options.hash)}'>#{text}</span>"
|
tag = if options.hash.bare then text else "<span data-t='#{path}' data-t-attributes='#{JSON.stringify(options.hash)}'>#{text}</span>"
|
||||||
tag.htmlSafe()
|
tag.htmlSafe()
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ App.SettingsController = Ember.ObjectController.extend
|
|||||||
countries: (-> window.countries ).property()
|
countries: (-> window.countries ).property()
|
||||||
saving: false
|
saving: false
|
||||||
editIensProfile: (-> @get('model.country') is 'Netherlands' ).property('model.country')
|
editIensProfile: (-> @get('model.country') is 'Netherlands' ).property('model.country')
|
||||||
|
suppliers: (-> @store.all 'supplier').property()
|
||||||
|
other_suppliers: ( -> @get('suppliers').rejectBy 'id', @get('controllers.application.supplier.id')).property('suppliers.@each')
|
||||||
actions:
|
actions:
|
||||||
saveSettings: ->
|
saveSettings: ->
|
||||||
@set 'saving', true
|
@set 'saving', true
|
||||||
@@ -12,3 +14,5 @@ App.SettingsController = Ember.ObjectController.extend
|
|||||||
@set 'saving', false
|
@set 'saving', false
|
||||||
$('.top-menu .supplier-name').text @get('model.name')
|
$('.top-menu .supplier-name').text @get('model.name')
|
||||||
@transitionToRoute 'index'
|
@transitionToRoute 'index'
|
||||||
|
switchToSupplier: (supplier)->
|
||||||
|
window.location = Routes.switch_to_suppliers_supplier_path(supplier.get('id'))
|
||||||
|
|||||||
@@ -52,5 +52,5 @@ App.List = DS.Model.extend
|
|||||||
$.post Routes.mark_helped_suppliers_list_path(@id)
|
$.post Routes.mark_helped_suppliers_list_path(@id)
|
||||||
remove_needs_payment: ->
|
remove_needs_payment: ->
|
||||||
@set 'needs_payment', false
|
@set 'needs_payment', false
|
||||||
$.post Routes.supplier_remove_list_needs_payment_path(), list_id: @id
|
$.post Routes.remove_needs_payment_suppliers_list_path(@id)
|
||||||
sorted_orders: (-> @get('relevant_orders').sortBy('created_at').reverseObjects()).property('relevant_orders.@each.isLoaded')
|
sorted_orders: (-> @get('relevant_orders').sortBy('created_at').reverseObjects()).property('relevant_orders.@each.isLoaded')
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ App.Supplier = DS.Model.extend
|
|||||||
orders_placed_count: attr('number')
|
orders_placed_count: attr('number')
|
||||||
|
|
||||||
close: ->
|
close: ->
|
||||||
$.post Routes.supplier_mark_as_closed_path(), =>
|
$.post Routes.mark_as_closed_suppliers_supplier_path(@id), =>
|
||||||
@set 'open', false
|
@set 'open', false
|
||||||
open_the_place: ->
|
open_the_place: ->
|
||||||
$.post Routes.supplier_mark_as_open_path(), =>
|
$.post Routes.mark_as_open_suppliers_supplier_path(@id), =>
|
||||||
@set 'open', true
|
@set 'open', true
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
App.SettingsRoute = Ember.Route.extend
|
App.SettingsRoute = Ember.Route.extend
|
||||||
|
beforeModel: ->
|
||||||
|
$.getJSON(Routes.employees_suppliers_path()).then (result) =>
|
||||||
|
@store.pushPayload result
|
||||||
model: -> @container.lookup('route:application').supplier
|
model: -> @container.lookup('route:application').supplier
|
||||||
# setupController: (controller, model)->
|
# setupController: (controller, model)->
|
||||||
# #controller.set 'model', controller.get('controllers.application.supplier')
|
# #controller.set 'model', controller.get('controllers.application.supplier')
|
||||||
|
|||||||
@@ -44,3 +44,9 @@ if editIensProfile
|
|||||||
span.fa.fa-lg.fa-spinner.fa-spin
|
span.fa.fa-lg.fa-spinner.fa-spin
|
||||||
else
|
else
|
||||||
button.button.submit-supplier-settings{action 'saveSettings'}=t 'settings.save'
|
button.button.submit-supplier-settings{action 'saveSettings'}=t 'settings.save'
|
||||||
|
|
||||||
|
|
||||||
|
if other_suppliers
|
||||||
|
.row: .small-12.columns: ul.button-group.stack-for-small.round
|
||||||
|
each supplier in other_suppliers
|
||||||
|
li: a.warning.button{action "switchToSupplier" supplier}= t 'settings.switch_to_supplier' supplier
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() +
|
|||||||
window.time_zones = <%= ActiveSupport::TimeZone.all.map{|tz| {name: tz.name, formatted: "GMT#{tz.formatted_offset} #{tz.name}"}}.to_json.html_safe %>;
|
window.time_zones = <%= ActiveSupport::TimeZone.all.map{|tz| {name: tz.name, formatted: "GMT#{tz.formatted_offset} #{tz.name}"}}.to_json.html_safe %>;
|
||||||
window.countries = <%= IsoCountryCodes.all.map{|cc| {name: cc.name}}.to_json.html_safe %>;
|
window.countries = <%= IsoCountryCodes.all.map{|cc| {name: cc.name}}.to_json.html_safe %>;
|
||||||
|
|
||||||
|
|
||||||
var path_mapping = {
|
var path_mapping = {
|
||||||
user_root: '/user',
|
user_root: '/user',
|
||||||
join_occupied_table: '/user/join_occupied_table',
|
join_occupied_table: '/user/join_occupied_table',
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
@ttry = (path, vars={})->
|
@ttry = (path, vars={})->
|
||||||
@t(path, $.extend(vars, emptyWhenNotFound: true))
|
@t(path, $.extend(vars, emptyWhenNotFound: true))
|
||||||
|
|
||||||
|
|
||||||
# return translation in the form
|
# return translation in the form
|
||||||
# <span data-t="models.table">Tafel</span>
|
# <span data-t="models.table">Tafel</span>
|
||||||
@tspan = (path, vars={}) -> "<span data-t='#{path}' data-t-attributes='#{JSON.stringify(vars)}'>#{t(path, vars)}</span>"
|
@tspan = (path, vars={}) -> "<span data-t='#{path}' data-t-attributes='#{JSON.stringify(vars)}'>#{t(path, vars)}</span>"
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ Ember.Application.initializer
|
|||||||
@App = Ember.Application.create
|
@App = Ember.Application.create
|
||||||
LOG_TRANSITIONS: true
|
LOG_TRANSITIONS: true
|
||||||
rootElement: '#ember-app-container'
|
rootElement: '#ember-app-container'
|
||||||
|
ready: -> window.ember_ready = true
|
||||||
|
|
||||||
App.deferReadiness()
|
App.deferReadiness()
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
|
include ControllerAfterAuthenticationHooks
|
||||||
before_action :set_locale
|
before_action :set_locale
|
||||||
if Rails.env.development?
|
if Rails.env.development?
|
||||||
before_action :force_reloads
|
before_action :force_reloads
|
||||||
@@ -14,6 +15,7 @@ class ApplicationController < ActionController::Base
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
||||||
def allow_all_origins
|
def allow_all_origins
|
||||||
headers['Access-Control-Allow-Origin'] = '*'
|
headers['Access-Control-Allow-Origin'] = '*'
|
||||||
headers['Access-Control-Request-Method'] = '*'
|
headers['Access-Control-Request-Method'] = '*'
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
module ControllerAfterAuthenticationHooks
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
class_attribute :after_authentication_hooks
|
||||||
|
end
|
||||||
|
|
||||||
|
def run_after_authentication_hooks!
|
||||||
|
Array.wrap(after_authentication_hooks).each do |hook|
|
||||||
|
next if hook[:options][:only].present? && !Array.wrap(hook[:options][:only]).include?(action_name.to_sym)
|
||||||
|
instance_eval &hook[:block]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
module ClassMethods
|
||||||
|
def after_authentication(options, &blk)
|
||||||
|
self.after_authentication_hooks ||= []
|
||||||
|
after_authentication_hooks << {options: options, block: blk}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
module Employees
|
||||||
|
class ApplicationController < ::ApplicationController
|
||||||
|
before_action :setup_employee!
|
||||||
|
load_and_authorize_resource
|
||||||
|
def setup_employee!
|
||||||
|
authenticate_employee!
|
||||||
|
@current_ability = Employees::Ability.new( current_employee )
|
||||||
|
run_after_authentication_hooks!
|
||||||
|
end
|
||||||
|
rescue_from CanCan::AccessDenied do |exception|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to root_path, alert: 'Action forbidden'}
|
||||||
|
format.json { render json: {}, status: :forbidden }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
module Employees
|
||||||
|
class SuppliersController < Employees::ApplicationController
|
||||||
|
def index
|
||||||
|
@suppliers = current_employee.suppliers
|
||||||
|
render json: @suppliers, each_serializer: Employees::SupplierSerializer
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,46 +1,7 @@
|
|||||||
class SupplierController < Suppliers::ApplicationController
|
class SupplierController < Suppliers::ApplicationController
|
||||||
def home
|
def home
|
||||||
end
|
end
|
||||||
|
=begin
|
||||||
def menu
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /supplier/settings
|
|
||||||
def edit
|
|
||||||
@supplier = current_supplier
|
|
||||||
end
|
|
||||||
|
|
||||||
def current
|
|
||||||
[current_supplier].include_relations(sections: :tables, product_categories: :products)
|
|
||||||
render json: Suppliers::SupplierSerializer.new(current_supplier).as_json
|
|
||||||
end
|
|
||||||
|
|
||||||
# POST /supplier/settings
|
|
||||||
def update
|
|
||||||
@supplier = current_supplier
|
|
||||||
respond_to do |format|
|
|
||||||
format.html do
|
|
||||||
if current_supplier.update_attributes(supplier_params)
|
|
||||||
redirect_to supplier_root_path
|
|
||||||
else
|
|
||||||
render action: :edit
|
|
||||||
end
|
|
||||||
end
|
|
||||||
format.json do
|
|
||||||
current_supplier.update_attributes(supplier_params)
|
|
||||||
render json: Suppliers::SupplierSerializer.new(current_supplier).as_json
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def mark_as_open
|
|
||||||
current_supplier.mark_as_open!
|
|
||||||
head :ok
|
|
||||||
end
|
|
||||||
def mark_as_closed
|
|
||||||
current_supplier.mark_as_closed!
|
|
||||||
head :ok
|
|
||||||
end
|
|
||||||
# GET /suppliers/1/active_orders
|
# GET /suppliers/1/active_orders
|
||||||
# GET /suppliers/1/active_orders.json
|
# GET /suppliers/1/active_orders.json
|
||||||
def active_orders
|
def active_orders
|
||||||
@@ -95,38 +56,5 @@ class SupplierController < Suppliers::ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
#POST /supplier/remove_list_needs_payment
|
#POST /supplier/remove_list_needs_payment
|
||||||
def remove_list_needs_payment
|
=end
|
||||||
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:list_id])
|
|
||||||
@list.remove_needs_payment!
|
|
||||||
render nothing: true
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def supplier_params
|
|
||||||
params.require(:supplier).permit(
|
|
||||||
:name,
|
|
||||||
:email,
|
|
||||||
:open,
|
|
||||||
:time_zone,
|
|
||||||
:night_offset,
|
|
||||||
:location,
|
|
||||||
:lat,
|
|
||||||
:lng,
|
|
||||||
:offer_wifi,
|
|
||||||
:wifi_ssid,
|
|
||||||
:wifi_type,
|
|
||||||
:wifi_password,
|
|
||||||
:iens_profile,
|
|
||||||
:address,
|
|
||||||
:house_number,
|
|
||||||
:house_number_addition,
|
|
||||||
:postal_code,
|
|
||||||
:city,
|
|
||||||
:country,
|
|
||||||
:facebook_promotion_url,
|
|
||||||
:created_at,
|
|
||||||
:updated_at
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ module Suppliers
|
|||||||
attr_reader :current_supplier
|
attr_reader :current_supplier
|
||||||
helper_method :current_supplier
|
helper_method :current_supplier
|
||||||
layout 'supplier/app'
|
layout 'supplier/app'
|
||||||
class_attribute :after_authentication_hooks
|
|
||||||
|
|
||||||
rescue_from 'RestClient::Conflict' do |e|
|
rescue_from 'RestClient::Conflict' do |e|
|
||||||
#binding.pry
|
#binding.pry
|
||||||
@@ -17,22 +16,14 @@ module Suppliers
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.after_authentication(options, &blk)
|
|
||||||
self.after_authentication_hooks ||= []
|
|
||||||
after_authentication_hooks << {options: options, block: blk}
|
|
||||||
end
|
|
||||||
|
|
||||||
def setup_employee_and_supplier!
|
def setup_employee_and_supplier!
|
||||||
authenticate_employee!
|
authenticate_employee!
|
||||||
find_current_supplier!
|
find_current_supplier!
|
||||||
return unless current_supplier.present?
|
return unless current_supplier.present?
|
||||||
current_employee.enrich_with_settings current_supplier.settings_for(current_employee)
|
current_employee.enrich_with_settings current_supplier.settings_for(current_employee)
|
||||||
raise CanCan::AccessDenied unless current_employee.active?
|
raise CanCan::AccessDenied unless current_employee.active?
|
||||||
@current_ability = ::Ability.new( current_employee )
|
@current_ability = Suppliers::Ability.new( current_employee )
|
||||||
Array.wrap(after_authentication_hooks).each do |hook|
|
run_after_authentication_hooks!
|
||||||
next if hook[:options][:only].present? && !Array.wrap(hook[:options][:only]).include?(action_name.to_sym)
|
|
||||||
instance_eval &hook[:block]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
module Suppliers
|
module Suppliers
|
||||||
class ProductsController < Suppliers::ApplicationController
|
class ProductsController < Suppliers::ApplicationController
|
||||||
layout 'tablet'
|
layout 'tablet'
|
||||||
|
after_authentication only: [:show, :edit, :update, :destroy] do
|
||||||
|
@product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
# GET /products
|
# GET /products
|
||||||
# GET /products.json
|
# GET /products.json
|
||||||
@@ -16,7 +19,6 @@ module Suppliers
|
|||||||
# GET /products/1
|
# GET /products/1
|
||||||
# GET /products/1.json
|
# GET /products/1.json
|
||||||
def show
|
def show
|
||||||
@product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # show.html.erb
|
format.html # show.html.erb
|
||||||
@@ -38,13 +40,13 @@ module Suppliers
|
|||||||
|
|
||||||
# GET /products/1/edit
|
# GET /products/1/edit
|
||||||
def edit
|
def edit
|
||||||
@product = Product.find(params[:id])
|
#@product = Product.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST /products
|
# POST /products
|
||||||
# POST /products.json
|
# POST /products.json
|
||||||
def create
|
def create
|
||||||
@product = Product.new(product_params)
|
#@product = Product.new(product_params)
|
||||||
@product.supplier = current_supplier
|
@product.supplier = current_supplier
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
@@ -61,7 +63,7 @@ module Suppliers
|
|||||||
# PUT /products/1
|
# PUT /products/1
|
||||||
# PUT /products/1.json
|
# PUT /products/1.json
|
||||||
def update
|
def update
|
||||||
@product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
#@product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @product.update_attributes(product_params)
|
if @product.update_attributes(product_params)
|
||||||
@@ -77,12 +79,12 @@ module Suppliers
|
|||||||
# DELETE /products/1
|
# DELETE /products/1
|
||||||
# DELETE /products/1.json
|
# DELETE /products/1.json
|
||||||
def destroy
|
def destroy
|
||||||
@product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
#@product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||||
@product.destroy
|
@product.destroy
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to suppliers_products_url, notice: t('action.destroy.successfull', model: Product.model_name.human) }
|
format.html { redirect_to suppliers_products_url, notice: t('action.destroy.successfull', model: Product.model_name.human) }
|
||||||
format.json { head :no_content }
|
format.json { head :ok }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
module Suppliers
|
||||||
|
class SuppliersController < Suppliers::ApplicationController
|
||||||
|
def index
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
[current_supplier].include_relations(sections: :tables, product_categories: :products)
|
||||||
|
render json: Suppliers::SupplierSerializer.new(current_supplier).as_json
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@supplier = current_supplier
|
||||||
|
current_supplier.update_attributes(supplier_params)
|
||||||
|
render json: Suppliers::SupplierSerializer.new(current_supplier).as_json
|
||||||
|
end
|
||||||
|
|
||||||
|
def switch_to
|
||||||
|
@switch_supplier = Supplier.find(params[:id])
|
||||||
|
session[:supplier_id] = params[:id] if @switch_supplier.employee_ids.include? current_employee.id
|
||||||
|
redirect_to supplier_root_path(anchor: '/settings')
|
||||||
|
end
|
||||||
|
|
||||||
|
def mark_as_open
|
||||||
|
current_supplier.mark_as_open!
|
||||||
|
head :ok
|
||||||
|
end
|
||||||
|
|
||||||
|
def mark_as_closed
|
||||||
|
current_supplier.mark_as_closed!
|
||||||
|
head :ok
|
||||||
|
end
|
||||||
|
def remove_needs_payment
|
||||||
|
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:id])
|
||||||
|
@list.remove_needs_payment!
|
||||||
|
head :ok
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def supplier_params
|
||||||
|
params.require(:supplier).permit(
|
||||||
|
:name,
|
||||||
|
:email,
|
||||||
|
:open,
|
||||||
|
:time_zone,
|
||||||
|
:night_offset,
|
||||||
|
:location,
|
||||||
|
:lat,
|
||||||
|
:lng,
|
||||||
|
:offer_wifi,
|
||||||
|
:wifi_ssid,
|
||||||
|
:wifi_type,
|
||||||
|
:wifi_password,
|
||||||
|
:iens_profile,
|
||||||
|
:address,
|
||||||
|
:house_number,
|
||||||
|
:house_number_addition,
|
||||||
|
:postal_code,
|
||||||
|
:city,
|
||||||
|
:country,
|
||||||
|
:facebook_promotion_url
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
class Employees::SupplierSerializer < Qwaiter::Serializer
|
||||||
|
self.root = :supplier
|
||||||
|
embed :ids, include: true
|
||||||
|
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
|
||||||
@@ -54,6 +54,7 @@ html lang="en"
|
|||||||
= javascript_include_tag "user/flat/application"
|
= javascript_include_tag "user/flat/application"
|
||||||
- unless Rails.env.user_app?
|
- unless Rails.env.user_app?
|
||||||
javascript:
|
javascript:
|
||||||
|
window.ember_ready = false
|
||||||
App.advanceReadiness()
|
App.advanceReadiness()
|
||||||
body
|
body
|
||||||
#ember-app-container
|
#ember-app-container
|
||||||
|
|||||||
@@ -24,13 +24,6 @@ header.top-menu
|
|||||||
aside.side-menu
|
aside.side-menu
|
||||||
ul
|
ul
|
||||||
li.title: h3 Menu
|
li.title: h3 Menu
|
||||||
- if current_supplier.open?
|
|
||||||
li
|
|
||||||
= form_tag supplier_mark_as_closed_path do
|
|
||||||
a.supplier-close-shop href="javascript:void(0)" onclick="$(this).parents('form').submit()"
|
|
||||||
span data-t="supplier.close_for_orders"
|
|
||||||
li= link_to content_tag(:span, '', data: {t: 'supplier.settings'}), supplier_settings_path, class: 'supplier-settings-link'
|
|
||||||
li= link_to content_tag(:span, '', data: {t: 'supplier.sign_out'}), destroy_employee_session_path, method: :delete, class: 'supplier-sign-out-link'
|
|
||||||
/.navbar.navbar-fixed-top.navbar-inverse
|
/.navbar.navbar-fixed-top.navbar-inverse
|
||||||
.navbar-inner
|
.navbar-inner
|
||||||
.container
|
.container
|
||||||
|
|||||||
+1
-1
@@ -73,7 +73,7 @@ namespace :deploy do
|
|||||||
end
|
end
|
||||||
|
|
||||||
after :publishing, :restart do
|
after :publishing, :restart do
|
||||||
update_remote_cache
|
deploy.update_remote_cache
|
||||||
end
|
end
|
||||||
|
|
||||||
after :restart, :clear_cache do
|
after :restart, :clear_cache do
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
ActiveModel::Serializer.setup do |config|
|
||||||
|
config.embed = :ids
|
||||||
|
config.embed_in_root = true
|
||||||
|
end
|
||||||
@@ -125,6 +125,7 @@ en:
|
|||||||
reviews:
|
reviews:
|
||||||
title: Reviews
|
title: Reviews
|
||||||
explanation: Fill in your Iens id. You can find this id in the web location of your page
|
explanation: Fill in your Iens id. You can find this id in the web location of your page
|
||||||
|
switch_to_supplier: Switch to %{name}
|
||||||
product_category:
|
product_category:
|
||||||
# week days depricated
|
# week days depricated
|
||||||
week_days:
|
week_days:
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ nl:
|
|||||||
reviews:
|
reviews:
|
||||||
title: Reviews
|
title: Reviews
|
||||||
explanation: Vul hier je iens id in. Deze kan je halen uit de url van je iens pagina
|
explanation: Vul hier je iens id in. Deze kan je halen uit de url van je iens pagina
|
||||||
|
switch_to_supplier: Switch to %{name}
|
||||||
product_category:
|
product_category:
|
||||||
week_days:
|
week_days:
|
||||||
abbreviation:
|
abbreviation:
|
||||||
|
|||||||
+23
-11
@@ -86,9 +86,9 @@ Qwaiter::Application.routes.draw do
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
get '/supplier/suppliers/current' => 'supplier#current' #ember
|
#get '/supplier/suppliers/current' => 'supplier#current' #ember
|
||||||
get '/supplier/suppliers/:id' => 'supplier#current' #ember
|
#get '/supplier/suppliers/:id' => 'supplier#current' #ember
|
||||||
put '/supplier/suppliers/:id' => 'supplier#update' #ember
|
#put '/supplier/suppliers/:id' => 'supplier#update' #ember
|
||||||
|
|
||||||
#match '/show_products' => 'dashboard#show_products', as: :user_products
|
#match '/show_products' => 'dashboard#show_products', as: :user_products
|
||||||
# GENERAL
|
# GENERAL
|
||||||
@@ -106,18 +106,25 @@ Qwaiter::Application.routes.draw do
|
|||||||
|
|
||||||
# SUPPLIER
|
# SUPPLIER
|
||||||
get '/supplier' => 'supplier#home', as: :supplier_root
|
get '/supplier' => 'supplier#home', as: :supplier_root
|
||||||
get '/supplier/active_orders' => 'supplier#active_orders', as: :supplier_active_orders
|
#get '/supplier/active_orders' => 'supplier#active_orders', as: :supplier_active_orders
|
||||||
get '/supplier/active_lists' => 'supplier#active_lists', as: :supplier_active_lists
|
#get '/supplier/active_lists' => 'supplier#active_lists', as: :supplier_active_lists
|
||||||
get '/supplier/menu' => 'supplier#menu', as: :suppliers_menu
|
#get '/supplier/menu' => 'supplier#menu', as: :suppliers_menu
|
||||||
post '/supplier/remove_list_needs_payment' => 'supplier#remove_list_needs_payment', as: :supplier_remove_list_needs_payment
|
#post '/supplier/remove_list_needs_payment' => 'supplier#remove_list_needs_payment', as: :supplier_remove_list_needs_payment
|
||||||
|
|
||||||
post '/supplier/mark_as_open' => 'supplier#mark_as_open', as: :supplier_mark_as_open
|
#post '/supplier/mark_as_open' => 'supplier#mark_as_open', as: :supplier_mark_as_open
|
||||||
post '/supplier/mark_as_closed' => 'supplier#mark_as_closed', as: :supplier_mark_as_closed
|
#post '/supplier/mark_as_closed' => 'supplier#mark_as_closed', as: :supplier_mark_as_closed
|
||||||
|
|
||||||
get '/supplier/settings' => 'supplier#edit', as: :supplier_settings
|
#get '/supplier/settings' => 'supplier#edit', as: :supplier_settings
|
||||||
match '/supplier/settings' => 'supplier#update', as: :supplier_update_settings, via: [:put, :post, :patch]
|
#match '/supplier/settings' => 'supplier#update', as: :supplier_update_settings, via: [:put, :post, :patch]
|
||||||
|
|
||||||
namespace :suppliers, path: '/supplier' do
|
namespace :suppliers, path: '/supplier' do
|
||||||
|
resources :suppliers do
|
||||||
|
member do
|
||||||
|
get :switch_to
|
||||||
|
post :mark_as_open
|
||||||
|
post :mark_as_closed
|
||||||
|
end
|
||||||
|
end
|
||||||
resources :sections do
|
resources :sections do
|
||||||
member do
|
member do
|
||||||
get :manage_tables
|
get :manage_tables
|
||||||
@@ -150,6 +157,7 @@ Qwaiter::Application.routes.draw do
|
|||||||
get :extra_info
|
get :extra_info
|
||||||
post :mark_helped
|
post :mark_helped
|
||||||
post :close
|
post :close
|
||||||
|
post :remove_needs_payment
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :product_categories do
|
resources :product_categories do
|
||||||
@@ -169,6 +177,10 @@ Qwaiter::Application.routes.draw do
|
|||||||
root to: 'sections#index'
|
root to: 'sections#index'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
namespace :employees, path: '/employee' do
|
||||||
|
resources :suppliers
|
||||||
|
end
|
||||||
|
|
||||||
#DEMO & DEVELOPMENT
|
#DEMO & DEVELOPMENT
|
||||||
get '/select_qrcode' => 'dashboard#select_qrcode'
|
get '/select_qrcode' => 'dashboard#select_qrcode'
|
||||||
get '/table_qr_image' => 'dashboard#table_qr_image', as: :table_qr_image
|
get '/table_qr_image' => 'dashboard#table_qr_image', as: :table_qr_image
|
||||||
|
|||||||
@@ -33,5 +33,19 @@ step "I open the debugger" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
step 'I reload the page' do
|
step 'I reload the page' do
|
||||||
page.driver.browser.navigate.refresh()
|
case Capybara.current_driver
|
||||||
|
when :selenium then page.driver.browser.navigate.refresh()
|
||||||
|
when :poltergeist
|
||||||
|
visit page.current_url
|
||||||
|
sleep 1
|
||||||
|
#steps = 0
|
||||||
|
#r = page.evaluate_script 'window.ember_ready'
|
||||||
|
#while !r and steps < 20
|
||||||
|
#sleep 0.1
|
||||||
|
#r = page.evaluate_script 'window.ember_ready'
|
||||||
|
#steps += 1
|
||||||
|
#end
|
||||||
|
else
|
||||||
|
visit page.current_url
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
# encoding: UTF-8
|
|
||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe SupplierController, type: :controller do
|
|
||||||
before :each do
|
|
||||||
setup_supplier_for_controller
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "GET settings" do
|
|
||||||
it 'displays the settings page' do
|
|
||||||
get :edit
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -116,7 +116,7 @@ describe Suppliers::ProductsController, type: :controller do
|
|||||||
|
|
||||||
it "deletes the product" do
|
it "deletes the product" do
|
||||||
expect{
|
expect{
|
||||||
delete :destroy, id: @product
|
delete :destroy, id: @product
|
||||||
}.to change(Product, :count).by(-1)
|
}.to change(Product, :count).by(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ describe Suppliers::ProductsController, type: :controller do
|
|||||||
it "should not be possible to delete a product of another supplier" do
|
it "should not be possible to delete a product of another supplier" do
|
||||||
product = create :product
|
product = create :product
|
||||||
expect{
|
expect{
|
||||||
delete :destroy, id: product
|
delete :destroy, id: product.id
|
||||||
}.to_not change(Product, :count)
|
}.to_not change(Product, :count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,26 +6,5 @@ describe SupplierController, type: :routing do
|
|||||||
it "routes root to #home" do
|
it "routes root to #home" do
|
||||||
get("/supplier").should route_to("supplier#home")
|
get("/supplier").should route_to("supplier#home")
|
||||||
end
|
end
|
||||||
it "routes to #active_orders" do
|
|
||||||
get("/supplier/active_orders").should route_to("supplier#active_orders")
|
|
||||||
end
|
|
||||||
it "routes to #active_lists" do
|
|
||||||
get("/supplier/active_lists").should route_to("supplier#active_lists")
|
|
||||||
end
|
|
||||||
it "routes to #mark_as_open" do
|
|
||||||
post("/supplier/mark_as_open").should route_to("supplier#mark_as_open")
|
|
||||||
end
|
|
||||||
it "routes to #mark_as_closed" do
|
|
||||||
post("/supplier/mark_as_closed").should route_to("supplier#mark_as_closed")
|
|
||||||
end
|
|
||||||
it "routes to #settings" do
|
|
||||||
get("/supplier/settings").should route_to("supplier#edit")
|
|
||||||
end
|
|
||||||
it "routes to #update via put" do
|
|
||||||
put("/supplier/settings").should route_to("supplier#update")
|
|
||||||
end
|
|
||||||
it "routes to #update via post" do
|
|
||||||
post("/supplier/settings").should route_to("supplier#update")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user