End of day commit

This commit is contained in:
2015-02-18 22:36:47 +01:00
parent 82670f271b
commit c1858455e9
68 changed files with 633 additions and 145 deletions
@@ -17,7 +17,7 @@ App.ApplicationController = Ember.Controller.extend
# @set 'supplier', @store.find('supplier', supplier_id)
actions:
signOut: ->
window.location = Routes.destroy_supplier_session_path()
window.location = Routes.destroy_employee_session_path()
markSupplierClosed: ->
return unless supplier = @get('supplier')
supplier.close()
@@ -1,14 +1,17 @@
App.EmployeesIndexController = Ember.ArrayController.extend
needs: ['application']
employees: (-> @get('model').sortBy('name')).property('model.@each.name')
actions:
newEmployee: ->
employee = @store.createRecord('employee')
@modal 'employee_edit',
model: employee
title_path: 'employee.modal.new_title'
close: -> employee.deleteRecord()
editEmployee: (employee)->
@modal 'employee_edit',
model: employee
title_path: 'employee.modal.edit_title'
close: -> employee.rollback()
destroyEmployee: (employee)->
@modal 'confirm',
@@ -34,3 +34,5 @@ App.modals.AddSectionController = @App.modals.BaseController.extend
@set 'section_title', ''
@send 'closeModal'
@transitionToRoute 'section', s.id
, @save_error.bind(@)
@@ -19,10 +19,21 @@
else
underscored.capitalize().replace(/_/, ' ')
).property('model.id')
save_error: (error)->
switch error.status
when 403
@set 'alert_message', 'Unauthorized action'
else
@set 'alert_message', 'Something went wrong'
save_success: ->
@set 'alert_message', ''
@send 'closeModal'
actions:
close: ->
if close = @get('modal_options.close')
close.apply(@)
@set 'alert_message', ''
@send 'closeModal' unless @preventClose
closeOnOverlay: ->
@send('close') if @get('modal_options.closeOnOverlay')
@@ -33,12 +44,13 @@
ok: ->
if ok = @get('modal_options.ok')
ok.apply(@)
@set 'alert_message', ''
@send 'closeModal' unless @preventClose
confirm: -> @send('ok')
save: ->
if @get('model.isValid')
@get('model').save().then((=> @send 'closeModal' ), (-> true))
#@send 'closeModal' unless @preventClose
@get('model').save().then @save_success.bind(@), @save_error.bind(@)
#@send 'closeModal' unless @preventClose
destroy: ->
@modal 'confirm',
title_path: @get('modal_options.destroy_text_path') || 'general.destroy.text'
@@ -1,4 +1,5 @@
App.TablesIndexController = Ember.ArrayController.extend
needs: ['application']
tables: (-> @get('model').sortBy('casted_number')).property('model.@each.number')
actions:
newTable: ->
@@ -0,0 +1,5 @@
Ember.Handlebars.registerHelper 'can', (operation, resource, options)->
if operation is 'manage' and @get('controllers.application.employee_settings.manager')
options.fn @
else
options.inverse @
@@ -4,5 +4,5 @@ App.Employee= DS.Model.extend Ember.Validations.Mixin,
email: attr 'string'
validations:
name:
presence: true
name: {presence: true}
email: {format: /.+@.+\..{2,4}/}
@@ -1,5 +1,5 @@
attr = DS.attr
App.ProductCategory = DS.Model.extend
App.ProductCategory = DS.Model.extend Ember.Validations.Mixin,
name: attr('string')
products: DS.hasMany('product')
supplier: DS.belongsTo 'supplier'
@@ -25,3 +25,6 @@ App.ProductCategory = DS.Model.extend
unless @get('full_day')
result += "<span class=\"time-range\">#{day_minutes_to_time @get('start_from')} - #{day_minutes_to_time @get('end_on')}</span>"
new Ember.Handlebars.SafeString result
validations:
name: {presence: true}
@@ -1,7 +1,6 @@
attr = DS.attr
App.Supplier = DS.Model.extend
name: attr 'string'
email: attr 'string'
time_zone: attr 'string'
address: attr 'string'
house_number: attr 'number'
@@ -2,18 +2,22 @@ App.ApplicationRoute = Ember.Route.extend
beforeModel: ->
# Preload only active lists and orders
@supplier = @store.push 'supplier', supplier_object
@product_categories = @store.find 'product_category'
@sections = @store.find 'section'
Ember.RSVP.all([@product_categories, @sections]).then (results)=>
@store.find('list', state: 'active').then (lists) -> lists.invoke('get', 'table')
@lists = @store.all 'list'
@employee = @store.push 'employee', employee_object
#@product_categories = @store.find 'product_category'
#@sections = @store.find '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
setupController: (controller)->
controller.set 'supplier', @supplier
controller.set 'employee', @employee
controller.set 'employee_settings', Ember.Object.create(employee_settings)
# @set 'supplier', @store.find('supplier', supplier_id)
controller.set 'sections', @sections
controller.set 'product_categories', @product_categories
#controller.set 'sections', @sections
#controller.set 'product_categories', @product_categories
faye = new Faye.Client(event_host)
faye.subscribe "/supplier/#{supplier_object.id}", (e)=>
@@ -15,7 +15,9 @@
= employee.email
= errors employee.errors.email
td.actions
a.table-edit{ action 'editEmployee' employee }: span
a.table-destroy{ action 'destroyEmployee' employee }: span
can manage sections
a.table-edit{ action 'editEmployee' employee }: span
a.table-destroy{ action 'destroyEmployee' employee }: span
.form-actions
a.form-action-new.new-employee-button{action "newEmployee"}= t 'employee.new_button'
can manage employees
a.form-action-new.new-employee-button{action "newEmployee"}= t 'employee.new_button'
@@ -0,0 +1 @@
span= view.text
@@ -6,13 +6,16 @@
each product_category in sorted_product_categories
.row.product_category-container: .small-12.columns
.product_category-header
a.move{action "moveProductCategory" product_category} href="#"
can manage menu
a.move{action "moveProductCategory" product_category} href="#"
span.title= product_category.name
span.availability= product_category.availability_text
a.edit-product-category-button{action "editProductCategory" product_category} href="#"
a.add-product-product_category-button{action "addProduct" product_category} href="#": span
can manage menu
a.edit-product-category-button{action "editProductCategory" product_category} href="#"
a.add-product-product_category-button{action "addProduct" product_category} href="#": span
each product in product_category.sorted_products
= menu-product product=product code_filter=product_code_filter
.row
.small-12.columns
a.new-product_category-button{action "newProductCategory"} href="#" = t 'product_category.new_button'
can manage menu
.row
.small-12.columns
a.new-product_category-button{action "newProductCategory"} href="#" = t 'product_category.new_button'
@@ -1,4 +1,4 @@
p=t 'employee.edit.modal.body_header'
p=t 'employee.modal.body_header'
.form-row.name
.form-label=t 'attributes.employee.name'
.form-field
@@ -7,8 +7,9 @@ p=t 'employee.edit.modal.body_header'
.form-row.name
.form-label=t 'attributes.employee.email'
.form-field
= input type="email" valueBinding="model.email"
= input type="email" valueBinding="model.email" action="save"
= errors model.errors.email
hr
button.modal-close{action "close"}=t 'section.add_employees.modal.close_button'
button.modal-confirm.right{action "save"}=t 'section.add_employees.modal.add_button'
button.modal-close{action "close"}=t 'employee.modal.close_button'
button.modal-confirm.right{action "save"} disabled=model.isInvalid
=t 'employee.modal.save_button'
@@ -1,6 +1,6 @@
.form-row.name
.form-label.half=t 'attributes.product_category.name'
.form-field.half= input valueBinding="model.name"
.form-field.half= input valueBinding="model.name" action="save"
.row
.small-12.medium-6.columns
unless model.supplier.week_starts_on_monday
@@ -2,4 +2,5 @@ p=t 'product_category.modal.new.body_header'
= partial "modals/product_category_form"
hr
button.modal-close{action "close"}=t 'product_category.modal.new.close_button'
button.modal-save.right{action "save"}=t 'product_category.modal.new.save_button'
button.modal-save.right{action "save"} disabled=model.isInvalid
=t 'product_category.modal.new.save_button'
@@ -2,22 +2,24 @@
= link-to 'sections' class="goto-sections-index-tab-header": span
each section in sections
= view "section-tab-header" context=section
a.add-section{action "addSection"}: span
.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'
if editmode
= input type="text" valueBinding="title" class="section-edit-title-field"
App.NumberField valueBinding="width" class="dimension section-edit-width-field"
span.fa.fa-lg.fa-times
App.NumberField valueBinding="height" class="dimension section-edit-height-field"
a.section-rollback-button{ action "rollbackEditable" }: span
a.section-normal-mode-button{ action "finishEditable" }: span
else
a.section-edit-mode-button{ action "makeEditable" }: span
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'
if editmode
= input type="text" valueBinding="title" class="section-edit-title-field"
App.NumberField valueBinding="width" class="dimension section-edit-width-field"
span.fa.fa-lg.fa-times
App.NumberField valueBinding="height" class="dimension section-edit-height-field"
a.section-rollback-button{ action "rollbackEditable" }: span
a.section-normal-mode-button{ action "finishEditable" }: span
else
a.section-edit-mode-button{ action "makeEditable" }: span
= view "section-tables" contentBinding="tables"
@@ -36,5 +36,6 @@
else
.row: .small-12.columns
.panel=t 'section.none_found'
.form-actions
a.form-action-new{action "addSection"}=t 'helpers.links.new'
can manage sections
.form-actions
a.form-action-new{action "addSection"}=t 'helpers.links.new'
@@ -18,10 +18,12 @@
= table.section.title
/td.timestamp=time table.created_at
td.actions
a.table-edit{ action 'editTable' table }: span
a.table-destroy{ action 'destroyTable' table }: span
can manage tables
a.table-edit{ action 'editTable' table }: span
a.table-destroy{ action 'destroyTable' table }: span
.form-actions
a.form-action-new.new-table-button{action "newTable"}= t 'table.new_button'
can manage tables
a.form-action-new.new-table-button{action "newTable"}= t 'table.new_button'
if tables
a.table-qr-codes{path qr_codes_suppliers_tables} target="_blank"
span.qr-icon
@@ -2,7 +2,7 @@ App.BooleanButtonView = Ember.View.extend
tagName: 'a'
href: '#'
classNames: "button"
# templateName: "form_elements/boolean_switch"
templateName: "form_elements/boolean_button"
#template: Ember.Handlebars.compile "<span>{{view.text}}</span>"
classNameBindings: ['rounded:round', 'active:active:disabled']
@@ -1,6 +1,7 @@
App.ModalView = Ember.View.extend
layoutName: 'modals/layout'
didInsertElement: ->
@$('input:first').focus()
sortable = $('.sortable')
controller = @get('controller')
if sortable.length
@@ -24,6 +24,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',
@@ -25,8 +25,10 @@
+grid-column($columns: 9, $last-column:true)
&.half
+grid-column(6)
.error, .error-message
.error
color: $alert-color
.error-message
color: $alert-color
&.form-actions
padding-top: 12px
body
@@ -17,6 +17,8 @@
&.full
@media #{$large-up}
+grid-column($columns: 9, $last-column:true)
.error-message
color: $alert-color
&.form-actions
padding-top: 12px