All the little details
This commit is contained in:
@@ -2,7 +2,14 @@ App.SectionsHeaderComponent = Ember.Component.extend
|
||||
sections: (-> @get('targetObject.store').all('section') ).property()
|
||||
actions:
|
||||
setSection: (section)->
|
||||
if section and section is @get('section')
|
||||
# click on already active section
|
||||
#return @transitionTo('section', section.id)
|
||||
return App.Router.router.transitionTo('section', section)
|
||||
@$('dd').removeClass('active')
|
||||
@$("[data-section=#{if section then section.id else 'all'}]").addClass('active')
|
||||
@set('section', section)
|
||||
didInsertElement: -> @send("setSection", @get('section'))
|
||||
didInsertElement: ->
|
||||
@$('dd').removeClass('active')
|
||||
section = @get('section')
|
||||
@$("[data-section=#{if section then section.id else 'all'}]").addClass('active')
|
||||
|
||||
@@ -19,12 +19,6 @@ App.ApplicationController = Ember.Controller.extend
|
||||
actions:
|
||||
signOut: ->
|
||||
window.location = Routes.destroy_employee_session_path()
|
||||
markSupplierClosed: ->
|
||||
return unless supplier = @get('supplier')
|
||||
supplier.close()
|
||||
markSupplierOpen: ->
|
||||
return unless supplier = @get('supplier')
|
||||
supplier.open_the_place()
|
||||
showSupplierStatusInfo: ->
|
||||
@modal 'supplier_status_info',
|
||||
model: @get('supplier')
|
||||
|
||||
@@ -5,15 +5,15 @@ App.IndexController = Ember.ObjectController.extend
|
||||
lists: (-> @store.all('list')).property()
|
||||
orders: (-> @store.all('order')).property()
|
||||
sections: (-> @store.all('section')).property()
|
||||
active_section: Ember.computed.alias 'controllers.application.active_section'
|
||||
active_lists: (->
|
||||
if @get('controllers.application.active_section.id')
|
||||
lists = @get('lists').filter (l)=>( l.get('section.id') == @get('controllers.application.active_section.id') && l.get('state') == 'active' )
|
||||
if section_id = @get('active_section.id')
|
||||
lists = @get('lists').filter (l)=>( l.get('section.id') == section_id && l.get('state') == 'active' )
|
||||
else
|
||||
lists = @get('lists').filterProperty('state', 'active')
|
||||
lists.sortBy('created_at') # Not reversed, oldest on top, start with oldest order first :-) Customer happyness
|
||||
).property('lists.@each.state', 'controllers.application.active_section.id')
|
||||
).property('lists.@each.state', 'active_section.id')
|
||||
|
||||
active_section: (-> @get('controllers.application.active_section')).property('controllers.application.active_section')
|
||||
active_orders: (->
|
||||
if @get('active_section.id')
|
||||
orders = @get('orders').filter (o)=>( o.get('section.id') == @get('active_section.id') && o.get('needs_supplier_attention') )
|
||||
|
||||
@@ -9,9 +9,10 @@
|
||||
if model = @get('model')
|
||||
translation_params = model.serialize() if model.serialize
|
||||
|
||||
return tspan(@title_path, translation_params).htmlSafe() if @title_path
|
||||
# return translated title_path if directly set by options
|
||||
return tspan(@get('modal_options.title_path'), translation_params).htmlSafe() if @get('modal_options.title_path')
|
||||
# return translated title_path if directly set by controller
|
||||
return tspan(@title_path, translation_params).htmlSafe() if @title_path
|
||||
# infer title path based on controller name App.modals.AddSectionController => add_section
|
||||
underscored = `this.constructor.toString().substr(11).replace(/Controller$/, '').underscore()`
|
||||
# find translated title or humanize the controller name
|
||||
@@ -19,7 +20,7 @@
|
||||
tspan(@get("modal.#{underscored}.title"), translation_params).htmlSafe()
|
||||
else
|
||||
underscored.capitalize().replace(/_/, ' ')
|
||||
).property('model.id')
|
||||
).property('model.id', 'modal_options.title_path')
|
||||
save_error: (error)->
|
||||
switch error.status
|
||||
when 403
|
||||
@@ -27,6 +28,8 @@
|
||||
else
|
||||
@set 'alert_message', 'Something went wrong'
|
||||
save_success: ->
|
||||
if save_callback = @get('modal_options.save')
|
||||
save_callback.apply(@)
|
||||
@set 'alert_message', ''
|
||||
@send 'closeModal'
|
||||
|
||||
@@ -53,9 +56,12 @@
|
||||
@get('model').save().then @save_success.bind(@), @save_error.bind(@)
|
||||
#@send 'closeModal' unless @preventClose
|
||||
destroy: ->
|
||||
my_scope = @
|
||||
destroy_callback = @get('modal_options.destroy')
|
||||
@modal 'confirm',
|
||||
title_path: @get('modal_options.destroy_text_path') || 'general.destroy.text'
|
||||
model: @get('model')
|
||||
ok: ->
|
||||
@get('model').destroyRecord()
|
||||
destroy_callback.call(my_scope) if destroy_callback
|
||||
@send 'closeModal' unless @preventClose
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
App.modals.SelectEmployeeController = App.modals.BaseController.extend
|
||||
employee: null
|
||||
employees: (-> @store.all 'employee').property()
|
||||
title_path: 'employee.select_modal.title'
|
||||
employees: (-> @store.all('employee').filterBy('active') ).property()
|
||||
actions:
|
||||
selectEmployee: (employee)->
|
||||
@set 'employee', employee
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
App.ScheduleController = Ember.ArrayController.extend
|
||||
event_changed: (event)->
|
||||
@store.find('employee-shift', event.id).then (employee_shift)->
|
||||
employee_shift.set 'start_on', event.start.toDate()
|
||||
employee_shift.set 'start_from', event.start.toDate()
|
||||
employee_shift.set 'end_on', event.end.toDate()
|
||||
employee_shift.save()
|
||||
editEvent: (id, callbacks)->
|
||||
if employee_shift = @store.all('employee-shift').findBy('id', id)
|
||||
@modal 'employee_shift',
|
||||
title_path: 'employee_shift.modal.title'
|
||||
destroy_text_path: 'employee_shift.modal.destroy_confirmation'
|
||||
model: employee_shift
|
||||
save: -> callbacks.save.call(@, employee_shift) if callbacks.save
|
||||
destroy: -> callbacks.destroy.call(@, employee_shift) if callbacks.destroy
|
||||
|
||||
@@ -9,9 +9,6 @@ App.SectionsIndexController = Ember.ArrayController.extend
|
||||
qrPath: (section_id)->
|
||||
Routes.qr_codes_suppliers_tables_path section_id: section_id
|
||||
actions:
|
||||
showDashboardOrders: (section)->
|
||||
@set 'controllers.application.active_section', section
|
||||
@transitionToRoute('index')
|
||||
addSection: -> @modal 'add_section', model: @get('model')
|
||||
goToSection: (section)->
|
||||
@set 'controllers.application.active_section', section
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
App.MomentTransform = DS.Transform.extend
|
||||
deserialize: (serialized)->
|
||||
return serialized unless serialized
|
||||
m = moment(serialized)
|
||||
m._ambigTime = true if serialized.length < 11
|
||||
m
|
||||
|
||||
serialize: (deserialized)->
|
||||
return deserialized unless deserialized
|
||||
deserialized = moment(deserialized) unless deserialized._isAMomentObject
|
||||
deserialized.toISOString()
|
||||
@@ -1,12 +1,19 @@
|
||||
attr = DS.attr
|
||||
App.EmployeeShift = DS.Model.extend
|
||||
start_on: attr('date')
|
||||
end_on: attr('date')
|
||||
start_from: attr('moment')
|
||||
end_on: attr('moment')
|
||||
employee: DS.belongsTo 'employee'
|
||||
description: attr('string')
|
||||
calendar_event: (->
|
||||
id: @id
|
||||
title: @get('employee.name')
|
||||
start: @get('start_on')
|
||||
title: @get('title')
|
||||
start: @get('start_from')
|
||||
end: @get('end_on')
|
||||
color: @get('employee.color')
|
||||
).property('start_on', 'end_on')
|
||||
).property('start_from', 'end_on', 'title')
|
||||
|
||||
title: Ember.computed 'employee.name', 'description', ->
|
||||
if @get('description')
|
||||
[@get('employee.name'), @get('description')].join(' - ')
|
||||
else
|
||||
@get 'employee.name'
|
||||
|
||||
@@ -54,7 +54,8 @@ App.ApplicationRoute = Ember.Route.extend
|
||||
defaultModalOptions =
|
||||
closeOnOverlay: true
|
||||
closeOnModalClick: false
|
||||
controller.set 'modal_options', $.extend(defaultModalOptions, options)
|
||||
modal_options = Ember.Object.create($.extend(defaultModalOptions, options))
|
||||
controller.set 'modal_options', modal_options
|
||||
@render "modals/#{modalName}",
|
||||
into: 'application'
|
||||
outlet: 'modal'
|
||||
@@ -80,6 +81,19 @@ App.ApplicationRoute = Ember.Route.extend
|
||||
controller.set 'flash_message', order.get('display_with_table')
|
||||
setTimeout (-> $('body').removeClass('new-order')), 4000
|
||||
try ion.sound.play('water_droplet')
|
||||
showDashboardOrders: (section)->
|
||||
@controllerFor('application').set 'active_section', section
|
||||
@transitionTo 'index'
|
||||
markSupplierClosed: ->
|
||||
controller = @controllerFor('application')
|
||||
return unless supplier = controller.get('supplier')
|
||||
controller.modal 'confirm',
|
||||
title_path: 'supplier.close_for_orders_confirmation'
|
||||
model: supplier
|
||||
ok: -> supplier.close()
|
||||
markSupplierOpen: ->
|
||||
return unless supplier = @controllerFor('application').get('supplier')
|
||||
supplier.open_the_place()
|
||||
events:
|
||||
list_needs_help: (data) ->
|
||||
if list = @store.getById('list', data.id)
|
||||
|
||||
@@ -3,5 +3,5 @@ dl.sections-header-container.sub-nav
|
||||
each s in sections
|
||||
dd data-section=s.id
|
||||
a.section-header-title{action "setSection" s} href="#" = s.title
|
||||
= link-to "section" s.id class="section-jumper"
|
||||
/= link-to "section" s.id class="section-jumper"
|
||||
span.fa.fa-chevron-circle-right
|
||||
|
||||
@@ -6,7 +6,7 @@ header.top-menu
|
||||
= link-to 'index' class="top-menu-root"
|
||||
= image_tag "icons/logo-small.png"
|
||||
= link-to "menu" class="top-menu-menu"
|
||||
= t 'supplier.top_menu.menu'
|
||||
= t 'top_menu.menu'
|
||||
= link-to "sections" class="top-menu-sections"
|
||||
= t 'models.plural.section'
|
||||
= link-to "tables" class="top-menu-tables"
|
||||
@@ -16,7 +16,14 @@ header.top-menu
|
||||
= link-to "employees" class="top-menu-employees"
|
||||
= t 'models.plural.employee'
|
||||
= link-to "schedule" class="top-menu-schedule"
|
||||
= t 'supplier.top_menu.schedule'
|
||||
= t 'top_menu.schedule'
|
||||
if supplier.open
|
||||
a.supplier-is-closed-indication.is-open{ action "markSupplierClosed" }: span.fa.fa-beer.fa-2x
|
||||
else
|
||||
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
|
||||
.extra-info{action "showSupplierStatusInfo"}
|
||||
.supplier-info-row
|
||||
.counter.supplier-orders-placed-count
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
.row: .small-12.columns
|
||||
= sections-header sectionBinding="controller.controllers.application.active_section"
|
||||
unless controllers.application.supplier.open
|
||||
.alert-box.alert.radius data-alert=true
|
||||
= t 'supplier.you_are_currently_closed_alert'
|
||||
a{ action "markSupplierOpen" }= t 'supplier.open_for_orders'
|
||||
.page-header
|
||||
div.dashboard-section-selection
|
||||
/App.HomeSectionSelectorView selectionBinding="controller.controllers.application.active_section" content=controller.sections prompt=controllers.application.supplier.name
|
||||
|
||||
@@ -6,7 +6,7 @@ p=t 'employee.modal.body_header'
|
||||
= errors model.errors.name
|
||||
.form-row.name
|
||||
.form-label=t 'attributes.employee.email'
|
||||
.form-field
|
||||
.form-field.half
|
||||
= input type="email" valueBinding="model.email" action="save"
|
||||
= errors model.errors.email
|
||||
if isNotSelf
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
p=t 'employee_shift.modal.body_header'
|
||||
.form-row.name
|
||||
.form-label= t 'models.employee'
|
||||
.form-field= model.employee.name
|
||||
.form-row.description
|
||||
.form-label=t 'attributes.employee_shift.description'
|
||||
.form-field
|
||||
= input valueBinding="model.description"
|
||||
= errors model.errors.description
|
||||
hr
|
||||
button.modal-close{action "close"}=t 'employee_shift.modal.close_button'
|
||||
button.modal-confirm.right{action "save"} disabled=model.isInvalid
|
||||
=t 'employee_shift.modal.save_button'
|
||||
button.modal-destroy.right{action "destroy"}
|
||||
=t 'employee_shift.modal.destroy_button'
|
||||
@@ -4,14 +4,9 @@
|
||||
= view "section-tab-header" context=section
|
||||
can manage sections
|
||||
a.add-section{action "addSection"}: span
|
||||
can manage sections
|
||||
.section-manage-tables.pull-right
|
||||
App.DropdownLink title="Action"
|
||||
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 href="{{route 'qr_codes_suppliers_tables_path' section_id=id}}" target="_blank": span.qr-icon=t 'table.print_qr_codes'
|
||||
li: a.section-destroy{action "destroySection"}: span.section-remove-icon=t 'helpers.links.destroy'
|
||||
.section-manage-tables.pull-right
|
||||
a.go-to-orders-list{ action "showDashboardOrders" model }: span
|
||||
can manage sections
|
||||
if editmode
|
||||
= input type="text" valueBinding="title" class="section-edit-title-field"
|
||||
App.NumberField valueBinding="width" class="dimension section-edit-width-field"
|
||||
@@ -20,6 +15,12 @@ can manage sections
|
||||
a.section-rollback-button{ action "rollbackEditable" }: span
|
||||
a.section-normal-mode-button{ action "finishEditable" }: span
|
||||
else
|
||||
App.DropdownLink title="Action"
|
||||
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 href="{{route 'qr_codes_suppliers_tables_path' section_id=id}}" target="_blank": span.qr-icon=t 'table.print_qr_codes'
|
||||
li: a.section-destroy{action "destroySection"}: span.section-remove-icon=t 'helpers.links.destroy'
|
||||
a.section-edit-mode-button{ action "makeEditable" }: span
|
||||
= view "section-tables" contentBinding="tables"
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
/td.currency=currency list.price
|
||||
/td.timestamp=time list.created_at
|
||||
td.actions
|
||||
a.section-dashboard-orders{action showDashboardOrders section}: span
|
||||
a.section-dashboard-orders.go-to-orders-list{action "showDashboardOrders" section}: span
|
||||
a.table-qr-codes{path qr_codes_suppliers_tables section_id=section.id} target="_blank": span.qr-icon
|
||||
else
|
||||
.row: .small-12.columns
|
||||
|
||||
@@ -16,15 +16,22 @@ App.ScheduleView = Ember.View.extend
|
||||
ok: ->
|
||||
# this context is SelectEmployeeController
|
||||
if employee = @get('employee')
|
||||
shift = controller.store.createRecord 'employee-shift', start_on: start.toDate(), end_on: end.toDate()
|
||||
shift = controller.store.createRecord 'employee-shift', start_from: start, end_on: end
|
||||
shift.set 'employee', employee
|
||||
shift.save()
|
||||
placeholder.fullCalendar('renderEvent', shift.get('calendar_event'), true)
|
||||
shift.save().then ->
|
||||
placeholder.fullCalendar('renderEvent', shift.get('calendar_event'), true)
|
||||
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])
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,14 @@ App.SectionTablesView = Ember.View.extend DragNDrop.Droppable,
|
||||
@$el = $(@get('element'))
|
||||
width = @$el.width()
|
||||
height = width * @get('controller.model.height') / @get('controller.model.width')
|
||||
viewport_height = $(window).height() - 52
|
||||
if height > viewport_height
|
||||
# Fit screen
|
||||
correction = viewport_height / height
|
||||
width = correction * width
|
||||
@$el.css('width', width)
|
||||
height = correction * height
|
||||
|
||||
@set 'element_width', width
|
||||
@set 'element_height', height
|
||||
@$el.css('height', height)
|
||||
|
||||
@@ -25,7 +25,6 @@ String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() +
|
||||
window.time_zones = <%= ActiveSupport::TimeZone.all.map{|tz| {name: tz.name, formatted: "GMT#{tz.formatted_offset} #{tz.name}"}}.to_json.html_safe %>;
|
||||
window.countries = <%= IsoCountryCodes.all.map{|cc| {name: cc.name}}.to_json.html_safe %>;
|
||||
|
||||
|
||||
var path_mapping = {
|
||||
user_root: '/user',
|
||||
join_occupied_table: '/user/join_occupied_table',
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
@ttry = (path, vars={})->
|
||||
@t(path, $.extend(vars, emptyWhenNotFound: true))
|
||||
|
||||
|
||||
# return translation in the form
|
||||
# <span data-t="models.table">Tafel</span>
|
||||
@tspan = (path, vars={}) -> "<span data-t='#{path}' data-t-attributes='#{JSON.stringify(vars)}'>#{t(path, vars)}</span>"
|
||||
@@ -39,8 +40,11 @@
|
||||
try
|
||||
result = result[part] for part in parts
|
||||
catch err
|
||||
console.log "[TRANSLATION] Cannot find translation: #{path}"
|
||||
result = parts[parts.length - 1].capitalize()
|
||||
result = if vars.emptyWhenNotFound then "" else parts[parts.length - 1].capitalize()
|
||||
unless result?
|
||||
console.log "[TRANSLATION] Cannot find translation: #{path}"
|
||||
return "" if result is ""
|
||||
return parts[parts.length - 1].capitalize() unless result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user