diff --git a/Gemfile b/Gemfile
index c3bf5dfd..34426427 100644
--- a/Gemfile
+++ b/Gemfile
@@ -68,6 +68,9 @@ gem 'kaminari'
gem 'rqrcode'
gem 'mini_magick'
+gem 'active_attr'
+gem 'naught'
+gem 'cancancan'
#gem 'geokit'
gem 'iso_country_codes'
diff --git a/Gemfile.lock b/Gemfile.lock
index bde5f57c..c5f3a5fe 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -78,6 +78,9 @@ GEM
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
+ active_attr (0.8.5)
+ activemodel (>= 3.0.2, < 5.0)
+ activesupport (>= 3.0.2, < 5.0)
active_decorator (0.4.0)
active_model_serializers (0.9.0)
activemodel (>= 3.2)
@@ -113,6 +116,7 @@ GEM
sass (~> 3.4)
thor
builder (3.2.2)
+ cancancan (1.10.1)
capistrano (3.3.5)
capistrano-stats (~> 1.1.0)
i18n
@@ -270,6 +274,7 @@ GEM
multi_json (1.10.1)
multi_xml (0.5.5)
multipart-post (2.0.0)
+ naught (1.0.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.2)
@@ -449,9 +454,11 @@ PLATFORMS
ruby
DEPENDENCIES
+ active_attr
active_decorator
active_model_serializers (= 0.9.0)
bourbon
+ cancancan
capistrano (~> 3.0)
capistrano-local-precompile
capistrano-rails (~> 1.1)
@@ -480,6 +487,7 @@ DEPENDENCIES
launchy
letter_opener
mini_magick
+ naught
omniauth-facebook
omniauth-instagram
paperclip
diff --git a/app/assets/javascripts/supplier/app/controllers/application_controller.js.coffee b/app/assets/javascripts/supplier/app/controllers/application_controller.js.coffee
index f80058ce..8204dd7a 100644
--- a/app/assets/javascripts/supplier/app/controllers/application_controller.js.coffee
+++ b/app/assets/javascripts/supplier/app/controllers/application_controller.js.coffee
@@ -17,7 +17,7 @@ App.ApplicationController = Ember.Controller.extend
# @set 'supplier', @store.find('supplier', supplier_id)
actions:
signOut: ->
- window.location = Routes.destroy_supplier_session_path()
+ window.location = Routes.destroy_employee_session_path()
markSupplierClosed: ->
return unless supplier = @get('supplier')
supplier.close()
diff --git a/app/assets/javascripts/supplier/app/controllers/employees_index_controller.js.coffee b/app/assets/javascripts/supplier/app/controllers/employees_index_controller.js.coffee
index b4b0e3a5..7d4a74f8 100644
--- a/app/assets/javascripts/supplier/app/controllers/employees_index_controller.js.coffee
+++ b/app/assets/javascripts/supplier/app/controllers/employees_index_controller.js.coffee
@@ -1,14 +1,17 @@
App.EmployeesIndexController = Ember.ArrayController.extend
+ needs: ['application']
employees: (-> @get('model').sortBy('name')).property('model.@each.name')
actions:
newEmployee: ->
employee = @store.createRecord('employee')
@modal 'employee_edit',
model: employee
+ title_path: 'employee.modal.new_title'
close: -> employee.deleteRecord()
editEmployee: (employee)->
@modal 'employee_edit',
model: employee
+ title_path: 'employee.modal.edit_title'
close: -> employee.rollback()
destroyEmployee: (employee)->
@modal 'confirm',
diff --git a/app/assets/javascripts/supplier/app/controllers/modals/add_section_controller.js.coffee b/app/assets/javascripts/supplier/app/controllers/modals/add_section_controller.js.coffee
index 0377c18a..7240f6fd 100644
--- a/app/assets/javascripts/supplier/app/controllers/modals/add_section_controller.js.coffee
+++ b/app/assets/javascripts/supplier/app/controllers/modals/add_section_controller.js.coffee
@@ -34,3 +34,5 @@ App.modals.AddSectionController = @App.modals.BaseController.extend
@set 'section_title', ''
@send 'closeModal'
@transitionToRoute 'section', s.id
+ , @save_error.bind(@)
+
diff --git a/app/assets/javascripts/supplier/app/controllers/modals/base_controller.js.coffee b/app/assets/javascripts/supplier/app/controllers/modals/base_controller.js.coffee
index 9472580f..15d97dec 100644
--- a/app/assets/javascripts/supplier/app/controllers/modals/base_controller.js.coffee
+++ b/app/assets/javascripts/supplier/app/controllers/modals/base_controller.js.coffee
@@ -19,10 +19,21 @@
else
underscored.capitalize().replace(/_/, ' ')
).property('model.id')
+ save_error: (error)->
+ switch error.status
+ when 403
+ @set 'alert_message', 'Unauthorized action'
+ else
+ @set 'alert_message', 'Something went wrong'
+ save_success: ->
+ @set 'alert_message', ''
+ @send 'closeModal'
+
actions:
close: ->
if close = @get('modal_options.close')
close.apply(@)
+ @set 'alert_message', ''
@send 'closeModal' unless @preventClose
closeOnOverlay: ->
@send('close') if @get('modal_options.closeOnOverlay')
@@ -33,12 +44,13 @@
ok: ->
if ok = @get('modal_options.ok')
ok.apply(@)
+ @set 'alert_message', ''
@send 'closeModal' unless @preventClose
confirm: -> @send('ok')
save: ->
if @get('model.isValid')
- @get('model').save().then((=> @send 'closeModal' ), (-> true))
- #@send 'closeModal' unless @preventClose
+ @get('model').save().then @save_success.bind(@), @save_error.bind(@)
+ #@send 'closeModal' unless @preventClose
destroy: ->
@modal 'confirm',
title_path: @get('modal_options.destroy_text_path') || 'general.destroy.text'
diff --git a/app/assets/javascripts/supplier/app/controllers/tables_index_controller.js.coffee b/app/assets/javascripts/supplier/app/controllers/tables_index_controller.js.coffee
index 342a9f1e..3d9d09df 100644
--- a/app/assets/javascripts/supplier/app/controllers/tables_index_controller.js.coffee
+++ b/app/assets/javascripts/supplier/app/controllers/tables_index_controller.js.coffee
@@ -1,4 +1,5 @@
App.TablesIndexController = Ember.ArrayController.extend
+ needs: ['application']
tables: (-> @get('model').sortBy('casted_number')).property('model.@each.number')
actions:
newTable: ->
diff --git a/app/assets/javascripts/supplier/app/helpers/can.js.coffee b/app/assets/javascripts/supplier/app/helpers/can.js.coffee
new file mode 100644
index 00000000..a9864afa
--- /dev/null
+++ b/app/assets/javascripts/supplier/app/helpers/can.js.coffee
@@ -0,0 +1,5 @@
+Ember.Handlebars.registerHelper 'can', (operation, resource, options)->
+ if operation is 'manage' and @get('controllers.application.employee_settings.manager')
+ options.fn @
+ else
+ options.inverse @
diff --git a/app/assets/javascripts/supplier/app/models/employee.js.coffee b/app/assets/javascripts/supplier/app/models/employee.js.coffee
index 3fb785bb..bd8e3cdd 100644
--- a/app/assets/javascripts/supplier/app/models/employee.js.coffee
+++ b/app/assets/javascripts/supplier/app/models/employee.js.coffee
@@ -4,5 +4,5 @@ App.Employee= DS.Model.extend Ember.Validations.Mixin,
email: attr 'string'
validations:
- name:
- presence: true
+ name: {presence: true}
+ email: {format: /.+@.+\..{2,4}/}
diff --git a/app/assets/javascripts/supplier/app/models/product_category.js.coffee b/app/assets/javascripts/supplier/app/models/product_category.js.coffee
index f99d0109..c08f3246 100644
--- a/app/assets/javascripts/supplier/app/models/product_category.js.coffee
+++ b/app/assets/javascripts/supplier/app/models/product_category.js.coffee
@@ -1,5 +1,5 @@
attr = DS.attr
-App.ProductCategory = DS.Model.extend
+App.ProductCategory = DS.Model.extend Ember.Validations.Mixin,
name: attr('string')
products: DS.hasMany('product')
supplier: DS.belongsTo 'supplier'
@@ -25,3 +25,6 @@ App.ProductCategory = DS.Model.extend
unless @get('full_day')
result += "#{day_minutes_to_time @get('start_from')} - #{day_minutes_to_time @get('end_on')}"
new Ember.Handlebars.SafeString result
+
+ validations:
+ name: {presence: true}
diff --git a/app/assets/javascripts/supplier/app/models/supplier.js.coffee b/app/assets/javascripts/supplier/app/models/supplier.js.coffee
index 6d66890b..f5825765 100644
--- a/app/assets/javascripts/supplier/app/models/supplier.js.coffee
+++ b/app/assets/javascripts/supplier/app/models/supplier.js.coffee
@@ -1,7 +1,6 @@
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'
diff --git a/app/assets/javascripts/supplier/app/routes/application_route.js.coffee.erb b/app/assets/javascripts/supplier/app/routes/application_route.js.coffee.erb
index 01c319c4..56ab14c7 100644
--- a/app/assets/javascripts/supplier/app/routes/application_route.js.coffee.erb
+++ b/app/assets/javascripts/supplier/app/routes/application_route.js.coffee.erb
@@ -2,18 +2,22 @@ App.ApplicationRoute = Ember.Route.extend
beforeModel: ->
# Preload only active lists and orders
@supplier = @store.push 'supplier', supplier_object
- @product_categories = @store.find 'product_category'
- @sections = @store.find 'section'
- Ember.RSVP.all([@product_categories, @sections]).then (results)=>
- @store.find('list', state: 'active').then (lists) -> lists.invoke('get', 'table')
- @lists = @store.all 'list'
+ @employee = @store.push 'employee', employee_object
+ #@product_categories = @store.find 'product_category'
+ #@sections = @store.find 'section'
+ #Ember.RSVP.all([@product_categories, @sections]).then (results)=>
+ @supplier.reload().then =>
+ @store.find('list', state: 'active') #.then (lists) -> lists.invoke('get', 'table')
+ #@lists = @store.all 'list'
# product_categories = controller.set 'product_categories', @store.all('product_category')
#@store.find 'order', state: 'active' included in list
setupController: (controller)->
controller.set 'supplier', @supplier
+ controller.set 'employee', @employee
+ controller.set 'employee_settings', Ember.Object.create(employee_settings)
# @set 'supplier', @store.find('supplier', supplier_id)
- controller.set 'sections', @sections
- controller.set 'product_categories', @product_categories
+ #controller.set 'sections', @sections
+ #controller.set 'product_categories', @product_categories
faye = new Faye.Client(event_host)
faye.subscribe "/supplier/#{supplier_object.id}", (e)=>
diff --git a/app/assets/javascripts/supplier/app/templates/employees/index.emblem b/app/assets/javascripts/supplier/app/templates/employees/index.emblem
index ca88805f..31d1f807 100644
--- a/app/assets/javascripts/supplier/app/templates/employees/index.emblem
+++ b/app/assets/javascripts/supplier/app/templates/employees/index.emblem
@@ -15,7 +15,9 @@
= employee.email
= errors employee.errors.email
td.actions
- a.table-edit{ action 'editEmployee' employee }: span
- a.table-destroy{ action 'destroyEmployee' employee }: span
+ can manage sections
+ a.table-edit{ action 'editEmployee' employee }: span
+ a.table-destroy{ action 'destroyEmployee' employee }: span
.form-actions
- a.form-action-new.new-employee-button{action "newEmployee"}= t 'employee.new_button'
+ can manage employees
+ a.form-action-new.new-employee-button{action "newEmployee"}= t 'employee.new_button'
diff --git a/app/assets/javascripts/supplier/app/templates/form_elements/boolean_button.emblem b/app/assets/javascripts/supplier/app/templates/form_elements/boolean_button.emblem
new file mode 100644
index 00000000..154a69f2
--- /dev/null
+++ b/app/assets/javascripts/supplier/app/templates/form_elements/boolean_button.emblem
@@ -0,0 +1 @@
+span= view.text
diff --git a/app/assets/javascripts/supplier/app/templates/menu.emblem b/app/assets/javascripts/supplier/app/templates/menu.emblem
index fffe2035..900604c1 100644
--- a/app/assets/javascripts/supplier/app/templates/menu.emblem
+++ b/app/assets/javascripts/supplier/app/templates/menu.emblem
@@ -6,13 +6,16 @@
each product_category in sorted_product_categories
.row.product_category-container: .small-12.columns
.product_category-header
- a.move{action "moveProductCategory" product_category} href="#"
+ can manage menu
+ a.move{action "moveProductCategory" product_category} href="#"
span.title= product_category.name
span.availability= product_category.availability_text
- a.edit-product-category-button{action "editProductCategory" product_category} href="#"
- a.add-product-product_category-button{action "addProduct" product_category} href="#": span
+ can manage menu
+ a.edit-product-category-button{action "editProductCategory" product_category} href="#"
+ a.add-product-product_category-button{action "addProduct" product_category} href="#": span
each product in product_category.sorted_products
= menu-product product=product code_filter=product_code_filter
-.row
- .small-12.columns
- a.new-product_category-button{action "newProductCategory"} href="#" = t 'product_category.new_button'
+can manage menu
+ .row
+ .small-12.columns
+ a.new-product_category-button{action "newProductCategory"} href="#" = t 'product_category.new_button'
diff --git a/app/assets/javascripts/supplier/app/templates/modals/employee_edit.emblem b/app/assets/javascripts/supplier/app/templates/modals/employee_edit.emblem
index a4857cd9..f14d57bf 100644
--- a/app/assets/javascripts/supplier/app/templates/modals/employee_edit.emblem
+++ b/app/assets/javascripts/supplier/app/templates/modals/employee_edit.emblem
@@ -1,4 +1,4 @@
-p=t 'employee.edit.modal.body_header'
+p=t 'employee.modal.body_header'
.form-row.name
.form-label=t 'attributes.employee.name'
.form-field
@@ -7,8 +7,9 @@ p=t 'employee.edit.modal.body_header'
.form-row.name
.form-label=t 'attributes.employee.email'
.form-field
- = input type="email" valueBinding="model.email"
+ = input type="email" valueBinding="model.email" action="save"
= errors model.errors.email
hr
-button.modal-close{action "close"}=t 'section.add_employees.modal.close_button'
-button.modal-confirm.right{action "save"}=t 'section.add_employees.modal.add_button'
+button.modal-close{action "close"}=t 'employee.modal.close_button'
+button.modal-confirm.right{action "save"} disabled=model.isInvalid
+ =t 'employee.modal.save_button'
diff --git a/app/assets/javascripts/supplier/app/templates/modals/product_category_form.emblem b/app/assets/javascripts/supplier/app/templates/modals/product_category_form.emblem
index db66bad7..1cae928e 100644
--- a/app/assets/javascripts/supplier/app/templates/modals/product_category_form.emblem
+++ b/app/assets/javascripts/supplier/app/templates/modals/product_category_form.emblem
@@ -1,6 +1,6 @@
.form-row.name
.form-label.half=t 'attributes.product_category.name'
- .form-field.half= input valueBinding="model.name"
+ .form-field.half= input valueBinding="model.name" action="save"
.row
.small-12.medium-6.columns
unless model.supplier.week_starts_on_monday
diff --git a/app/assets/javascripts/supplier/app/templates/modals/product_category_new.emblem b/app/assets/javascripts/supplier/app/templates/modals/product_category_new.emblem
index 4fc63401..f8e642fe 100644
--- a/app/assets/javascripts/supplier/app/templates/modals/product_category_new.emblem
+++ b/app/assets/javascripts/supplier/app/templates/modals/product_category_new.emblem
@@ -2,4 +2,5 @@ p=t 'product_category.modal.new.body_header'
= partial "modals/product_category_form"
hr
button.modal-close{action "close"}=t 'product_category.modal.new.close_button'
-button.modal-save.right{action "save"}=t 'product_category.modal.new.save_button'
+button.modal-save.right{action "save"} disabled=model.isInvalid
+ =t 'product_category.modal.new.save_button'
diff --git a/app/assets/javascripts/supplier/app/templates/section.emblem b/app/assets/javascripts/supplier/app/templates/section.emblem
index e7160bb7..7882089d 100644
--- a/app/assets/javascripts/supplier/app/templates/section.emblem
+++ b/app/assets/javascripts/supplier/app/templates/section.emblem
@@ -2,22 +2,24 @@
= link-to 'sections' class="goto-sections-index-tab-header": span
each section in sections
= view "section-tab-header" context=section
- a.add-section{action "addSection"}: span
-.section-manage-tables.pull-right
- App.DropdownLink title="Action"
- ul
- li: a{action "addTables"}: span.section-add-tables-icon=t 'section.add_tables.button_label'
- li: a{action "arrangeTables"}: span.section-arrange-tables-icon=t 'section.arrange_tables.modal.title'
- li: a href="{{route 'qr_codes_suppliers_tables_path' section_id=id}}" target="_blank": span.qr-icon=t 'table.print_qr_codes'
- li: a.section-destroy{action "destroySection"}: span.section-remove-icon=t 'helpers.links.destroy'
- if editmode
- = input type="text" valueBinding="title" class="section-edit-title-field"
- App.NumberField valueBinding="width" class="dimension section-edit-width-field"
- span.fa.fa-lg.fa-times
- App.NumberField valueBinding="height" class="dimension section-edit-height-field"
- a.section-rollback-button{ action "rollbackEditable" }: span
- a.section-normal-mode-button{ action "finishEditable" }: span
- else
- a.section-edit-mode-button{ action "makeEditable" }: span
+ can manage sections
+ a.add-section{action "addSection"}: span
+can manage sections
+ .section-manage-tables.pull-right
+ App.DropdownLink title="Action"
+ ul
+ li: a{action "addTables"}: span.section-add-tables-icon=t 'section.add_tables.button_label'
+ li: a{action "arrangeTables"}: span.section-arrange-tables-icon=t 'section.arrange_tables.modal.title'
+ li: a href="{{route 'qr_codes_suppliers_tables_path' section_id=id}}" target="_blank": span.qr-icon=t 'table.print_qr_codes'
+ li: a.section-destroy{action "destroySection"}: span.section-remove-icon=t 'helpers.links.destroy'
+ if editmode
+ = input type="text" valueBinding="title" class="section-edit-title-field"
+ App.NumberField valueBinding="width" class="dimension section-edit-width-field"
+ span.fa.fa-lg.fa-times
+ App.NumberField valueBinding="height" class="dimension section-edit-height-field"
+ a.section-rollback-button{ action "rollbackEditable" }: span
+ a.section-normal-mode-button{ action "finishEditable" }: span
+ else
+ a.section-edit-mode-button{ action "makeEditable" }: span
= view "section-tables" contentBinding="tables"
diff --git a/app/assets/javascripts/supplier/app/templates/sections/index.emblem b/app/assets/javascripts/supplier/app/templates/sections/index.emblem
index 5a232e3f..53d9c572 100644
--- a/app/assets/javascripts/supplier/app/templates/sections/index.emblem
+++ b/app/assets/javascripts/supplier/app/templates/sections/index.emblem
@@ -36,5 +36,6 @@
else
.row: .small-12.columns
.panel=t 'section.none_found'
- .form-actions
- a.form-action-new{action "addSection"}=t 'helpers.links.new'
+ can manage sections
+ .form-actions
+ a.form-action-new{action "addSection"}=t 'helpers.links.new'
diff --git a/app/assets/javascripts/supplier/app/templates/tables/index.emblem b/app/assets/javascripts/supplier/app/templates/tables/index.emblem
index 37f3039c..803797e3 100644
--- a/app/assets/javascripts/supplier/app/templates/tables/index.emblem
+++ b/app/assets/javascripts/supplier/app/templates/tables/index.emblem
@@ -18,10 +18,12 @@
= table.section.title
/td.timestamp=time table.created_at
td.actions
- a.table-edit{ action 'editTable' table }: span
- a.table-destroy{ action 'destroyTable' table }: span
+ can manage tables
+ a.table-edit{ action 'editTable' table }: span
+ a.table-destroy{ action 'destroyTable' table }: span
.form-actions
- a.form-action-new.new-table-button{action "newTable"}= t 'table.new_button'
+ can manage tables
+ a.form-action-new.new-table-button{action "newTable"}= t 'table.new_button'
if tables
a.table-qr-codes{path qr_codes_suppliers_tables} target="_blank"
span.qr-icon
diff --git a/app/assets/javascripts/supplier/app/views/form_elements/boolean_button_view.js.coffee b/app/assets/javascripts/supplier/app/views/form_elements/boolean_button_view.js.coffee
index 52c08c78..daf9c860 100644
--- a/app/assets/javascripts/supplier/app/views/form_elements/boolean_button_view.js.coffee
+++ b/app/assets/javascripts/supplier/app/views/form_elements/boolean_button_view.js.coffee
@@ -2,7 +2,7 @@ App.BooleanButtonView = Ember.View.extend
tagName: 'a'
href: '#'
classNames: "button"
- # templateName: "form_elements/boolean_switch"
+ templateName: "form_elements/boolean_button"
#template: Ember.Handlebars.compile "{{view.text}}"
classNameBindings: ['rounded:round', 'active:active:disabled']
diff --git a/app/assets/javascripts/supplier/app/views/modal_view.js.coffee b/app/assets/javascripts/supplier/app/views/modal_view.js.coffee
index ad3745f0..9e3c8717 100644
--- a/app/assets/javascripts/supplier/app/views/modal_view.js.coffee
+++ b/app/assets/javascripts/supplier/app/views/modal_view.js.coffee
@@ -1,6 +1,7 @@
App.ModalView = Ember.View.extend
layoutName: 'modals/layout'
didInsertElement: ->
+ @$('input:first').focus()
sortable = $('.sortable')
controller = @get('controller')
if sortable.length
diff --git a/app/assets/javascripts/supplier/foundation1/application.js.erb b/app/assets/javascripts/supplier/foundation1/application.js.erb
index b02f041e..80005ed4 100644
--- a/app/assets/javascripts/supplier/foundation1/application.js.erb
+++ b/app/assets/javascripts/supplier/foundation1/application.js.erb
@@ -24,6 +24,7 @@ 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.countries = <%= IsoCountryCodes.all.map{|cc| {name: cc.name}}.to_json.html_safe %>;
+
var path_mapping = {
user_root: '/user',
join_occupied_table: '/user/join_occupied_table',
diff --git a/app/assets/stylesheets/supplier/foundation1/components/_forms.css.sass b/app/assets/stylesheets/supplier/foundation1/components/_forms.css.sass
index f08f6325..c2aa0f25 100644
--- a/app/assets/stylesheets/supplier/foundation1/components/_forms.css.sass
+++ b/app/assets/stylesheets/supplier/foundation1/components/_forms.css.sass
@@ -25,8 +25,10 @@
+grid-column($columns: 9, $last-column:true)
&.half
+grid-column(6)
- .error, .error-message
+ .error
color: $alert-color
+ .error-message
+ color: $alert-color
&.form-actions
padding-top: 12px
body
diff --git a/app/assets/stylesheets/theme1/elements/_forms.css.sass b/app/assets/stylesheets/theme1/elements/_forms.css.sass
index 74097201..cc31a12f 100644
--- a/app/assets/stylesheets/theme1/elements/_forms.css.sass
+++ b/app/assets/stylesheets/theme1/elements/_forms.css.sass
@@ -17,6 +17,8 @@
&.full
@media #{$large-up}
+grid-column($columns: 9, $last-column:true)
+ .error-message
+ color: $alert-color
&.form-actions
padding-top: 12px
diff --git a/app/controllers/admin/employees_controller.rb b/app/controllers/admin/employees_controller.rb
new file mode 100644
index 00000000..0f2136b0
--- /dev/null
+++ b/app/controllers/admin/employees_controller.rb
@@ -0,0 +1,106 @@
+module Admin
+ class EmployeesController < Admin::ApplicationController
+ before_filter :set_relation_options, only: [:new, :edit, :create, :update]
+ skip_before_filter :authenticate_administrator!, only: :test_login
+ skip_before_filter :set_locale, only: :test_login
+ # GET /employees
+ # GET /employees.json
+ def index
+ @employees = Employee.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @employees }
+ end
+ end
+
+ def test_login
+ if Rails.env.test? and employee = Employee.find_by_email(params[:email])
+ sign_in employee
+ end
+ render nothing: true
+ end
+
+ # GET /employees/1
+ # GET /employees/1.json
+ def show
+ @employee = Employee.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @employee }
+ end
+ end
+
+ # GET /employees/new
+ # GET /employees/new.json
+ def new
+ @employee = Employee.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @employee }
+ end
+ end
+
+ # GET /employees/1/edit
+ def edit
+ @employee = Employee.find(params[:id])
+ end
+
+ # POST /employees
+ # POST /employees.json
+ def create
+ @employee = Employee.new(employee_params)
+
+ respond_to do |format|
+ if @employee.save
+ format.html { redirect_to [:admin, @employee], notice: t('action.create.successfull', model: Employee.model_name.human) }
+ format.json { render json: @employee, status: :created, location: @employee }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @employee.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /employees/1
+ # PUT /employees/1.json
+ def update
+ @employee = Employee.find(params[:id])
+
+ respond_to do |format|
+ if @employee.update_attributes(employee_params)
+ format.html { redirect_to [:admin, @employee], notice: t('action.update.successfull', model: Employee.model_name.human) }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @employee.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /employees/1
+ # DELETE /employees/1.json
+ def destroy
+ @employee = Employee.find(params[:id])
+ @employee.destroy
+
+ respond_to do |format|
+ format.html { redirect_to admin_employees_path, notice: t('action.destroy.successfull', model: Employee.model_name.human) }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+
+ def set_relation_options
+ @employees = Employee.all
+ @lists = List.all
+ end
+
+ def employee_params
+ params.require(:employee).permit!
+ end
+ end
+end
diff --git a/app/controllers/admin/suppliers_controller.rb b/app/controllers/admin/suppliers_controller.rb
index d30fde48..954bcb5c 100644
--- a/app/controllers/admin/suppliers_controller.rb
+++ b/app/controllers/admin/suppliers_controller.rb
@@ -2,7 +2,6 @@ module Admin
class SuppliersController < Admin::ApplicationController
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
skip_before_filter :authenticate_administrator!, only: :test_login
- skip_before_filter :set_locale, only: :test_login
# GET /suppliers
# GET /suppliers.json
def index
@@ -14,13 +13,6 @@ module Admin
end
end
- def test_login
- if Rails.env.test? and supplier = Supplier.find_by_email(params[:email])
- sign_in supplier
- end
- render nothing: true
- end
-
# GET /suppliers/1
# GET /suppliers/1.json
def show
diff --git a/app/controllers/new_suppliers_controller.rb b/app/controllers/new_suppliers_controller.rb
new file mode 100644
index 00000000..04e4eba9
--- /dev/null
+++ b/app/controllers/new_suppliers_controller.rb
@@ -0,0 +1,22 @@
+class NewSuppliersController < ApplicationController
+ def index
+ new
+ render 'new'
+ end
+
+ def new
+ @new_supplier = NewSupplier.new
+ @new_supplier.current_employee = current_employee
+ end
+
+ def create
+ @new_supplier = NewSupplier.new(params[:new_supplier])
+ @new_supplier.current_employee = current_employee
+
+ if @new_supplier.save
+ redirect_to supplier_root_path
+ else
+ render 'new'
+ end
+ end
+end
diff --git a/app/controllers/supplier_controller.rb b/app/controllers/supplier_controller.rb
index 62bdc205..8a5d3d6d 100644
--- a/app/controllers/supplier_controller.rb
+++ b/app/controllers/supplier_controller.rb
@@ -1,5 +1,5 @@
-class SupplierController < ApplicationController
- before_filter :authenticate_supplier!
+class SupplierController < Suppliers::ApplicationController
+ before_filter :setup_employee_and_supplier!
layout 'supplier/app'
def home
@@ -14,7 +14,8 @@ class SupplierController < ApplicationController
end
def current
- render json: SupplierSupplierSerializer.new(current_supplier).as_json
+ [current_supplier].include_relations(sections: :tables, product_categories: :products)
+ render json: Suppliers::SupplierSerializer.new(current_supplier).as_json
end
# POST /supplier/settings
@@ -30,7 +31,7 @@ class SupplierController < ApplicationController
end
format.json do
current_supplier.update_attributes(supplier_params)
- render json: SupplierSupplierSerializer.new(current_supplier).as_json
+ render json: Suppliers::SupplierSerializer.new(current_supplier).as_json
end
end
end
diff --git a/app/controllers/suppliers/application_controller.rb b/app/controllers/suppliers/application_controller.rb
index daa78f1c..7c9a9e4e 100644
--- a/app/controllers/suppliers/application_controller.rb
+++ b/app/controllers/suppliers/application_controller.rb
@@ -1,11 +1,40 @@
module Suppliers
class ApplicationController < ::ApplicationController
- before_filter :authenticate_supplier!
+ before_action :setup_employee_and_supplier!
+ load_and_authorize_resource
+ attr_reader :current_supplier, :employee_settings
+ helper_method :current_supplier, :employee_settings
layout 'supplier/app'
rescue_from 'RestClient::Conflict' do |e|
#binding.pry
end
+ rescue_from CanCan::AccessDenied do |exception|
+ render json: {}, status: :forbidden
+ end
+ def setup_employee_and_supplier!
+ authenticate_employee!
+ find_current_supplier!
+ return unless current_supplier.present?
+ @employee_settings = current_supplier.employee_settings.for_employee( current_employee )
+ @current_ability = ::Ability.new(@employee_settings)
+ end
+
+
+ def find_current_supplier!
+ return current_supplier if current_supplier.present?
+ if session[:supplier_id]
+ supplier = Supplier.find(session[:supplier_id])
+ if supplier.employee_ids.include?(current_employee.id)
+ @current_supplier = supplier
+ else
+ render nothing: true, status: :unauthorized
+ end
+ else
+ @current_supplier = current_employee.suppliers.first
+ session[:supplier_id] = @current_supplier.try(:id)
+ end
+ end
end
end
diff --git a/app/controllers/suppliers/employees_controller.rb b/app/controllers/suppliers/employees_controller.rb
index 43fa287a..21848b51 100644
--- a/app/controllers/suppliers/employees_controller.rb
+++ b/app/controllers/suppliers/employees_controller.rb
@@ -19,14 +19,12 @@ module Suppliers
# POST /employees.json
def create
@employee = Employee.new(employee_params)
- @employee.supplier = current_supplier
- respond_to do |format|
- if @employee.save
- render json: @employee, serializer: Suppliers::EmployeeSerializer, status: :created
- else
- render json: {errors: @employee.errors}, status: :unprocessable_entity
- end
+ if @employee.save
+ current_supplier.add_employee @employee
+ render json: @employee, serializer: Suppliers::EmployeeSerializer, status: :created
+ else
+ render json: {errors: @employee.errors}, status: :unprocessable_entity
end
end
diff --git a/app/controllers/suppliers/sections_controller.rb b/app/controllers/suppliers/sections_controller.rb
index d77a036d..72eb5120 100644
--- a/app/controllers/suppliers/sections_controller.rb
+++ b/app/controllers/suppliers/sections_controller.rb
@@ -17,7 +17,7 @@ module Suppliers
# end
# end
# end
- render json: @sections, each_serializer: SupplierExtendedSectionSerializer
+ render json: @sections, each_serializer: Suppliers::ExtendedSectionSerializer
end
# GET /sections/1
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 4870a494..277b64f8 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -182,5 +182,4 @@ module ApplicationHelper
options[:onclick] = function
link_to title, 'javascript:void(0)', options
end
-
end
diff --git a/app/models/employee.rb b/app/models/employee.rb
index 52068228..fba6135f 100644
--- a/app/models/employee.rb
+++ b/app/models/employee.rb
@@ -2,14 +2,23 @@ class Employee
include SimplyStored::Couch
include ActiveModel::SerializerSupport
- devise :database_authenticatable, :recoverable, :rememberable, :trackable #, :omniauthable, :omniauth_providers => [:facebook] #, :token_authenticatable , :registerable
+ view :by_confirmation_token, key: :confirmation_token # devise confirmable
+ devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable, :confirmable
+ property :unconfirmed_email
+
property :name
- property :email
+ #property :email
view :by_email, key: :email
- validates :email, email: true
- belongs_to :supplier
+ class << self
+ def count_by_email(email)
+ database.view by_email(key: email, reduce: true)
+ end
+ end
+
+ #validates :email, email: true
+ has_and_belongs_to_many :suppliers, storing_keys: false
has_many :orders
has_and_belongs_to_many :lists, storing_keys: false
diff --git a/app/models/supplier.rb b/app/models/supplier.rb
index 92e6736d..ceb34d6e 100644
--- a/app/models/supplier.rb
+++ b/app/models/supplier.rb
@@ -3,9 +3,7 @@ class Supplier
include ActiveModel::SerializerSupport
include Supplier::Counters
- view :by_confirmation_token, key: :confirmation_token # devise confirmable
- devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable, :confirmable
- property :unconfirmed_email
+ #devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable, :confirmable
property :name
property :open, type: :boolean, default: false
@@ -19,6 +17,7 @@ class Supplier
property :country, default: 'Netherlands'
property :facebook_promotion_url
property :week_starts_on_monday, type: :boolean, default: true
+ property :employee_settings_storage
#LOCATION
property :lat, type: Float #, default: 52.08062426379751
@@ -41,16 +40,13 @@ class Supplier
#has_many :lists, through: :tables
has_many :orders, dependent: :destroy
has_many :sections, dependent: :destroy
- has_many :employees
+ has_and_belongs_to_many :employees, storing_keys: true
after_create :add_section_on_create
- view :by_email, key: :email
-
validates :name, presence: true
- validates :email, email: true
validates :iens_profile, numericality: {allow_blank: true}
- validates :password, confirmation: true, presence: {if: ->(r){ r.new_record? }}
+ #validates :password, confirmation: true, presence: {if: ->(r){ r.new_record? }}
def location=(val)
lat, lng = val.is_a?(Array) ? val : val.strip.split(/[ ,]+/).map(&:to_f)
@@ -62,6 +58,17 @@ class Supplier
[lat, lng].join(',')
end
+ def add_manager(employee)
+ add_employee employee unless employee_ids.include? employee.id
+ settings = employee_settings.for_employee(employee)
+ settings.is_manager!
+ save and employee
+ end
+
+ def employee_settings
+ SupplierEmployeesSettings.new(self)
+ end
+
def active_orders(options = {})
return @active_orders if @active_orders && @active_orders_options == options
@active_orders_options = options
@@ -122,22 +129,22 @@ class Supplier
# Options must have the confirmation_token
#
# Overwrite devise method for mail sending
- def self.confirm_by_token(confirmation_token)
- confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_token)
- send_creation_mail = confirmable.errors.empty? && !confirmable.confirmed?
- confirmable.confirm! if confirmable.persisted?
- confirmable.send_creation_notifications if send_creation_mail
- confirmable
- end
+ #def self.confirm_by_token(confirmation_token)
+ #confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_token)
+ #send_creation_mail = confirmable.errors.empty? && !confirmable.confirmed?
+ #confirmable.confirm! if confirmable.persisted?
+ #confirmable.send_creation_notifications if send_creation_mail
+ #confirmable
+ #end
# Send confirmation instructions by email
- def send_confirmation_instructions(*args)
- self.confirmation_token = nil if reconfirmation_required?
- @reconfirmation_required = false
+ #def send_confirmation_instructions(*args)
+ #self.confirmation_token = nil if reconfirmation_required?
+ #@reconfirmation_required = false
- @bypass_postpone = true and generate_confirmation_token! if self.confirmation_token.blank?
- self.devise_mailer.confirmation_instructions(self, confirmation_token).deliver_now
- end
+ #@bypass_postpone = true and generate_confirmation_token! if self.confirmation_token.blank?
+ #self.devise_mailer.confirmation_instructions(self, confirmation_token).deliver_now
+ #end
def find_order(id)
order = Order.find(id)
diff --git a/app/serializers/supplier_employees_settings.rb b/app/serializers/supplier_employees_settings.rb
new file mode 100644
index 00000000..af1170d8
--- /dev/null
+++ b/app/serializers/supplier_employees_settings.rb
@@ -0,0 +1,71 @@
+class SupplierEmployeesSettings
+ attr_reader :dictionary, :employee_ids, :supplier
+ def initialize(supplier)
+ @supplier = supplier
+ @dictionary = supplier.employee_settings_storage || {}
+ @employee_ids = supplier.employee_ids || []
+ end
+
+ def for_employee(employee_id)
+ employee_id = employee_id.id if employee_id.is_a?(Employee)
+ if employee_ids.include? employee_id
+ SupplierEmployeeSettings.new(self, employee_id, dictionary[employee_id])
+ else
+ SupplierEmployeeSettings::NullObject.new
+ end
+ end
+
+ def [](val)
+ val = val.to_s
+ if dictionary[val].is_a? SettingsPersistor
+ dictionary[val]
+ else
+ dictionary[val] = SettingsPersistor.new(self, dictionary[val])
+ end
+ end
+
+ def persist
+ supplier.employee_settings_storage = dictionary
+ end
+
+ def method_missing(m, *args)
+ dictionary.send(m, *args)
+ end
+
+ class SettingsPersistor < Hash
+ attr_reader :all_employees_settings
+ def initialize(all_employees_settings, options = {})
+ @all_employees_settings = all_employees_settings
+ self.replace options if options.is_a? Hash
+ end
+
+ def []=(*args)
+ super
+ all_employees_settings.persist
+ end
+ end
+
+ class SupplierEmployeeSettings
+ delegate :as_json, :to_json, to: :settings
+ DEFAULTS = {
+ 'manager' => false
+ }
+ attr_reader :id, :settings, :all_employees_settings
+ class NullObject < ::NullObject
+ end
+
+ def initialize(all_employees_settings, employee_id, settings = {})
+ @all_employees_settings = all_employees_settings
+ @id = employee_id
+ @settings = DEFAULTS.merge(settings || {})
+ end
+
+ def manager?
+ settings['manager']
+ end
+
+ def is_manager!
+ all_employees_settings[id]['manager'] = true
+ end
+ end
+end
diff --git a/app/serializers/supplier_extended_section_serializer.rb b/app/serializers/supplier_extended_section_serializer.rb
deleted file mode 100644
index 0f7c3f13..00000000
--- a/app/serializers/supplier_extended_section_serializer.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class SupplierExtendedSectionSerializer < Qwaiter::Serializer
- root 'section'
- embed :ids, include: true
- attributes :title, :path, :width, :height
- has_many :tables, serializer: SupplierExtendedTableSerializer
-end
diff --git a/app/serializers/supplier_supplier_serializer.rb b/app/serializers/supplier_supplier_serializer.rb
deleted file mode 100644
index e6749454..00000000
--- a/app/serializers/supplier_supplier_serializer.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class SupplierSupplierSerializer < Qwaiter::Serializer
- self.root = :supplier
- attributes :extended_version, :open, :name, :lat, :lng, :email, :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
-
- def extended_version
- false
- end
-
-end
diff --git a/app/serializers/supplier_table_serializer.rb b/app/serializers/supplier_table_serializer.rb
index 5f0edf20..c2af84bf 100644
--- a/app/serializers/supplier_table_serializer.rb
+++ b/app/serializers/supplier_table_serializer.rb
@@ -2,5 +2,5 @@ class SupplierTableSerializer < Qwaiter::Serializer
self.root = :table
embed :ids, include: true
attributes :number, :width, :height, :position_x, :position_y, :section_id, :needs_help
- has_one :supplier, serializer: SupplierSupplierSerializer
+ has_one :supplier, serializer: Suppliers::SupplierSerializer
end
diff --git a/app/serializers/suppliers/employee_serializer.rb b/app/serializers/suppliers/employee_serializer.rb
index d85da47f..ade9740c 100644
--- a/app/serializers/suppliers/employee_serializer.rb
+++ b/app/serializers/suppliers/employee_serializer.rb
@@ -1,6 +1,5 @@
class Suppliers::EmployeeSerializer < Qwaiter::Serializer
self.root = :employee
embed :ids, include: true
- attributes :supplier_id, :name, :email
- has_many :orders
+ attributes :name, :email
end
diff --git a/app/serializers/suppliers/extended_section_serializer.rb b/app/serializers/suppliers/extended_section_serializer.rb
new file mode 100644
index 00000000..dd9a62de
--- /dev/null
+++ b/app/serializers/suppliers/extended_section_serializer.rb
@@ -0,0 +1,6 @@
+class Suppliers::ExtendedSectionSerializer < Qwaiter::Serializer
+ root 'section'
+ embed :ids, include: true
+ attributes :title, :path, :width, :height
+ has_many :tables, serializer: Suppliers::ExtendedTableSerializer
+end
diff --git a/app/serializers/supplier_extended_table_serializer.rb b/app/serializers/suppliers/extended_table_serializer.rb
similarity index 84%
rename from app/serializers/supplier_extended_table_serializer.rb
rename to app/serializers/suppliers/extended_table_serializer.rb
index ea79118e..0b7cf818 100644
--- a/app/serializers/supplier_extended_table_serializer.rb
+++ b/app/serializers/suppliers/extended_table_serializer.rb
@@ -1,4 +1,4 @@
-class SupplierExtendedTableSerializer < Qwaiter::Serializer
+class Suppliers::ExtendedTableSerializer < Qwaiter::Serializer
root 'table'
embed :ids, include: true
attributes :number, :width, :height, :position_x, :position_y, :section_id#, :active_list_id
diff --git a/app/serializers/suppliers/supplier_serializer.rb b/app/serializers/suppliers/supplier_serializer.rb
new file mode 100644
index 00000000..7a3dbeca
--- /dev/null
+++ b/app/serializers/suppliers/supplier_serializer.rb
@@ -0,0 +1,12 @@
+class Suppliers::SupplierSerializer < Qwaiter::Serializer
+ self.root = :supplier
+ embed :ids, include: true
+ attributes :extended_version, :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
+
+ def extended_version
+ true
+ end
+ has_many :sections, serializer: Suppliers::ExtendedSectionSerializer
+ has_many :product_categories
+end
diff --git a/app/services/ability.rb b/app/services/ability.rb
new file mode 100644
index 00000000..631f517d
--- /dev/null
+++ b/app/services/ability.rb
@@ -0,0 +1,11 @@
+class Ability
+ include CanCan::Ability
+ def initialize(settings)
+ settings ||= SupplierEmployeesSettings.new(Supplier.new).for_employee(nil)
+ if settings.manager?
+ can :manage, :all
+ else
+ can :read, :all
+ end
+ end
+end
diff --git a/app/services/new_supplier.rb b/app/services/new_supplier.rb
new file mode 100644
index 00000000..0be0991c
--- /dev/null
+++ b/app/services/new_supplier.rb
@@ -0,0 +1,46 @@
+class NewSupplier
+ include ActiveAttr::Model
+ attr_accessor :current_employee
+
+ attribute :supplier_name
+ attribute :email
+ attribute :password
+ attribute :password_confirmation
+
+ without_current_supplier = { unless: 'current_employee.present?' }
+ validates :supplier_name, presence: true
+ validates :email, email: without_current_supplier
+ validates :password, presence: without_current_supplier, confirmation: without_current_supplier
+
+ validate :supplier_name_uniqueness
+ validate :employee_uniqueness
+
+ def save
+ if valid?
+ persist!
+ true
+ else
+ false
+ end
+ end
+
+ private
+
+ def persist!
+ employee = Employee.new unconfirmed_email: email, password: password, password_confirmation: password_confirmation
+ raise "Cannot create employee with #{attributes.inspect}" unless employee.save
+ supplier = Supplier.create name: supplier_name
+ supplier.add_manager employee
+ end
+
+ def employee_uniqueness
+ return if current_employee.present?
+ errors.add :email, :taken if Employee.count_by_email(email) > 0
+ end
+
+ def supplier_name_uniqueness
+ return unless current_employee.present? and supplier_name.present?
+ current_suppliers = current_employee.suppliers
+ errors.add :base, 'You already have a supplier with that name' if current_suppliers.map(&:name).include? supplier_name
+ end
+end
diff --git a/app/services/null_object.rb b/app/services/null_object.rb
new file mode 100644
index 00000000..8b15f13b
--- /dev/null
+++ b/app/services/null_object.rb
@@ -0,0 +1,23 @@
+NullObject = Naught.build do |config|
+ config.black_hole
+ config.define_explicit_conversions
+ config.define_implicit_conversions
+end
+
+class NullObject
+ def presence
+ nil
+ end
+ def present?
+ false
+ end
+ def blank?
+ true
+ end
+ def empty?
+ true
+ end
+ def any?
+ false
+ end
+end
diff --git a/app/views/suppliers/mailer/confirmation_instructions.html.slim b/app/views/employees/mailer/confirmation_instructions.html.slim
similarity index 68%
rename from app/views/suppliers/mailer/confirmation_instructions.html.slim
rename to app/views/employees/mailer/confirmation_instructions.html.slim
index 6f2701bb..1b74a21a 100644
--- a/app/views/suppliers/mailer/confirmation_instructions.html.slim
+++ b/app/views/employees/mailer/confirmation_instructions.html.slim
@@ -3,4 +3,5 @@ p= t('devise.mailer.confirmation_instructions.supplier.salutation', email: @reso
p=raw t \
'devise.mailer.confirmation_instructions.supplier.body',
unconfirmed_email: @resource.unconfirmed_email,
- confirm_url: confirmation_url(@resource, :confirmation_token => @resource.confirmation_token)
+ confirm_url: confirmation_url(@resource, confirmation_token: @token)
+p Boe
diff --git a/app/views/suppliers/mailer/reset_password_instructions.html.erb b/app/views/employees/mailer/reset_password_instructions.html.erb
similarity index 100%
rename from app/views/suppliers/mailer/reset_password_instructions.html.erb
rename to app/views/employees/mailer/reset_password_instructions.html.erb
diff --git a/app/views/suppliers/mailer/unlock_instructions.html.erb b/app/views/employees/mailer/unlock_instructions.html.erb
similarity index 100%
rename from app/views/suppliers/mailer/unlock_instructions.html.erb
rename to app/views/employees/mailer/unlock_instructions.html.erb
diff --git a/app/views/new_suppliers/new.html.slim b/app/views/new_suppliers/new.html.slim
new file mode 100644
index 00000000..7131ab15
--- /dev/null
+++ b/app/views/new_suppliers/new.html.slim
@@ -0,0 +1,28 @@
+.row
+ .large-7.large-offset-1.columns
+ = form_for @new_supplier do |f|
+ = f.row :supplier_name
+ .large-4.columns= f.label :supplier_name
+ .large-4.columns= f.text_field :supplier_name
+ .large-4.columns= f.error_message :supplier_name
+ = f.row :email
+ .large-4.columns= f.label :email
+ .large-4.columns
+ - if @new_supplier.current_employee.present?
+ = @new_supplier.current_employee.email
+ - else
+ = f.email_field :email
+ .large-4.columns= f.error_message :email
+ - if not @new_supplier.current_employee.present?
+ = f.row :password
+ .large-4.columns= f.label :password
+ .large-4.columns= f.text_field :password
+ .large-4.columns= f.error_message :password
+ = f.row :password_confirmation
+ .large-4.columns= f.label :password_confirmation
+ .large-4.columns= f.text_field :password_confirmation
+ .large-4.columns= f.error_message :password_confirmation
+
+ .form-actions
+ = f.submit class: 'button'
+
diff --git a/app/views/suppliers/application/_head.html.erb b/app/views/suppliers/application/_head.html.erb
index e3bcdb5a..89405cd9 100644
--- a/app/views/suppliers/application/_head.html.erb
+++ b/app/views/suppliers/application/_head.html.erb
@@ -1,7 +1,9 @@