End of day commit
This commit is contained in:
@@ -35,7 +35,9 @@ group :assets do
|
||||
#gem 'therubyracer', :platforms => :ruby
|
||||
|
||||
gem 'uglifier', '>= 1.0.3'
|
||||
#gem "emblem-source", github: "machty/emblem.js"
|
||||
gem 'emblem-rails'
|
||||
gem 'ember-validations-rails'
|
||||
|
||||
gem 'foundation-rails' #, github: 'bterkuile/foundation-rails'
|
||||
#gem 'mustache' #, :require => 'mustache/railtie'
|
||||
|
||||
@@ -189,6 +189,8 @@ GEM
|
||||
railties (>= 3.1)
|
||||
ember-source (1.8.1)
|
||||
handlebars-source (~> 1.0)
|
||||
ember-validations-rails (1.0.0)
|
||||
railties
|
||||
ember_script (0.0.5)
|
||||
ember_script-source (>= 0.0.2)
|
||||
execjs
|
||||
@@ -462,6 +464,7 @@ DEPENDENCIES
|
||||
devise_simply_stored!
|
||||
ember-rails
|
||||
ember-source (= 1.8.1)
|
||||
ember-validations-rails
|
||||
ember_script-rails!
|
||||
emblem-rails
|
||||
factory_girl_rails
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
#= require handlebars
|
||||
#= require ember
|
||||
#= require ember-data
|
||||
#= require ember-validations
|
||||
#= require_directory ./modifications
|
||||
#= require shared-ember-helpers/all
|
||||
#= require ./app
|
||||
#= require ./controllers/modals/base_controller
|
||||
#= require ion.sound
|
||||
#= require_tree .
|
||||
@$assets_path = '/assets/';
|
||||
@$assets_path = '/assets/'
|
||||
@EmberENV = {FEATURES: {'query-params-new': true}}
|
||||
@$days = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
|
||||
|
||||
@@ -25,8 +25,7 @@ App.MenuProductComponent = Ember.Component.extend
|
||||
save: ->
|
||||
return unless @get('product.isValid')
|
||||
if @get('product.isDirty')
|
||||
@get('product').save().then((-> true), (-> true))
|
||||
@set 'editMode', false
|
||||
@get('product').save().then((=> @set 'editMode', false), (-> true))
|
||||
destroyProduct: (product)->
|
||||
if product.get('isNew')
|
||||
product.deleteRecord()
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
App.EmployeesIndexController = Ember.ArrayController.extend
|
||||
employees: (-> @get('model').sortBy('name')).property('model.@each.name')
|
||||
actions:
|
||||
newEmployee: ->
|
||||
employee = @store.createRecord('employee')
|
||||
@modal 'employee_edit',
|
||||
model: employee
|
||||
close: -> employee.deleteRecord()
|
||||
editEmployee: (employee)->
|
||||
@modal 'employee_edit',
|
||||
model: employee
|
||||
close: -> employee.rollback()
|
||||
destroyEmployee: (employee)->
|
||||
@modal 'confirm',
|
||||
title: t('employee.destroy.modal.title', employee.serialize())
|
||||
ok: -> employee.destroyRecord()
|
||||
@@ -36,8 +36,9 @@
|
||||
@send 'closeModal' unless @preventClose
|
||||
confirm: -> @send('ok')
|
||||
save: ->
|
||||
@get('model').save()
|
||||
@send 'closeModal' unless @preventClose
|
||||
if @get('model.isValid')
|
||||
@get('model').save().then((=> @send 'closeModal' ), (-> true))
|
||||
#@send 'closeModal' unless @preventClose
|
||||
destroy: ->
|
||||
@modal 'confirm',
|
||||
title_path: @get('modal_options.destroy_text_path') || 'general.destroy.text'
|
||||
|
||||
@@ -3,10 +3,13 @@ Ember.Handlebars.helper 'errors', (errors, params..., options)->
|
||||
result = ""
|
||||
model_name = options.hash.includeAttribute
|
||||
for error in errors
|
||||
if typeof error is "string"
|
||||
message = error
|
||||
else
|
||||
if model_name
|
||||
attribute = ttry("attributes.#{model_name}.#{error.attribute}")
|
||||
message = "#{attribute} #{error.message}"
|
||||
else
|
||||
message = error.message
|
||||
result += "<div class='error'>#{message}</div>"
|
||||
new Ember.Handlebars.SafeString(result)
|
||||
result.htmlSafe()
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
attr = DS.attr
|
||||
App.Employee= DS.Model.extend Ember.Validations.Mixin,
|
||||
name: attr 'string'
|
||||
email: attr 'string'
|
||||
|
||||
validations:
|
||||
name:
|
||||
presence: true
|
||||
@@ -12,6 +12,8 @@ App.Router.map ->
|
||||
@resource 'table', path: ':table_id'
|
||||
@resource 'lists', ->
|
||||
@resource 'list', path: ':list_id'
|
||||
@resource 'employees', ->
|
||||
@resource 'employee', path: ':employee_id'
|
||||
@route 'orders_display' # chromecast etc
|
||||
@route 'menu'
|
||||
@route 'settings'
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
App.EmployeesRoute = Ember.Route.extend
|
||||
model: -> @store.find 'employee'
|
||||
@@ -0,0 +1 @@
|
||||
= outlet
|
||||
@@ -0,0 +1,21 @@
|
||||
.row: .small-12.columns
|
||||
h1=t 'models.plural.employee'
|
||||
if employees
|
||||
table.table
|
||||
thead
|
||||
tr
|
||||
th.name=t 'attributes.employee.name'
|
||||
th.email=t 'attributes.employee.email'
|
||||
th.actions=t 'helpers.actions.title'
|
||||
tbody
|
||||
each employee in employees
|
||||
tr
|
||||
td: link-to 'employee' employee: span= employee.name
|
||||
td.email
|
||||
= employee.email
|
||||
= errors employee.errors.email
|
||||
td.actions
|
||||
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'
|
||||
@@ -13,6 +13,8 @@ header.top-menu
|
||||
= t 'models.plural.table'
|
||||
= link-to "lists" class="top-menu-lists"
|
||||
= t 'models.plural.list'
|
||||
= link-to "employees" class="top-menu-employees"
|
||||
= t 'models.plural.employee'
|
||||
.extra-info{action "showSupplierStatusInfo"}
|
||||
.supplier-info-row
|
||||
.counter.supplier-orders-placed-count
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
p=t 'employee.edit.modal.body_header'
|
||||
.form-row.name
|
||||
.form-label=t 'attributes.employee.name'
|
||||
.form-field
|
||||
= input valueBinding="model.name"
|
||||
= errors model.errors.name
|
||||
.form-row.name
|
||||
.form-label=t 'attributes.employee.email'
|
||||
.form-field
|
||||
= input type="email" valueBinding="model.email"
|
||||
= 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'
|
||||
+1
-1
@@ -3,7 +3,7 @@ App.BooleanButtonView = Ember.View.extend
|
||||
href: '#'
|
||||
classNames: "button"
|
||||
# templateName: "form_elements/boolean_switch"
|
||||
template: Ember.Handlebars.compile "<span>{{view.text}}</span>"
|
||||
#template: Ember.Handlebars.compile "<span>{{view.text}}</span>"
|
||||
classNameBindings: ['rounded:round', 'active:active:disabled']
|
||||
|
||||
text: Ember.computed 'text_path', ->
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
+grid-column($columns: 9, $last-column:true)
|
||||
&.half
|
||||
+grid-column(6)
|
||||
.error
|
||||
color: $alert-color
|
||||
&.form-actions
|
||||
padding-top: 12px
|
||||
body
|
||||
|
||||
@@ -16,6 +16,10 @@ table
|
||||
text-align: right
|
||||
&.date
|
||||
text-align: right
|
||||
.error
|
||||
display: inline-block
|
||||
padding-left: 5px
|
||||
color: $alert-color
|
||||
a.table-qr-codes
|
||||
+button-icon-only
|
||||
.table-edit
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
module Suppliers
|
||||
class EmployeesController < Suppliers::ApplicationController
|
||||
|
||||
# GET /employees
|
||||
# GET /employees.json
|
||||
def index
|
||||
@employees = current_supplier.employees
|
||||
render json: @employees, each_serializer: Suppliers::EmployeeSerializer
|
||||
end
|
||||
|
||||
# GET /employees/1
|
||||
# GET /employees/1.json
|
||||
def show
|
||||
@employee = Employee.find(params[:id])
|
||||
render json: @employee, serializer: Suppliers::EmployeeSerializer
|
||||
end
|
||||
|
||||
# POST /employees
|
||||
# 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
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /employees/1
|
||||
# PUT /employees/1.json
|
||||
def update
|
||||
@employee = Employee.find(params[:id])
|
||||
render json: {}, status: 404 unless @employee.supplier_id == current_supplier.id
|
||||
respond_to do |format|
|
||||
if @employee.update_attributes(employee_params)
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.json { render json: {errors: @employee.errors}, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /employees/1
|
||||
# DELETE /employees/1.json
|
||||
def destroy
|
||||
@employee = Employee.find(params[:id])
|
||||
render json: {}, status: :forbidden unless @employee.supplier_id == current_supplier.id
|
||||
@employee.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def employee_params
|
||||
params.require(:employee).permit(:name, :email)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,8 +1,14 @@
|
||||
class Employee
|
||||
include SimplyStored::Couch
|
||||
include ActiveModel::SerializerSupport
|
||||
|
||||
devise :database_authenticatable, :recoverable, :rememberable, :trackable #, :omniauthable, :omniauth_providers => [:facebook] #, :token_authenticatable , :registerable
|
||||
property :name
|
||||
property :email
|
||||
|
||||
view :by_email, key: :email
|
||||
|
||||
validates :email, email: true
|
||||
belongs_to :supplier
|
||||
has_many :orders
|
||||
has_and_belongs_to_many :lists, storing_keys: false
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class Suppliers::EmployeeSerializer < Qwaiter::Serializer
|
||||
self.root = :employee
|
||||
embed :ids, include: true
|
||||
attributes :supplier_id, :name, :email
|
||||
has_many :orders
|
||||
end
|
||||
@@ -11,6 +11,7 @@ en:
|
||||
section: Section
|
||||
join_request: Join request
|
||||
user_feedback: User feedback
|
||||
employee: Employee
|
||||
plural:
|
||||
user: Users
|
||||
supplier: Restaurants
|
||||
@@ -22,6 +23,7 @@ en:
|
||||
section: Sections
|
||||
join_request: Join requests
|
||||
user_feedback: User feedbacks
|
||||
employee: Employees
|
||||
attributes:
|
||||
product_category:
|
||||
name: Name
|
||||
|
||||
@@ -10,6 +10,7 @@ nl:
|
||||
product_category: Product categorie
|
||||
section: Afdeling
|
||||
join_request: Deelname verzoek
|
||||
employee: Werknemer
|
||||
plural:
|
||||
user: Gebruikers
|
||||
supplier: Restaurants
|
||||
@@ -20,6 +21,7 @@ nl:
|
||||
product_category: Product categorieen
|
||||
section: Afdelingen
|
||||
join_request: Deelname verzoeken
|
||||
employee: Werknemers
|
||||
attributes:
|
||||
product_category:
|
||||
name: Naam
|
||||
|
||||
@@ -182,3 +182,11 @@ en:
|
||||
orders_placed_count_explanation: " means that there are %{count} orders placed and not yet processing or finished"
|
||||
orders_in_process_count_explanation: " means that there are %{count} orders currently processing"
|
||||
close: Got it
|
||||
employee:
|
||||
new_button: 'Add ${models.employee}'
|
||||
destroy:
|
||||
modal:
|
||||
title: 'Delete ${models.employee} %{name}?'
|
||||
edit:
|
||||
modal:
|
||||
body_header: ''
|
||||
|
||||
@@ -185,3 +185,8 @@ nl:
|
||||
orders_placed_count_explanation: " means that there are %{count} orders placed and not yet processing or finished"
|
||||
orders_in_process_count_explanation: " means that there are %{count} orders currently processing"
|
||||
close: Got it
|
||||
employee:
|
||||
new_button: '${models.employee} toevoegen'
|
||||
destroy:
|
||||
modal:
|
||||
title: '${models.employee} %{name} verwijderen?'
|
||||
|
||||
@@ -128,6 +128,8 @@ Qwaiter::Application.routes.draw do
|
||||
get :qr_codes
|
||||
end
|
||||
end
|
||||
|
||||
resources :employees
|
||||
resources :products do
|
||||
collection do
|
||||
get :preview_products
|
||||
|
||||
Reference in New Issue
Block a user