Add my-schedule and some other things

This commit is contained in:
2015-08-17 19:13:35 +02:00
parent 2df1b38e8f
commit 9cadc3e94f
30 changed files with 139 additions and 23 deletions
+1
View File
@@ -2,5 +2,6 @@ class Employees::Ability
include CanCan::Ability include CanCan::Ability
def initialize(employee) def initialize(employee)
can :read, Supplier can :read, Supplier
can :read, EmployeeShift
end end
end end
@@ -3,6 +3,6 @@ App.QrCodesLinkComponent = Ember.Component.extend
target: '_blank' target: '_blank'
classNames: ["table-qr-codes"] classNames: ["table-qr-codes"]
attributeBindings: ['href', 'target'] attributeBindings: ['href', 'target']
href: Ember.computed 'section.id', -> href: Ember.computed 'section.id', 'table.id', ->
Routes.qr_codes_suppliers_tables_path(section_id: @get('section.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'] classNameBindings: ['vertical', 'right_half:right-half', 'section_area.rounded:rounded']
pixelWidth: Ember.computed 'section_area.width', 'dpm', -> @get('dpm') * @get('section_area.width') 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') pixelHeight: Ember.computed 'section_area.height', 'dpm', -> @get('dpm') * @get('section_area.height')
offsetX: Ember.computed.product 'dpm', 'content.position_x' offsetX: Ember.computed.product 'dpm', 'section_area.position_x'
offsetY: Ember.computed.product 'dpm', 'content.position_y' offsetY: Ember.computed.product 'dpm', 'section_area.position_y'
vertical: Ember.computed 'section_area.width', 'section_area.height', 'section.editmode', -> vertical: Ember.computed 'section_area.width', 'section_area.height', 'section.editmode', ->
not @get('section.editmode') and @get('section_area.height') > @get('section_area.width') 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) @get('section_area.position_x') + (@get('section_area.width') / 2) > (@get('section_area.section.width') / 2)
style: Ember.computed 'offsetX', 'offsetY', 'pixelWidth', 'pixelHeight', -> style: Ember.computed 'offsetX', 'offsetY', 'pixelWidth', 'pixelHeight', ->
App.CssObject.create( App.CssObject.create(
@@ -19,12 +19,11 @@ App.SectionAreaComponent = Ember.Component.extend DragNDrop.Draggable,
top: @get('offsetY') top: @get('offsetY')
"line-height": @get('pixelHeight') "line-height": @get('pixelHeight')
).toString() ).toString()
content: Ember.computed.alias 'section_area'
draggable: (-> if @get('section.editmode') then true else false ).property('section.editmode') draggable: (-> if @get('section.editmode') then true else false ).property('section.editmode')
positionChange: (position)-> positionChange: (position)->
dpm = @get('dpm') dpm = @get('dpm')
return if !dpm or parseFloat(dpm) is 0 return if !dpm or parseFloat(dpm) is 0
@get('content').setProperties @get('section_area').setProperties
position_x: position.left / dpm position_x: position.left / dpm
position_y: position.top / dpm position_y: position.top / dpm
click: -> click: ->
@@ -14,11 +14,14 @@ App.SectionTableComponent = Ember.Component.extend DragNDrop.Draggable,
'table.active_list.needs_help:needs_help', 'table.active_list.needs_help:needs_help',
'table.active_list.needs_payment:needs_payment', 'table.active_list.needs_payment:needs_payment',
'table.active_list.has_active_orders:active_order', 'table.active_list.has_active_orders:active_order',
'right_half:right-half',
'uniqueClass' 'uniqueClass'
] ]
uniqueClass: (-> uniqueClass: (->
"section-table-#{@get('table.id')}" "section-table-#{@get('table.id')}"
).property('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: (-> offsetX: (->
(@get('dpm') || 0) * (@get('table.position_x') || 0) (@get('dpm') || 0) * (@get('table.position_x') || 0)
).property('dpm', 'table.position_x') ).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.set 'end_on', event.end
employee_shift.save() employee_shift.save()
editEvent: (id, callbacks)-> editEvent: (id, callbacks)->
if employee_shift = @store.all('employee-shift').findBy('id', id) if employee_shift = @store.peekRecord('employee-shift', id)
@modal 'employee_shift', @modal 'employee_shift',
title_path: 'employee_shift.modal.title' title_path: 'employee_shift.modal.title'
destroy_text_path: 'employee_shift.modal.destroy_confirmation' destroy_text_path: 'employee_shift.modal.destroy_confirmation'
@@ -11,9 +11,22 @@ App.EmployeeShift = DS.Model.extend
end: @get('end_on') end: @get('end_on')
color: @get('employee.color') color: @get('employee.color')
).property('start_from', 'end_on', 'title') ).property('start_from', 'end_on', 'title')
supplier: DS.belongsTo('supplier')
title: Ember.computed 'employee.name', 'description', -> title: Ember.computed 'employee.name', 'description', ->
if @get('description') if @get('description')
[@get('employee.name'), @get('description')].join(' - ') [@get('employee.name'), @get('description')].join(' - ')
else else
@get 'employee.name' @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' product_categories: DS.hasMany 'product_category'
orders_in_process_count: attr('number') orders_in_process_count: attr('number')
orders_placed_count: attr('number') orders_placed_count: attr('number')
employee_shifts: DS.hasMany('employee-shift')
close: -> close: ->
$.post Routes.mark_as_closed_suppliers_supplier_path(@id), => $.post Routes.mark_as_closed_suppliers_supplier_path(@id), =>
@@ -19,7 +19,8 @@ App.Router.map ->
@route 'orders_display' # chromecast etc @route 'orders_display' # chromecast etc
@route 'menu' @route 'menu'
@route 'settings' @route 'settings'
@route 'my_account'
@route 'schedule' @route 'schedule'
@route 'my_account'
@route 'my-schedule'
@route 'empty' @route 'empty'
#@resource 'lists', queryParams: ['state'] #@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 App.ScheduleRoute = Ember.Route.extend
model: -> @store.find 'employee-shift' model: -> @store.findAll 'employee-shift'
@@ -21,6 +21,7 @@ header.top-menu
ul ul
li li
li= link-to 'my_account': span.current-employee-my-account-icon= t 'current_employee.my_account.link' 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' li: a{action "signOut"}: span.sign-out-icon= t 'supplier.sign_out'
if globals.current_supplier.open if globals.current_supplier.open
/a.supplier-is-closed-indication.is-open{ action "markSupplierClosed" }: span.fa.fa-beer.fa-2x /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 hr
button.modal-close{action "close"}=t 'table.modal.close_button' button.modal-close{action "close"}=t 'table.modal.close_button'
button.modal-confirm.right{action "save"}=t 'table.modal.save_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: -> didInsertElement: ->
placeholder = @$('#schedule-placeholder') placeholder = @$('#schedule-placeholder')
controller = @get('controller') 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 placeholder.fullCalendar
header: header:
left: 'prev,next,today' left: 'prev,next,today'
@@ -97,6 +97,10 @@
@extend .fa, .fa-user @extend .fa, .fa-user
span span
padding-left: 7px padding-left: 7px
span.current-employee-my-schedule-icon
@extend .fa, .fa-calendar
span
padding-left: 7px
&.active &.active
.dropdown-list-container .dropdown-list-container
display: block display: block
@@ -1,6 +1,8 @@
@mixin button-icon-only @mixin button-icon-only
padding: 2px 5px padding: 2px 5px
margin: 0 margin: 0
&.hide
display: none
@mixin table-fit @mixin table-fit
width: 1px width: 1px
@@ -21,6 +21,10 @@
.handle .handle
@extend .fa, .fa-arrows-v @extend .fa, .fa-arrows-v
margin-right: 10px 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 .modal-alert
color: $alert-color color: $alert-color
@@ -82,6 +82,10 @@
.status-icons .active_order .status-icons .active_order
display: inline-block display: inline-block
//background-color: #f77 //background-color: #f77
&.right-half
.table-actions
right: 100%
left: initial
a a
color: black color: black
&:hover &: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 class EmployeeShiftsController < Suppliers::ApplicationController
def index def index
@employee_shifts = EmployeeShift.for_supplier(current_supplier, relevant_from: 1.week.ago) @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 # Only select shifts from currently linked and employees
@employee_shifts.select! do |shift| @employee_shifts.select! do |shift|
current_supplier.employee_ids.include?(shift.employee.try(:id)) current_supplier.employee_ids.include?(shift.employee.try(:id))
@@ -88,6 +88,7 @@ module Suppliers
def qr_codes def qr_codes
@tables = Table.for_supplier(current_supplier, from_number: params[:from_number], to_number: params[:to_number]) @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.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' render layout: 'qr_sheet'
end end
+12 -2
View File
@@ -8,13 +8,23 @@ class EmployeeShift
belongs_to :supplier belongs_to :supplier
belongs_to :employee 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){ if(doc.ruby_class == 'EmployeeShift' && doc.start_from && doc.end_on){
emit([doc.supplier_id, doc.end_on], 1) emit([doc.supplier_id, doc.end_on], 1)
} }
}|, reduce_function: '_sum' }|, 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) 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
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 class Suppliers::EmployeeShiftSerializer < Qwaiter::Serializer
self.root = :employee_shift self.root = :employee_shift
#embed :ids, include: true #embed :ids, include: true
attributes :start_from, :end_on, :employee_id, :description attributes :start_from, :end_on, :employee_id
has_one :supplier
end end
+3
View File
@@ -241,4 +241,7 @@ en:
my_account: my_account:
link: My account link: My account
title: My account title: My account
my_schedule:
title: My schedule
link: My schedule
+3
View File
@@ -244,3 +244,6 @@ nl:
my_account: my_account:
link: Mijn account link: Mijn account
title: Mijn account title: Mijn account
my_schedule:
title: Mijn schema
link: Mijn schema
+1
View File
@@ -172,6 +172,7 @@ Qwaiter::Application.routes.draw do
namespace :employees, path: '/employee' do namespace :employees, path: '/employee' do
resources :suppliers resources :suppliers
resources :employee_shifts
end end
#DEMO & DEVELOPMENT #DEMO & DEVELOPMENT
+4 -8
View File
@@ -3,12 +3,10 @@ Release
Supplier Supplier
-------- --------
- collapse top menu on small screens
- Allow table drag rollback same as area and element in section edit - Add supplier specific name field to my_account
mode view - Add styling to active class active navigation items in top menu, side
- Move arrange tables logic to the client and dropdown menus
- Show menu next to table in section view at the left side for tables at
the right side of the section
- Proper emails when an employee is created or added to a supplier - Proper emails when an employee is created or added to a supplier
- Add section-area colors - Add section-area colors
- Add snap_code toggle to svg elements - Add snap_code toggle to svg elements
@@ -16,8 +14,6 @@ Supplier
- Employee personal schedule - Employee personal schedule
- english emails - english emails
- Add qr print functionality offering to send the stickers - 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 - Use modernizr svg to determine svg handling capabilities
- Add spec for switching from non-manager supplier to other supplier - Add spec for switching from non-manager supplier to other supplier