Dynamic pages, language switcher and fix schedule drag drop time mismatch bug

This commit is contained in:
2015-02-21 15:05:45 +01:00
parent e60955130a
commit c8109c8ad6
29 changed files with 163 additions and 40 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

@@ -5,3 +5,29 @@
store: -> @__container__.lookup('controller:application').store
@App.modals = Ember.Namespace.create()
@Modals = @App.modals
Ember.$.ajaxPrefilter (options) ->
locale = $locale
app_version = 0
params =
locale: $locale
app_version: 0
if options.type.toUpperCase() == 'GET'
if options.data
options.data += "&#{$.param(params)}"
else
options.data = $.param(params)
if options.type.toUpperCase() == 'POST'
if options.data
if typeof(options.data) == 'string'
if options.data[0] == '{' || options.data[0] == '[' # json
object = JSON.parse(options.data)
$.extend object, params
options.data = JSON.stringify(object)
else
options.data += "&#{$.param(params)}"
else
options.data = params
else
options.data = $.param(params)
true
@@ -0,0 +1,7 @@
App.LanguageSwitcherComponent = Ember.Component.extend
classNames: ['language-switcher-container']
locales: (-> ['en', 'nl']).property()
actions:
switchTo: (locale)->
setLocale locale
@get('targetObject.store').all("page").invoke 'reload'
@@ -1,8 +1,8 @@
App.ScheduleController = Ember.ArrayController.extend
event_changed: (event)->
@store.find('employee-shift', event.id).then (employee_shift)->
employee_shift.set 'start_from', event.start.toDate()
employee_shift.set 'end_on', event.end.toDate()
employee_shift.set 'start_from', event.start
employee_shift.set 'end_on', event.end
employee_shift.save()
editEvent: (id, callbacks)->
if employee_shift = @store.all('employee-shift').findBy('id', id)
@@ -0,0 +1,2 @@
Ember.Handlebars.helper 'flag', (locale, options)->
"<img src=\"#{$assets_path}supplier/flags/flag-#{locale}.png\">".htmlSafe()
@@ -0,0 +1,4 @@
Ember.Handlebars.registerHelper 'page-body-helper', (resource, params..., options)->
body = @get resource
template = Ember.Handlebars.compile('body')
body.htmlSafe()
@@ -0,0 +1,4 @@
attr = DS.attr
App.Page = DS.Model.extend
title: attr 'string'
body: attr 'string'
@@ -14,6 +14,8 @@ App.Router.map ->
@resource 'list', path: ':list_id'
@resource 'employees', ->
@resource 'employee', path: ':employee_id'
@resource 'pages', ->
@resource 'page', path: ':page_id'
@route 'orders_display' # chromecast etc
@route 'menu'
@route 'settings'
@@ -0,0 +1,2 @@
each locale in locales
a.language-switch-button{ action "switchTo" locale}= flag locale
@@ -0,0 +1,4 @@
.row: .small-12.columns
h2=model.title
/= page-body model.body
view page-body templateBody=model.body
@@ -36,6 +36,7 @@ if editIensProfile
App.NumberField valueBinding="controller.model.iens_profile"
= image_tag 'supplier/settings/iens-example.png'
span=t "settings.reviews.explanation"
.row: .small-12.columns= language-switcher
.form-row.form-actions
if saving
button.button.submit-supplier-settings.disabled
@@ -0,0 +1,11 @@
App.PageBodyView = Ember.View.extend
setTemplate: (->
body = @get('templateBody')
body ||= ""
try
template = Ember.Handlebars.compile(body)
catch
template = Ember.Handlebars.compile(tspan('page.cannot_compile'))
@set 'template', template
@rerender()
).on('init').observes('templateBody')
@@ -25,6 +25,7 @@ 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',
@@ -1,21 +0,0 @@
class List
constructor: (@attributes)->
id: -> @attributes.id || @attributes._id
table_number: -> @attributes.table_number
total_amount: -> @attributes.total_amount
section_title: -> @attributes.section_title
needs_help: -> @attributes.needs_help
needs_payment: -> @attributes.needs_payment
active: -> @attributes.state == 'active'
table_id: -> @attributes.table_id
products: -> @attributes.products || []
has_active_orders: -> @attributes.has_active_orders
supplier_name: -> @attributes.supplier_name
created_at: -> @attributes.created_at
display: ->
txt = @supplier_name()
txt += ' - '
txt += Quser.format_date(@created_at())
txt
@List = List
@@ -1,17 +0,0 @@
class Order
constructor: (@attributes)->
table_number: -> @attributes.table_number
id: -> @attributes.id || @attributes._id
total_amount: -> @attributes.total_amount
section_title: -> @attributes.section_title
list_id: -> @attributes.list_id
state: -> @attributes.state
display: ->
order_txts = []
return '' unless @attributes.products
for product in @attributes.products
order_txts.push(product.name + ' (' + product.number + ')')
order_txts.join(', ')
can_process: -> @attributes.state == 'placed'
@Order = Order
@@ -0,0 +1,5 @@
.language-switcher-container
.language-switch-button
+button($bg: $secondary-color, $padding: $button-tny)
margin: 0
margin-right: 8px