End of week commit

This commit is contained in:
2014-04-18 20:38:13 +02:00
parent 2a5331471c
commit 821f59b761
42 changed files with 304 additions and 91 deletions
@@ -0,0 +1,3 @@
Ember.Handlebars.registerBoundHelper 'boolean', (truefalse, options={})->
classname = if truefalse then 'boolean-true' else 'boolean-false'
new Handlebars.SafeString("<span class=\"#{classname}\"></span>")
@@ -0,0 +1,3 @@
Ember.Handlebars.registerBoundHelper 'state', (subject, state, options={})->
path = "state.#{subject}.#{state}"
new Handlebars.SafeString("<span data-t=\"#{path}\">#{t(path)}</span>")
@@ -0,0 +1,4 @@
Qsupplier.App.ListsController = Ember.ArrayController.extend
dateChanged: (->
@set('model', @store.find('list', date: @get('date')))
).observes('date')
@@ -1,5 +1,5 @@
Qsupplier.App.SectionController = Ember.ObjectController.extend
needs: ['application']
needs: ['application', 'sections', 'section'] #wtf? section, otherwise an Ember error
editmode: false
makeEditable: -> @set('editmode', true)
finishEditable: ->
@@ -14,3 +14,4 @@ Qsupplier.App.SectionController = Ember.ObjectController.extend
closeList: (list)-> list.close() if list
textures: ['wood1', 'wood2']
sections: (-> @get('controllers.sections.model')).property('controllers.sections.model')
@@ -1,2 +1,2 @@
Qsupplier.App.SectionsController = Ember.ArrayController.extend
needs: ['application', 'section']
needs: ['application']
@@ -0,0 +1,10 @@
Qsupplier.App.SectionsIndexController = Ember.ArrayController.extend
needs: ['application', 'sections']
sections: (-> @get('controllers.sections.model')).property('controllers.sections.model')
sectionQrCodesUrl: ((a,b,c)->
debugger
Routes.qr_codes_suppliers_tables_path()
).property()
newPath: Routes.new_suppliers_section_path()
qrPath: (section_id)->
Routes.qr_codes_suppliers_tables_path section_id: section_id
@@ -0,0 +1,12 @@
Ember.Handlebars.registerHelper 'path', (route, params..., options)->
route_method = Routes["#{route}_path"]
throw "Route #{route} cannout be found" unless route_method
mapped_options = {}
for k, v of options.hash
mapped_options[k] = Ember.Handlebars.get(this, v, options) || v
params.push mapped_options
path = route_method.apply(this, params)
new Handlebars.SafeString("href='#{path}'")
@@ -7,6 +7,7 @@ Qsupplier.App.List = DS.Model.extend
is_paid: attr 'boolean'
has_active_orders: attr 'boolean'
price: attr 'number'
closed_at: DS.attr('date')
table_number: attr 'number'
table: DS.belongsTo('table', inverse: 'active_list')
#users: DS.hasMany('user', inverse: 'active_list')
@@ -1,6 +1,6 @@
DS.Model.reopen
created_at: DS.attr('string')
updated_at: DS.attr('string')
created_at: DS.attr('date')
updated_at: DS.attr('date')
DS.Model.reopenClass
findCached: (id)->
return null unless id
@@ -8,4 +8,6 @@ Qsupplier.App.Router.map ->
@route '/', queryParams: ['section_id']
@resource 'sections', ->
@resource 'section', path: ':section_id'
@resource 'lists', ->
@resource 'list', path: ':list_id'
#@resource 'lists', queryParams: ['state']
@@ -0,0 +1,4 @@
Qsupplier.App.ListsRoute = Ember.Route.extend
#model: -> @store.find 'list'
setupController: (controller, model)->
controller.set 'date', (new Date()).toISOString().substr(0,10)
@@ -0,0 +1,26 @@
h1=t 'models.plural.list'
Qsupplier.App.ListDisplayDateSelector valueBinding=date
if controller.model
table.table
thead
tr
th.state=t 'attributes.list.state'
th.boolean=t 'attributes.list.needs_help'
th.boolean=t 'attributes.list.needs_payment'
th.timestamp=t 'attributes.list.closed_at'
th.table_number=t 'models.table'
th.currentcy=t 'attributes.list.price'
th.timestamp=t 'attributes.list.created_at'
tbody
each list in controller
tr
td.state=state 'list' list.state
td.boolean.needs_help=boolean list.needs_help
td.boolean.needs_payment=boolean list.needs_payment
td.timestamp=time list.closed_at
td.table_number 7
td.currency=currency list.price
td.timestamp=time list.created_at
else
.row
.panel=t 'list.none_found'
@@ -1,3 +1,7 @@
.section-tabs-container
link-to 'sections' | b
each section in sections
view Qsupplier.App.SectionTabHeaderView context=section
.section-manage-tables.pull-right
if editmode
.btn-group
@@ -1,4 +1 @@
.section-tabs-container
each section in controller
view Qsupplier.App.SectionTabHeaderView context=section
= outlet
@@ -0,0 +1,40 @@
h1=t 'models.plural.section'
if sections
table.table
thead
tr
th=t 'attributes.section.title'
th=t 'models.plural.table'
th.numeric=t 'attributes.section.width'
th.numeric=t 'attributes.section.height'
/th.boolean=t 'attributes.list.needs_help'
/th.boolean=t 'attributes.list.needs_payment'
/th.timestamp=t 'attributes.list.closed_at'
/th.table_number=t 'models.table'
/th.currentcy=t 'attributes.list.price'
/th.timestamp=t 'attributes.list.created_at'
th.actions=t 'helpers.actions.title'
tbody
each section in sections
tr
td
link-to 'section' section
=section.title
td
span.table-count= section.tables.length
td.numeric= section.width
td.numeric= section.height
/td.boolean.needs_help=boolean list.needs_help
/td.boolean.needs_payment=boolean list.needs_payment
/td.timestamp=time list.closed_at
/td.table_number 7
/td.currency=currency list.price
/td.timestamp=time list.created_at
td.actions
a.table-qr-codes{path qr_codes_suppliers_tables section_id=section.id}
span
else
.row
.panel=t 'section.none_found'
.form-actions
a.form-action-new{path new_suppliers_section}=t 'helpers.links.new'
@@ -0,0 +1,4 @@
Qsupplier.App.ListDisplayDateSelector = Ember.TextField.extend
classNames: 'datepicker'
didInsertElement: ->
setTranslations @$().hide()
@@ -17,9 +17,11 @@ var Qstorage = localStorage;
$.extend($translations.en, <%= I18n.t('supplier', locale: :en).to_json %>);
$.extend($translations.nl, <%= I18n.t('supplier', locale: :nl).to_json %>);
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
var path_mapping = {
user_root: '/user',
join_occupied_table: '/user/join_occupied_table',
@@ -126,6 +126,9 @@ $ ->
menu.show().animate left: 0
toggle.animate left: 222 - 30, -> $(@).addClass('open')
$('[data-boolean]').each ->
$(@).addClass(if $(@).data('boolean') then 'boolean-true' else 'boolean-false')
# Hide alert boxes on click
$(document).on 'click', '.general-alerts .alert-box', -> $(@).slideUp()
@@ -75,12 +75,19 @@
$("*[data-time]").each ->
$(this).text moment($(this).data("time")).format($(this).data("timeFormat") or "dd D MMM HH:MM")
# jQuery UI datepicker support
$(".datepicker").datepicker "option", $.datepicker.regional[locale] if $.fn.datepicker
# pickadate support
if $.fn.pickadate
datepicker_object = $('.datepicker')
if selector.hasClass('datepicker')
datepicker_object = selector
selector.siblings('.pickadate-display').remove()
else
datepicker_object = selector.find('.datepicker')
selector.find('.pickadate-display').remove()
datepicker_object.pickadate('stop') if datepicker_object.data('pickadate')
$.extend( $.fn.pickadate.defaults, $pickadate_translations[locale] )
$('.pickadate-display').remove()
window.pickadate_options ||= {}
datepicker_object.pickadate(window.pickadate_options)
datepicker_object.change()
@@ -89,16 +96,20 @@
@setupTranslations = (options = {})->
locale = options.locale || Qstorage.getItem('locale') || 'en'
if $.fn.pickadate
$('.datepicker').change ->
$(document).on 'change', '.datepicker', ->
input = $(@)
input.next().remove() if input.next().hasClass('pickadate-display')
display_format = $pickadate_translations[$locale].displayFormat
display_date = input.data('pickadate').get('select', display_format)
display_date = ' '+display_date # add space between the icon and the date
display_tag = $('<span></span>').addClass('pickadate-display').append('<span class="fa fa-calendar fa-lg"></span>').append($('<span></span>').text(display_date))
#display_tag.click (e)->(e.preventDefault();input.click().focus();false )
display_tag.click (e)->(e.preventDefault();input.pickadate('open');false )
$(@).after(display_tag)
if input.data('pickadate')
if input.val()
display_format = $pickadate_translations[$locale].displayFormat
display_date = input.data('pickadate').get('select', display_format)
display_date = $('<span></span>').text(' '+display_date) # add space between the icon and the date
else
display_date = $('<span></span>').data('t', 'datepicker.no_date').text(t('datepicker.no_date'))
display_tag = $('<span></span>').addClass('pickadate-display').append('<span class="fa fa-calendar fa-lg"></span>').append(display_date)
#display_tag.click (e)->(e.preventDefault();input.click().focus();false )
display_tag.click (e)->(e.preventDefault();input.pickadate('open');false )
$(@).after(display_tag)
setLocale(locale)
$('.datepicker').change().hide()
$transformation_mappings =