Add my-schedule and some other things
This commit is contained in:
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user