supplier updates mostly
This commit is contained in:
@@ -1,13 +1,4 @@
|
||||
/*
|
||||
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
||||
* listed below.
|
||||
*
|
||||
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
||||
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
||||
*
|
||||
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
||||
* compiled file, but it's generally better to create a new file per style scope.
|
||||
*
|
||||
*= require_self
|
||||
*= require_directory .
|
||||
*/
|
||||
|
||||
@@ -43,3 +43,7 @@ body
|
||||
margin-bottom: 30px
|
||||
float: left
|
||||
margin-right: 30px
|
||||
.supplier-is-closed
|
||||
.alert
|
||||
form
|
||||
margin: 0
|
||||
|
||||
@@ -1,9 +1,34 @@
|
||||
class SupplierController < ApplicationController
|
||||
before_filter :authenticate_supplier!
|
||||
layout 'tablet'
|
||||
|
||||
def home
|
||||
render layout: 'tablet'
|
||||
end
|
||||
|
||||
# GET /supplier/settings
|
||||
def edit
|
||||
@supplier = current_supplier
|
||||
end
|
||||
|
||||
# POST /supplier/settings
|
||||
def update
|
||||
@supplier = current_supplier
|
||||
if current_supplier.update_attributes(params[:supplier])
|
||||
redirect_to supplier_root_path
|
||||
else
|
||||
render action: :edit
|
||||
end
|
||||
end
|
||||
|
||||
def mark_as_open
|
||||
current_supplier.mark_as_open!
|
||||
redirect_to :back
|
||||
end
|
||||
def mark_as_closed
|
||||
current_supplier.mark_as_closed!
|
||||
redirect_to :back
|
||||
end
|
||||
# GET /suppliers/1/active_orders
|
||||
# GET /suppliers/1/active_orders.json
|
||||
def active_orders
|
||||
|
||||
@@ -31,6 +31,8 @@ class UserController < ApplicationController
|
||||
@table = Table.find(params[:table_id])
|
||||
res = {}
|
||||
res[:ocupied] = @table.occupied?
|
||||
res[:reserved] = @table.reserved?
|
||||
res[:supplier_closed] = @table.supplier.closed?
|
||||
if list.present?
|
||||
res[:other_supplier] = true if list.supplier_id != @table.supplier_id
|
||||
res[:current_table_id] = list.table_id
|
||||
|
||||
@@ -4,6 +4,14 @@ class Supplier
|
||||
devise :database_authenticatable, :recoverable, :rememberable, :trackable
|
||||
|
||||
property :name
|
||||
property :open, type: :boolean, default: false
|
||||
|
||||
#WIFI
|
||||
property :offer_wifi
|
||||
property :wifi_ssid
|
||||
property :wifi_type
|
||||
property :wifi_password
|
||||
|
||||
#has_many :orders, through: :lists
|
||||
has_many :products, dependent: :destroy
|
||||
has_many :product_categories, dependent: :destroy
|
||||
@@ -38,6 +46,22 @@ class Supplier
|
||||
tables.reject{|t| t.section_id.present? }
|
||||
end
|
||||
|
||||
def open?
|
||||
open
|
||||
end
|
||||
def closed?
|
||||
!open?
|
||||
end
|
||||
|
||||
def mark_as_open!
|
||||
self.open = true
|
||||
save
|
||||
end
|
||||
def mark_as_closed!
|
||||
self.open = false
|
||||
save
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def add_section_on_create
|
||||
|
||||
@@ -27,6 +27,10 @@ class Table
|
||||
@is_occupied = !self.class.database.view(self.class.active_lists(key: id, reduce: true)).zero?
|
||||
end
|
||||
|
||||
def reserved?
|
||||
false
|
||||
end
|
||||
|
||||
def name
|
||||
number
|
||||
end
|
||||
|
||||
@@ -40,6 +40,11 @@ html lang="en"
|
||||
= current_supplier.email
|
||||
b.caret
|
||||
ul.dropdown-menu
|
||||
- if current_supplier.open?
|
||||
li
|
||||
= form_tag supplier_mark_as_closed_path do
|
||||
= submit_tag t('supplier.close'), class: [:btn, 'btn-danger'], onClick: %|$(this).parents('form').submit()|
|
||||
li= link_to 'Settings', supplier_settings_path
|
||||
li= link_to 'Logout', destroy_supplier_session_path, method: :delete
|
||||
.container.nav-collapse
|
||||
|
||||
@@ -53,6 +58,14 @@ html lang="en"
|
||||
.alert.alert-success
|
||||
a.close data-dismiss="alert" ×
|
||||
div= flash[:notice]
|
||||
- if current_supplier.closed?
|
||||
.row.supplier-is-closed
|
||||
.span12
|
||||
.alert.alert-block
|
||||
button.close{data-dismiss="alert"} x
|
||||
p = t('supplier.you_are_currently_closed_alert')
|
||||
= form_tag supplier_mark_as_open_path do
|
||||
= submit_tag t('supplier.mark_as_open_button'), class: [:btn, 'btn-primary']
|
||||
.row
|
||||
.span12
|
||||
= content_for?(:content) ? yield(:content) : yield
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
= form_for @supplier, url: supplier_update_settings_path, html: {class: 'form-horizontal'} do |f|
|
||||
= render 'error_messages', target: current_supplier
|
||||
.control-group class=(@supplier.errors[:name].any? ? 'error' : nil)
|
||||
= f.label :name, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :name, class: 'text_field'
|
||||
.control-group class=(@supplier.errors[:email].any? ? 'error' : nil)
|
||||
= f.label :email, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :email, class: 'text_field'
|
||||
.control-group class=(@supplier.errors[:offer_wifi].any? ? 'error' : nil)
|
||||
= f.label :offer_wifi, class: 'control-label'
|
||||
.controls
|
||||
= f.check_box :offer_wifi, class: 'checkbox'
|
||||
.control-group class=(@supplier.errors[:wifi_ssid].any? ? 'error' : nil)
|
||||
= f.label :wifi_ssid, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :wifi_ssid, class: 'text_field'
|
||||
.control-group class=(@supplier.errors[:wifi_type].any? ? 'error' : nil)
|
||||
= f.label :wifi_type, class: 'control-label'
|
||||
.controls
|
||||
= f.select :wifi_type, options_for_select([['web', 'web40'], ['WPA2 Personal', 'wpa2personal']], @supplier.wifi_type)
|
||||
.control-group class=(@supplier.errors[:wifi_password].any? ? 'error' : nil)
|
||||
= f.label :wifi_password, class: 'control-label'
|
||||
.controls
|
||||
= f.text_field :wifi_password, class: 'text_field'
|
||||
|
||||
.form-actions
|
||||
= f.submit nil, class: 'btn btn-primary'
|
||||
'
|
||||
= link_to t("helpers.links.cancel"), suppliers_path, class: 'btn'
|
||||
Reference in New Issue
Block a user