Add my-schedule and some other things
This commit is contained in:
@@ -2,5 +2,6 @@ class Employees::Ability
|
||||
include CanCan::Ability
|
||||
def initialize(employee)
|
||||
can :read, Supplier
|
||||
can :read, EmployeeShift
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,6 +3,6 @@ App.QrCodesLinkComponent = Ember.Component.extend
|
||||
target: '_blank'
|
||||
classNames: ["table-qr-codes"]
|
||||
attributeBindings: ['href', 'target']
|
||||
href: Ember.computed 'section.id', ->
|
||||
Routes.qr_codes_suppliers_tables_path(section_id: @get('section.id'))
|
||||
href: Ember.computed 'section.id', 'table.id', ->
|
||||
Routes.qr_codes_suppliers_tables_path(section_id: @get('section.id'), table_id: @get('table.id'))
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ App.SectionAreaComponent = Ember.Component.extend DragNDrop.Draggable,
|
||||
classNameBindings: ['vertical', 'right_half:right-half', 'section_area.rounded:rounded']
|
||||
pixelWidth: Ember.computed 'section_area.width', 'dpm', -> @get('dpm') * @get('section_area.width')
|
||||
pixelHeight: Ember.computed 'section_area.height', 'dpm', -> @get('dpm') * @get('section_area.height')
|
||||
offsetX: Ember.computed.product 'dpm', 'content.position_x'
|
||||
offsetY: Ember.computed.product 'dpm', 'content.position_y'
|
||||
offsetX: Ember.computed.product 'dpm', 'section_area.position_x'
|
||||
offsetY: Ember.computed.product 'dpm', 'section_area.position_y'
|
||||
vertical: Ember.computed 'section_area.width', 'section_area.height', 'section.editmode', ->
|
||||
not @get('section.editmode') and @get('section_area.height') > @get('section_area.width')
|
||||
right_half: Ember.computed 'section_area.position_x', 'section_area.width', 'section_area.sectino.width', ->
|
||||
right_half: Ember.computed 'section_area.position_x', 'section_area.width', 'section_area.section.width', ->
|
||||
@get('section_area.position_x') + (@get('section_area.width') / 2) > (@get('section_area.section.width') / 2)
|
||||
style: Ember.computed 'offsetX', 'offsetY', 'pixelWidth', 'pixelHeight', ->
|
||||
App.CssObject.create(
|
||||
@@ -19,12 +19,11 @@ App.SectionAreaComponent = Ember.Component.extend DragNDrop.Draggable,
|
||||
top: @get('offsetY')
|
||||
"line-height": @get('pixelHeight')
|
||||
).toString()
|
||||
content: Ember.computed.alias 'section_area'
|
||||
draggable: (-> if @get('section.editmode') then true else false ).property('section.editmode')
|
||||
positionChange: (position)->
|
||||
dpm = @get('dpm')
|
||||
return if !dpm or parseFloat(dpm) is 0
|
||||
@get('content').setProperties
|
||||
@get('section_area').setProperties
|
||||
position_x: position.left / dpm
|
||||
position_y: position.top / dpm
|
||||
click: ->
|
||||
|
||||
@@ -14,11 +14,14 @@ App.SectionTableComponent = Ember.Component.extend DragNDrop.Draggable,
|
||||
'table.active_list.needs_help:needs_help',
|
||||
'table.active_list.needs_payment:needs_payment',
|
||||
'table.active_list.has_active_orders:active_order',
|
||||
'right_half:right-half',
|
||||
'uniqueClass'
|
||||
]
|
||||
uniqueClass: (->
|
||||
"section-table-#{@get('table.id')}"
|
||||
).property('table.id')
|
||||
right_half: Ember.computed 'table.position_x', 'table.width', 'table.section.width', ->
|
||||
@get('table.position_x') + (@get('table.width') / 2) > (@get('table.section.width') / 2)
|
||||
offsetX: (->
|
||||
(@get('dpm') || 0) * (@get('table.position_x') || 0)
|
||||
).property('dpm', 'table.position_x')
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
App.MyScheduleController = Ember.Controller.extend
|
||||
actions:
|
||||
debugger: -> debugger
|
||||
@@ -5,7 +5,7 @@ App.ScheduleController = Ember.Controller.extend
|
||||
employee_shift.set 'end_on', event.end
|
||||
employee_shift.save()
|
||||
editEvent: (id, callbacks)->
|
||||
if employee_shift = @store.all('employee-shift').findBy('id', id)
|
||||
if employee_shift = @store.peekRecord('employee-shift', id)
|
||||
@modal 'employee_shift',
|
||||
title_path: 'employee_shift.modal.title'
|
||||
destroy_text_path: 'employee_shift.modal.destroy_confirmation'
|
||||
|
||||
@@ -11,9 +11,22 @@ App.EmployeeShift = DS.Model.extend
|
||||
end: @get('end_on')
|
||||
color: @get('employee.color')
|
||||
).property('start_from', 'end_on', 'title')
|
||||
supplier: DS.belongsTo('supplier')
|
||||
|
||||
title: Ember.computed 'employee.name', 'description', ->
|
||||
if @get('description')
|
||||
[@get('employee.name'), @get('description')].join(' - ')
|
||||
else
|
||||
@get 'employee.name'
|
||||
calendar_event_for_employee: (->
|
||||
id: @id
|
||||
title: @get('title_for_employee')
|
||||
start: @get('start_from')
|
||||
end: @get('end_on')
|
||||
color: @get('employee.color')
|
||||
).property('start_from', 'end_on', 'title_for_employee')
|
||||
title_for_employee: Ember.computed 'supplier.name', 'description', ->
|
||||
if @get('description')
|
||||
[@get('supplier.name'), @get('description')].join(' - ')
|
||||
else
|
||||
@get 'supplier.name'
|
||||
|
||||
@@ -18,6 +18,7 @@ App.Supplier = DS.Model.extend
|
||||
product_categories: DS.hasMany 'product_category'
|
||||
orders_in_process_count: attr('number')
|
||||
orders_placed_count: attr('number')
|
||||
employee_shifts: DS.hasMany('employee-shift')
|
||||
|
||||
close: ->
|
||||
$.post Routes.mark_as_closed_suppliers_supplier_path(@id), =>
|
||||
|
||||
@@ -19,7 +19,8 @@ App.Router.map ->
|
||||
@route 'orders_display' # chromecast etc
|
||||
@route 'menu'
|
||||
@route 'settings'
|
||||
@route 'my_account'
|
||||
@route 'schedule'
|
||||
@route 'my_account'
|
||||
@route 'my-schedule'
|
||||
@route 'empty'
|
||||
#@resource 'lists', queryParams: ['state']
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
App.MyScheduleRoute = Ember.Route.extend
|
||||
model: ->
|
||||
$.getJSON(Routes.employees_employee_shifts_path()).then (payload)=>
|
||||
@store.pushPayload payload
|
||||
@store.peekAll('employee-shift')
|
||||
@@ -1,2 +1,2 @@
|
||||
App.ScheduleRoute = Ember.Route.extend
|
||||
model: -> @store.find 'employee-shift'
|
||||
model: -> @store.findAll 'employee-shift'
|
||||
|
||||
@@ -21,6 +21,7 @@ header.top-menu
|
||||
ul
|
||||
li
|
||||
li= link-to 'my_account': span.current-employee-my-account-icon= t 'current_employee.my_account.link'
|
||||
li= link-to 'my-schedule': span.current-employee-my-schedule-icon= t 'current_employee.my_schedule.link'
|
||||
li: a{action "signOut"}: span.sign-out-icon= t 'supplier.sign_out'
|
||||
if globals.current_supplier.open
|
||||
/a.supplier-is-closed-indication.is-open{ action "markSupplierClosed" }: span.fa.fa-beer.fa-2x
|
||||
|
||||
@@ -14,3 +14,4 @@ p=t 'table.modal.body_header'
|
||||
hr
|
||||
button.modal-close{action "close"}=t 'table.modal.close_button'
|
||||
button.modal-confirm.right{action "save"}=t 'table.modal.save_button'
|
||||
= qr-codes-link table=model
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
.row: .small-12.columns: h2=t 'current_employee.my_schedule.title'
|
||||
.row: .small-12.columns
|
||||
#schedule-placeholder
|
||||
@@ -0,0 +1,43 @@
|
||||
App.MyScheduleView = Ember.View.extend
|
||||
classNames: ['schedule-view']
|
||||
didInsertElement: ->
|
||||
placeholder = @$('#schedule-placeholder')
|
||||
controller = @get('controller')
|
||||
events = @get('globals.current_employee.employee_shifts').map( (employee_shift)->employee_shift.get('calendar_event_for_employee') )
|
||||
placeholder.fullCalendar
|
||||
header:
|
||||
left: 'prev,next,today'
|
||||
center: 'title'
|
||||
right: 'month,agendaWeek,agendaDay'
|
||||
selectable: false
|
||||
#selectHelper: true
|
||||
#select: (start, end)=>
|
||||
#format = 'dddd h:mm'
|
||||
#controller.modal 'select_employee',
|
||||
#ok: ->
|
||||
##this context is SelectEmployeeController
|
||||
#if employee = @get('employee')
|
||||
#shift = controller.store.createRecord 'employee-shift', start_from: start, end_on: end
|
||||
#shift.set 'employee', employee
|
||||
#shift.save().then ->
|
||||
#placeholder.fullCalendar('renderEvent', shift.get('calendar_event'), true)
|
||||
#header: t('employee_shift.time_window', start: start.format(format), end: end.format(format))
|
||||
#editable: true
|
||||
defaultView: 'agendaWeek'
|
||||
events: events
|
||||
timezone: 'UTC'
|
||||
#eventDrop: controller.event_changed.bind(controller)
|
||||
#eventResize: controller.event_changed.bind(controller)
|
||||
#eventClick: (event)->
|
||||
#controller.editEvent event.id,
|
||||
#save: (shift)->
|
||||
#placeholder.fullCalendar('removeEvents', [event.id])
|
||||
#placeholder.fullCalendar('renderEvent', shift.get('calendar_event'), true)
|
||||
#destroy: (shift)->
|
||||
#placeholder.fullCalendar('removeEvents', [event.id])
|
||||
timeFormat: 'H(:mm)'
|
||||
axisFormat: 'H:mm'
|
||||
lang: moment.locale()
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ App.ScheduleView = Ember.View.extend
|
||||
didInsertElement: ->
|
||||
placeholder = @$('#schedule-placeholder')
|
||||
controller = @get('controller')
|
||||
events = controller.get('model').filter((employee_shift) -> employee_shift.get('employee.active') ).map( (employee_shift)->employee_shift.get('calendar_event') )
|
||||
events = @get('globals.current_supplier.employee_shifts').filter((employee_shift) -> employee_shift.get('employee.active') ).map( (employee_shift)->employee_shift.get('calendar_event') )
|
||||
placeholder.fullCalendar
|
||||
header:
|
||||
left: 'prev,next,today'
|
||||
|
||||
@@ -97,6 +97,10 @@
|
||||
@extend .fa, .fa-user
|
||||
span
|
||||
padding-left: 7px
|
||||
span.current-employee-my-schedule-icon
|
||||
@extend .fa, .fa-calendar
|
||||
span
|
||||
padding-left: 7px
|
||||
&.active
|
||||
.dropdown-list-container
|
||||
display: block
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
@mixin button-icon-only
|
||||
padding: 2px 5px
|
||||
margin: 0
|
||||
&.hide
|
||||
display: none
|
||||
|
||||
@mixin table-fit
|
||||
width: 1px
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
.handle
|
||||
@extend .fa, .fa-arrows-v
|
||||
margin-right: 10px
|
||||
.table-qr-codes
|
||||
//+button($bg: $button-qr-code-color, $padding: $button-sml)
|
||||
+button($bg: $button-qr-code-color)
|
||||
margin-left: 10px
|
||||
.modal-alert
|
||||
color: $alert-color
|
||||
|
||||
|
||||
@@ -82,6 +82,10 @@
|
||||
.status-icons .active_order
|
||||
display: inline-block
|
||||
//background-color: #f77
|
||||
&.right-half
|
||||
.table-actions
|
||||
right: 100%
|
||||
left: initial
|
||||
a
|
||||
color: black
|
||||
&:hover
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
module Employees
|
||||
class EmployeeShiftsController < Employees::ApplicationController
|
||||
def index
|
||||
@employee_shifts = EmployeeShift.for_employee(current_employee).include_relation(:supplier)
|
||||
render json: @employee_shifts, each_serializer: Employees::EmployeeShiftSerializer
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2,7 +2,7 @@ module Suppliers
|
||||
class EmployeeShiftsController < Suppliers::ApplicationController
|
||||
def index
|
||||
@employee_shifts = EmployeeShift.for_supplier(current_supplier, relevant_from: 1.week.ago)
|
||||
@employee_shifts.include_relation(:employee)
|
||||
@employee_shifts.include_relations(:employee, :supplier)
|
||||
# Only select shifts from currently linked and employees
|
||||
@employee_shifts.select! do |shift|
|
||||
current_supplier.employee_ids.include?(shift.employee.try(:id))
|
||||
|
||||
@@ -88,6 +88,7 @@ module Suppliers
|
||||
def qr_codes
|
||||
@tables = Table.for_supplier(current_supplier, from_number: params[:from_number], to_number: params[:to_number])
|
||||
@tables.select!{|t| t.section_id == params[:section_id]} if params[:section_id].present?
|
||||
@tables.select!{|t| t.id == params[:table_id]} if params[:table_id].present?
|
||||
render layout: 'qr_sheet'
|
||||
end
|
||||
|
||||
|
||||
@@ -8,13 +8,23 @@ class EmployeeShift
|
||||
belongs_to :supplier
|
||||
belongs_to :employee
|
||||
|
||||
view :relevants_view, type: :custom, map_function: %|function(doc){
|
||||
view :for_supplier_view, type: :custom, map_function: %|function(doc){
|
||||
if(doc.ruby_class == 'EmployeeShift' && doc.start_from && doc.end_on){
|
||||
emit([doc.supplier_id, doc.end_on], 1)
|
||||
}
|
||||
}|, reduce_function: '_sum'
|
||||
|
||||
view :for_employee_view, type: :custom, map_function: %|function(doc){
|
||||
if(doc.ruby_class == 'EmployeeShift' && doc.start_from && doc.end_on){
|
||||
emit([doc.employee_id, doc.end_on], 1)
|
||||
}
|
||||
}|, reduce_function: '_sum'
|
||||
|
||||
def self.for_supplier(supplier, relevant_from: 1.week.ago)
|
||||
database.view relevants_view(startkey: [supplier.id, relevant_from], endkey: [supplier.id, {}], reduce: false, include_docs: true)
|
||||
database.view for_supplier_view(startkey: [supplier.id, relevant_from.iso8601], endkey: [supplier.id, {}], reduce: false, include_docs: true)
|
||||
end
|
||||
|
||||
def self.for_employee(employee, relevant_from: 1.week.ago)
|
||||
database.view for_employee_view(startkey: [employee.id, relevant_from.iso8601], endkey: [employee.id, {}], reduce: false, include_docs: true)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class Employees::EmployeeShiftSerializer < Qwaiter::Serializer
|
||||
self.root = :employee_shift
|
||||
attributes :start_from, :end_on, :employee_id, :description
|
||||
has_one :supplier
|
||||
end
|
||||
@@ -1,5 +1,6 @@
|
||||
class Suppliers::EmployeeShiftSerializer < Qwaiter::Serializer
|
||||
self.root = :employee_shift
|
||||
#embed :ids, include: true
|
||||
attributes :start_from, :end_on, :employee_id, :description
|
||||
attributes :start_from, :end_on, :employee_id
|
||||
has_one :supplier
|
||||
end
|
||||
|
||||
@@ -241,4 +241,7 @@ en:
|
||||
my_account:
|
||||
link: My account
|
||||
title: My account
|
||||
my_schedule:
|
||||
title: My schedule
|
||||
link: My schedule
|
||||
|
||||
|
||||
@@ -244,3 +244,6 @@ nl:
|
||||
my_account:
|
||||
link: Mijn account
|
||||
title: Mijn account
|
||||
my_schedule:
|
||||
title: Mijn schema
|
||||
link: Mijn schema
|
||||
|
||||
@@ -172,6 +172,7 @@ Qwaiter::Application.routes.draw do
|
||||
|
||||
namespace :employees, path: '/employee' do
|
||||
resources :suppliers
|
||||
resources :employee_shifts
|
||||
end
|
||||
|
||||
#DEMO & DEVELOPMENT
|
||||
|
||||
@@ -3,12 +3,10 @@ Release
|
||||
|
||||
Supplier
|
||||
--------
|
||||
|
||||
- Allow table drag rollback same as area and element in section edit
|
||||
mode view
|
||||
- Move arrange tables logic to the client
|
||||
- Show menu next to table in section view at the left side for tables at
|
||||
the right side of the section
|
||||
- collapse top menu on small screens
|
||||
- Add supplier specific name field to my_account
|
||||
- Add styling to active class active navigation items in top menu, side
|
||||
and dropdown menus
|
||||
- Proper emails when an employee is created or added to a supplier
|
||||
- Add section-area colors
|
||||
- Add snap_code toggle to svg elements
|
||||
@@ -16,8 +14,6 @@ Supplier
|
||||
- Employee personal schedule
|
||||
- english emails
|
||||
- Add qr print functionality offering to send the stickers
|
||||
- Add qr-print button to tables
|
||||
- Order product buttons to views
|
||||
- Use modernizr svg to determine svg handling capabilities
|
||||
- Add spec for switching from non-manager supplier to other supplier
|
||||
|
||||
|
||||
Reference in New Issue
Block a user