major usability improvements

This commit is contained in:
2015-08-18 16:00:10 +02:00
parent 9cadc3e94f
commit 8a5c2e5b74
47 changed files with 423 additions and 178 deletions
@@ -2,6 +2,6 @@ Ember.Handlebars.helper 't', (path, params..., options)->
toptions = options.hash
if params.length and typeof(params[0].serialize) is 'function'
$.extend toptions, params[0].serialize()
text = t(path, options.hash)
tag = if options.hash.bare then text else "<span data-t='#{path}' class='translation' data-t-attributes='#{JSON.stringify(options.hash)}'>#{text}</span>"
text = t(path, toptions)
tag = if options.hash.bare then text else "<span data-t='#{path}' class='translation' data-t-attributes='#{JSON.stringify(toptions)}'>#{text}</span>"
tag.htmlSafe()
@@ -4,16 +4,16 @@ App.ApplicationController = Ember.Controller.extend
#success = (supplier)=>
## A supplier record with id current and with the content of the returned supplier is created
## at the moment remove the dummy supplier, this should be resolved by Ember eventually
#if error_supplier = @store.all('supplier').findBy('id', 'current')
#if error_supplier = @store.peekAll('supplier').findBy('id', 'current')
#error_supplier.eraseRecord()
#@set 'supplier', supplier
#error = (emberError)=>
#if error_supplier = @store.all('supplier').findBy('id', 'current')
#if error_supplier = @store.peekAll('supplier').findBy('id', 'current')
#error_supplier.eraseRecord()
#@set 'supplier', null
#@store.find('supplier', 'current').then success, error
# @set 'supplier', @store.find('supplier', supplier_id)
#@store.findRecord('supplier', 'current').then success, error
# @set 'supplier', @store.findRecord('supplier', supplier_id)
#current_employee: (-> @get('employee') ).property('employee')
actions:
signOut: ->
@@ -2,9 +2,9 @@ App.IndexController = Ember.Controller.extend
needs: ['application']
show_lists: true
show_orders: true
lists: (-> @store.all('list')).property()
orders: (-> @store.all('order')).property()
sections: (-> @store.all('section')).property()
lists: (-> @store.peekAll('list')).property()
orders: (-> @store.peekAll('order')).property()
sections: (-> @store.peekAll('section')).property()
active_section: Ember.computed.alias 'globals.active_section'
active_lists: (->
if section_id = @get('active_section.id')
@@ -2,12 +2,12 @@ App.ListsIndexController = Ember.Controller.extend
loading: true
dateChanged: (->
@set 'loading', true
lists = if @get('date') then @store.find('list', date: @get('date')) else @store.find('list')
lists = if @get('date') then @store.findAll('list', date: @get('date')) else @store.findAll('list')
lists.then => @set('loading', false)
@set 'model', lists
).observes('date')
lists: (->
return @store.all('list') unless date = @get('date')
return @store.peekAll('list') unless date = @get('date')
@store.filter('list', (l)->
return false unless list_date = l.get('created_at')
list_date = list_date.toISOString().substring(0,10) if typeof(list_date) is 'object'
@@ -1,7 +1,7 @@
App.MenuController = Ember.Controller.extend
needs: ['application']
product_code_filter: ''
product_categories: (-> @store.all('product_category')).property()
product_categories: (-> @store.peekAll('product_category')).property()
filter: null
sorted_product_categories: (->
list = @get('product_categories')
@@ -1,6 +1,6 @@
App.modals.AddSectionElementController = @App.modals.BaseController.extend
title_path: 'section_element.modal.title'
svg_elements: (-> @store.find 'svg_element').property()
svg_elements: (-> @store.findAll 'svg_element').property()
actions:
addSectionElement: (svg_element)->
section_element = @store.createRecord 'section-element'
@@ -18,7 +18,8 @@ App.modals.ProductCategoryMoveController = App.modals.BaseController.extend
@send 'close'
product_categories: (->
@store.all('product_category').filter( (pc) => pc.id isnt @get('model.id')).sortBy('position')
# do not return self, since place below should not include self option
@store.peekAll('product_category').rejectBy('id', @get('model.id')).sortBy('position')
).property('model.id')
sortableUpdate: (ids)->
@@ -2,7 +2,7 @@ App.modals.SelectEmployeeController = App.modals.BaseController.extend
employee: null
title_path: 'employee.select_modal.title'
employees: (-> @get('all_employees').filterBy('active') ).property('all_employees.@each.active')
all_employees: (-> @store.all('employee')).property()
all_employees: (-> @store.peekAll('employee')).property()
actions:
selectEmployee: (employee)->
@set 'employee', employee
@@ -1,7 +1,7 @@
App.OrdersDisplayController = Ember.Controller.extend
needs: ['application']
active_section: null
sections: (-> @store.all('section') ).property()
sections: (-> @store.peekAll('section') ).property()
orders: Ember.computed 'model.[]', 'active_section.id', ->
orders = @get('model').filterBy('needs_supplier_attention')
orders = orders.filterBy('section.id', id) if id = @get('active_section.id')
@@ -1,6 +1,6 @@
App.ScheduleController = Ember.Controller.extend
event_changed: (event)->
@store.find('employee-shift', event.id).then (employee_shift)->
@store.findRecord('employee-shift', event.id).then (employee_shift)->
employee_shift.set 'start_from', event.start
employee_shift.set 'end_on', event.end
employee_shift.save()
@@ -10,7 +10,7 @@ ControllerExtensions = Ember.Mixin.create
options.model ||= Ember.Object.create()
@send "openModal", name, options
all_sections: (-> @store.all('section')).property()
all_sections: (-> @store.peekAll('section')).property()
#current_employee: (-> @get('controllers.application.employee') ).property('controllers.application.employee')
Ember.Controller.reopen ControllerExtensions
@@ -14,7 +14,7 @@ DS.Model.reopen
DS.Model.reopenClass
findCached: (id)->
return null unless id
@store.all(@typeKey).findProperty('id', id)
@store.peekRecord(@typeKey, id)
updateOrAdd: (attributes)->
if cached = @findCached(attributes.id)
@@ -23,12 +23,12 @@ DS.Model.reopenClass
relation = relation[0]
if relation.kind == 'belongsTo'
if id = attributes["#{relation.name}_id"]
@store.find(relation.name, id).then (relation_object)->
@store.findAll(relation.name, id).then (relation_object)->
cached.set relation.name, relation_object
cached.setProperties attributes
cached
else
#@store.find(@, attributes.id)
#@store.findRecord(@, attributes.id)
@pushByAttriburtes(attributes)
pushByAttriburtes: (attributes, options = {})->
#store = @all().get('store')
@@ -58,7 +58,7 @@ DS.Model.reopenClass
#relation = relation[0]
#if relation.kind == 'belongsTo' and id = attributes["#{relation.name}_id"]
#attributes[relation.name] = id
#promises.push @store.find(relation.name, id)
#promises.push @store.findRecord(relation.name, id)
#association_names.push relation.name
#Ember.RSVP.all(promises).then (records)->
#for record, i in records
@@ -20,7 +20,7 @@ App.Router.map ->
@route 'menu'
@route 'settings'
@route 'schedule'
@route 'my_account'
@route 'my-account'
@route 'my-schedule'
@route 'empty'
#@resource 'lists', queryParams: ['state']
@@ -3,18 +3,18 @@ App.ApplicationRoute = Ember.Route.extend
# Preload only active lists and orders
@supplier = @store.push 'supplier', supplier_object
@employee = @store.push 'employee', employee_object
#@product_categories = @store.find 'product_category'
#@sections = @store.find 'section'
#@product_categories = @store.findAll 'product_category'
#@sections = @store.findAll '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
@store.findAll('list', state: 'active') #.then (lists) -> lists.invoke('get', 'table')
#@lists = @store.peekAll 'list'
# product_categories = controller.set 'product_categories', @store.peekAll('product_category')
#@store.findAll 'order', state: 'active' included in list
setupController: (controller)->
controller.set 'globals.current_supplier', @supplier
controller.set 'globals.current_employee', @employee
# @set 'supplier', @store.find('supplier', supplier_id)
# @set 'supplier', @store.findRecord('supplier', supplier_id)
#controller.set 'sections', @sections
#controller.set 'product_categories', @product_categories
@@ -79,7 +79,7 @@ App.ApplicationRoute = Ember.Route.extend
cancel: options.cancel
ok: options.ok
newOrder: (order_id)->
@store.findById('order', order_id).then (order)=>
@store.peekRecord('order', order_id).then (order)=>
controller = @controllerFor('application')
return if @get('globals.active_section.id') and order.get('section.id') isnt @get('globals.active_section.id')
$('body').addClass('new-order')
@@ -122,7 +122,7 @@ App.ApplicationRoute = Ember.Route.extend
@store.pushPayload('list', data)
# Fix broken reference. TODO: remove this when single source of
# truth is working
#@store.findById('list', data.list.id).then (list)->
#@store.peekRecord('list', data.list.id).then (list)->
# list.get('table').then (table)->table.set('active_list', list)
list_changed_table: (data) -> @store.pushPayload('list', lists: [data.list])
list_closed: (data) -> list.isClosed() if list = @store.getById('list', data.id)
@@ -1,5 +1,5 @@
App.EmployeesRoute = Ember.Route.extend
model: -> @store.all 'employee'
model: -> @store.peekAll 'employee'
actions:
newEmployee: ->
employee = @store.createRecord('employee')
@@ -7,15 +7,15 @@
# #lists: @store.filter 'list', (l)-> l.get('state') == 'active' # DOES NOT WORK!!!! (yet)
# # use filter to create a scope on all the records
# #lists: @store.filter 'list', -> true
# lists: @store.all 'list'
# # mayby @store.all 'list' will work better!!!! (2014-04-24 a more experienced benjamin :)
# lists: @store.peekAll 'list'
# # mayby @store.peekAll 'list' will work better!!!! (2014-04-24 a more experienced benjamin :)
# #orders: @store.filter 'order', -> true
# orders: @store.all 'order'
# sections: @store.all 'section'
# orders: @store.peekAll 'order'
# sections: @store.peekAll 'section'
# setupController: (controller, model)->
# controller.set('model', model)
# #$('#section_selector').on 'change', (-> controller.set('sectionId', $(this).val()))
# #controller.set 'lists', @store.all('list')
# #controller.set 'lists', @store.peekAll('list')
# #controller.set 'lists', App.List.all() #.filterProperty('state', 'active')
# #controller.set 'orders', App.Order.all()
# #controller.set 'lists', model.get('lists')
@@ -1,4 +1,4 @@
App.ListsIndexRoute = Ember.Route.extend
#model: -> @store.find 'list'
#model: -> @store.findAll 'list'
setupController: (controller, model)->
controller.set 'date', (new Date()).toISOString().substr(0,10) unless controller.get('date')
@@ -1,2 +1,2 @@
App.OrdersDisplayRoute = Ember.Route.extend
model: -> @store.all('order')
model: -> @store.peekAll('order')
@@ -1,4 +1,4 @@
App.SectionRoute = Ember.Route.extend
model: (params) -> @store.findById 'section', params.section_id
model: (params) -> @store.peekRecord 'section', params.section_id
renderTemplate: ->
@render 'section'
@@ -1,8 +1,8 @@
App.SectionsRoute = Ember.Route.extend
beforeModel: ->
@store.find 'section-element'
@store.find 'section-area'
model: -> @store.all 'section'
@store.findAll 'section-element'
@store.findAll 'section-area'
model: -> @store.peekAll 'section'
# setupController: (controller, collection) ->
# controller.set 'content', collection
@@ -1,2 +1,2 @@
App.TablesIndexRoute = Ember.Route.extend
model: -> @store.all('table')
model: -> @store.peekAll('table')
@@ -3,6 +3,5 @@ if gravatar
else
span.dropdown-trigger.button.tiny.dropdown
span.dropdown-trigger-text= view.title
/span.dropdown-trigger-icon
.dropdown-list-container
= yield
@@ -3,32 +3,37 @@
li.title: h3= globals.current_supplier.name
li
= link-to 'index'
span.fa.fa-list-alt
span.icon.dashboard
= t 'dashboard.title'
li
= link-to 'menu'
span.fa.fa-coffee
span.icon.menu
= t 'top_menu.menu'
li
= link-to 'sections'
span.fa.fa-th-large
span.icon.sections
= t 'models.plural.section'
li
= link-to 'tables'
span.fa.fa-square-o
span.icon.tables
= t 'models.plural.table'
li
= link-to 'employees'
span.fa.fa-users
= t 'models.plural.employee'
= link-to 'lists'
span.icon.lists
= t 'models.plural.list'
can "manage" "employees"
li
= link-to 'employees'
span.icon.employees
= t 'models.plural.employee'
li
= link-to 'schedule'
span.fa.fa-calendar
span.icon.schedule
= t 'top_menu.schedule'
can "manage" globals.current_supplier
li
=link-to 'settings' class="supplier-settings-link"
span.settings-icon
span.icon.settings
span= t 'supplier.settings'
if globals.current_supplier.open
li: a.supplier-close-shop{action "markSupplierClosed"}= t 'supplier.close_for_orders'
@@ -6,32 +6,34 @@ header.top-menu
= link-to 'index' class="top-menu-root"
= image_tag "icons/logo-small.png"
= link-to "menu" class="top-menu-menu"
span.icon.menu
= t 'top_menu.menu'
= link-to "sections" class="top-menu-sections"
span.icon.sections
= t 'models.plural.section'
= link-to "tables" class="top-menu-tables"
span.icon.tables
= t 'models.plural.table'
= link-to "lists" class="top-menu-lists"
span.icon.lists
= t 'models.plural.list'
= link-to "employees" class="top-menu-employees"
= t 'models.plural.employee'
can "manage" "employees"
= link-to "employees" class="top-menu-employees"
span.icon.employees
= t 'models.plural.employee'
= link-to "schedule" class="top-menu-schedule"
span.icon.schedule
= t 'top_menu.schedule'
= dropdown-link gravatar=globals.current_employee.email class="current-employee-nav"
ul
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'
if globals.current_supplier.open
/a.supplier-is-closed-indication.is-open{ action "markSupplierClosed" }: span.fa.fa-beer.fa-2x
a.supplier-availability.currently-open{ action "markSupplierClosed" }: span Open
else
a.supplier-availability.currently-closed{ action "markSupplierOpen" }: span Closed
/a.supplier-is-closed-indication.is-closed{ action "markSupplierOpen" }
/span.fa-stack.fa-lg
/i.fa.fa-beer.fa-stack-1x
/i.fa.fa-ban.fa-stack-2x.text-alert
.supplier-name= globals.current_supplier.name
.extra-info{action "showSupplierStatusInfo"}
.supplier-info-row
@@ -1,2 +1,3 @@
.row: .small-12.columns
h2= t 'schedule.title' globals.current_supplier
#schedule-placeholder
@@ -18,8 +18,8 @@
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{action "addSectionElement"}: span.section-add-section-element-icon= t 'section_element.add_button'
li: a{action "addSectionArea"}: span.section-add-section-area-icon= t 'section_area.add_button'
li: a{action "addSectionElement"}: span.icon.section-elements= t 'section_element.add_button'
li: a{action "addSectionArea"}: span.icon.section-areas= t 'section_area.add_button'
li= qr-codes-link section=content: span.qr-icon= t 'table.print_qr_codes'
li: a.section-destroy{action "destroySection"}: span.section-remove-icon=t 'helpers.links.destroy'
a.section-normal-mode-button{ action "finishEditable" }: span
@@ -8,7 +8,7 @@ App.MyScheduleView = Ember.View.extend
header:
left: 'prev,next,today'
center: 'title'
right: 'month,agendaWeek,agendaDay'
right: 'agendaDay,agendaWeek,month'
selectable: false
#selectHelper: true
#select: (start, end)=>
@@ -4,14 +4,40 @@ App.ScheduleView = Ember.View.extend
placeholder = @$('#schedule-placeholder')
controller = @get('controller')
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
editable = !!controller.get('globals.current_employee.manager')
fullCalendarOptions =
header:
left: 'prev,next,today'
center: 'title'
right: 'month,agendaWeek,agendaDay'
selectable: true
selectHelper: true
select: (start, end)=>
right: 'agendaDay,agendaWeek,month'
selectable: editable
selectHelper: editable
editable: editable
defaultView: 'agendaWeek'
events: events
timezone: 'UTC'
eventDrop: controller.event_changed.bind(controller)
eventResize: controller.event_changed.bind(controller)
dayClick: (date, jsEvent, view)->
jsEvent.preventDefault()
if view.type is 'month'
placeholder.fullCalendar('changeView', 'agendaDay')
placeholder.fullCalendar('gotoDate', date)
false
eventClick: (event)->
return unless editable
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()
if editable
fullCalendarOptions.select = (start, end, jsEvent, view) =>
return if view.type is 'month'
format = 'dddd h:mm'
controller.modal 'select_employee',
ok: ->
@@ -22,22 +48,5 @@ App.ScheduleView = Ember.View.extend
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()
placeholder.fullCalendar fullCalendarOptions
@@ -1,14 +1,14 @@
App.SideMenuItemView = Ember.View.extend
classNames: 'menu-list-item'
classNameBindings: ['active']
click: ->
if @route_param
@get('controller').transitionToRoute(@route, @route_param)
else
@get('controller').transitionToRoute(@route)
active: (->
if @get('controller.currentPath') == @route then 'active' else ''
).property('controller.currentPath')
init: ->
@templateName = "side_menu/#{@route}"
@_super()
#App.SideMenuItemView = Ember.View.extend
#classNames: 'menu-list-item'
#classNameBindings: ['active']
#click: ->
#if @route_param
#@get('controller').transitionToRoute(@route, @route_param)
#else
#@get('controller').transitionToRoute(@route)
#active: (->
#if @get('controller.currentPath') == @route then 'active' else ''
#).property('controller.currentPath')
#init: ->
#@templateName = "side_menu/#{@route}"
#@_super()
@@ -14,6 +14,7 @@
errors: <%= I18n.t('errors', locale: :nl).to_json %>
date: <%= {day_name: Hash[Date::DAYNAMES.map(&:downcase).zip(I18n.t('date.day_names', locale: :nl))]}.to_json %>
@day_minutes_to_time = (minutes)->
return "" unless minutes
[("0" + Math.floor(minutes/60)).substr(-2,2), ("0" + Math.floor(minutes%60)).substr(-2,2)].join(":")
@@ -28,7 +28,7 @@
span= t 'models.plural.list'
li
=link-to 'settings'
span.settings-icon
span.icon.settings
span= t 'settings.title'
li
=link-to 'about' class="side-menu-about"