Ember2 refactor progress
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
App.CloseListButtonView = Ember.View.extend
|
App.ButtonCloseListComponent = Ember.Component.extend
|
||||||
templateName: 'close_list_button'
|
templateName: 'close_list_button'
|
||||||
classNames: ['close-list-button']
|
classNames: ['close-list-button']
|
||||||
classNameBindings: ['content.active:show:hide']
|
classNameBindings: ['content.active:show:hide']
|
||||||
tagName: 'button'
|
tagName: 'button'
|
||||||
click: (e)->
|
click: (e)->
|
||||||
@get('controller').modal 'close_list', model: @get('content')
|
@get('targetObject').modal 'close_list', model: @get('content')
|
||||||
@@ -6,27 +6,27 @@ App.EditCurrencyComponent = Ember.Component.extend
|
|||||||
placeholder: '0.00'
|
placeholder: '0.00'
|
||||||
validatePresence: false
|
validatePresence: false
|
||||||
|
|
||||||
inputValue: Ember.computed (key, value, previousValue)->
|
inputValue: Ember.computed "value",
|
||||||
key = "value"
|
get: ->
|
||||||
if arguments.length > 1
|
return_value = @get "value"
|
||||||
|
@set 'has_error', true if @validatePresence and !return_value
|
||||||
|
return_value = return_value.toFixed(2) if typeof return_value is 'number'
|
||||||
|
return_value
|
||||||
|
set: (key, value, previousValue)->
|
||||||
if value
|
if value
|
||||||
# if typeof value is 'number'
|
# if typeof value is 'number'
|
||||||
# return_value = value.toPrecision()
|
# return_value = value.toPrecision()
|
||||||
# @set key, value
|
# @set key, value
|
||||||
if typeof value is 'string' and value.match(/^[+-]?\d+(\.?\d?\d)?$/)
|
if typeof value is 'string' and value.match(/^[+-]?\d+(\.?\d?\d)?$/)
|
||||||
@set 'has_error', false
|
@set 'has_error', false
|
||||||
@set key, parseFloat(value)
|
@set "value", parseFloat(value)
|
||||||
else
|
else
|
||||||
@set 'has_error', true
|
@set 'has_error', true
|
||||||
|
|
||||||
else
|
else
|
||||||
@set key, 0.0 # empty
|
@set "value", 0.0 # empty
|
||||||
@set 'has_error', false
|
@set 'has_error', false
|
||||||
return_value = value
|
value
|
||||||
return_value ||= @get key
|
|
||||||
@set 'has_error', true if @validatePresence and !return_value
|
|
||||||
return_value = return_value.toFixed(2) if typeof return_value is 'number'
|
|
||||||
return_value
|
|
||||||
|
|
||||||
actions:
|
actions:
|
||||||
action: ->
|
action: ->
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
App.ModalDialogComponent = Ember.Component.extend
|
|
||||||
actions:
|
|
||||||
close: ->
|
|
||||||
@sendAction()
|
|
||||||
+3
-2
@@ -1,11 +1,12 @@
|
|||||||
App.SectionsHeaderComponent = Ember.Component.extend
|
App.SectionsHeaderComponent = Ember.Component.extend
|
||||||
sections: (-> @get('targetObject.store').all('section') ).property()
|
sections: (-> @get('targetObject.store').peekAll('section') ).property()
|
||||||
actions:
|
actions:
|
||||||
setSection: (section)->
|
setSection: (section)->
|
||||||
if section and section is @get('section')
|
if section and section is @get('section')
|
||||||
# click on already active section
|
# click on already active section
|
||||||
#return @transitionTo('section', section.id)
|
#return @transitionTo('section', section.id)
|
||||||
return App.Router.router.transitionTo('section', section)
|
#return App.Router.router.transitionTo('section', section)
|
||||||
|
return @get('targetObject').transitionToRoute('section', section)
|
||||||
@$('dd').removeClass('active')
|
@$('dd').removeClass('active')
|
||||||
@$("[data-section=#{if section then section.id else 'all'}]").addClass('active')
|
@$("[data-section=#{if section then section.id else 'all'}]").addClass('active')
|
||||||
@set('section', section)
|
@set('section', section)
|
||||||
@@ -15,7 +15,7 @@ App.ApplicationController = Ember.Controller.extend
|
|||||||
#@set 'supplier', null
|
#@set 'supplier', null
|
||||||
#@store.find('supplier', 'current').then success, error
|
#@store.find('supplier', 'current').then success, error
|
||||||
# @set 'supplier', @store.find('supplier', supplier_id)
|
# @set 'supplier', @store.find('supplier', supplier_id)
|
||||||
current_employee: (-> @get('employee') ).property('employee')
|
#current_employee: (-> @get('employee') ).property('employee')
|
||||||
actions:
|
actions:
|
||||||
signOut: ->
|
signOut: ->
|
||||||
window.location = Routes.destroy_employee_session_path()
|
window.location = Routes.destroy_employee_session_path()
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
App.EmployeesIndexController = Ember.ArrayController.extend
|
App.EmployeesIndexController = Ember.Controller.extend
|
||||||
needs: ['application']
|
needs: ['application']
|
||||||
employees: (-> @get('model').sortBy('name')).property('model.@each.name')
|
employees: (-> @get('model').sortBy('name')).property('model.@each.name')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
App.IndexController = Ember.ObjectController.extend
|
App.IndexController = Ember.Controller.extend
|
||||||
needs: ['application']
|
needs: ['application']
|
||||||
show_lists: true
|
show_lists: true
|
||||||
show_orders: true
|
show_orders: true
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
App.ListController = Ember.ObjectController.extend
|
App.ListController = Ember.Controller.extend
|
||||||
needs: ['application', 'lists', 'list'] #wtf? list, otherwise an Ember error
|
needs: ['application', 'lists', 'list'] #wtf? list, otherwise an Ember error
|
||||||
list: (-> @get('model')).property('model')
|
list: (-> @get('model')).property('model')
|
||||||
showTotal: (->
|
showTotal: (->
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
App.ListsIndexController = Ember.ArrayController.extend
|
App.ListsIndexController = Ember.Controller.extend
|
||||||
loading: true
|
loading: true
|
||||||
dateChanged: (->
|
dateChanged: (->
|
||||||
@set 'loading', true
|
@set 'loading', true
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
App.MenuController = Ember.ObjectController.extend
|
App.MenuController = Ember.Controller.extend
|
||||||
needs: ['application']
|
needs: ['application']
|
||||||
product_code_filter: ''
|
product_code_filter: ''
|
||||||
product_categories: (-> @store.all('product_category')).property()
|
product_categories: (-> @store.all('product_category')).property()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@App.modals.BaseController = Ember.ObjectController.extend
|
@App.modals.BaseController = Ember.Controller.extend
|
||||||
needs: ['application']
|
needs: ['application']
|
||||||
alert_message: ""
|
alert_message: ""
|
||||||
modal_options: {}
|
modal_options: {}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
App.modals.EmployeeEditController = App.modals.BaseController.extend
|
App.modals.EmployeeEditController = App.modals.BaseController.extend
|
||||||
isNotSelf: (->
|
isNotSelf: (->
|
||||||
@get('model.id') isnt @get('current_employee.id')
|
@get('model.id') isnt @get('globals.current_employee.id')
|
||||||
).property('model.id')
|
).property('model.id')
|
||||||
|
|
||||||
colors: (->
|
colors: (->
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
App.OrdersDisplayController = Ember.ObjectController.extend
|
App.OrdersDisplayController = Ember.Controller.extend
|
||||||
needs: ['application']
|
needs: ['application']
|
||||||
active_section: null
|
active_section: null
|
||||||
sections: (-> @store.all('section') ).property()
|
sections: (-> @store.all('section') ).property()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
App.ScheduleController = Ember.ArrayController.extend
|
App.ScheduleController = Ember.Controller.extend
|
||||||
event_changed: (event)->
|
event_changed: (event)->
|
||||||
@store.find('employee-shift', event.id).then (employee_shift)->
|
@store.find('employee-shift', event.id).then (employee_shift)->
|
||||||
employee_shift.set 'start_from', event.start
|
employee_shift.set 'start_from', event.start
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
App.SectionController = Ember.ObjectController.extend
|
App.SectionController = Ember.Controller.extend
|
||||||
needs: ['application', 'sections', 'section'] #wtf? section, otherwise an Ember error
|
needs: ['application', 'sections', 'section'] #wtf? section, otherwise an Ember error
|
||||||
editmode: false
|
editmode: false
|
||||||
actions:
|
actions:
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
App.SectionsController = Ember.ArrayController.extend
|
App.SectionsController = Ember.Controller.extend
|
||||||
needs: ['application']
|
needs: ['application']
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
App.SectionsIndexController = Ember.ArrayController.extend
|
App.SectionsIndexController = Ember.Controller.extend
|
||||||
needs: ['application', 'sections', 'index']
|
needs: ['application', 'sections', 'index']
|
||||||
sections: (-> @get('controllers.sections.model')).property('controllers.sections.model')
|
sections: (-> @get('controllers.sections.model')).property('controllers.sections.model')
|
||||||
sectionQrCodesUrl: ((a,b,c)->
|
sectionQrCodesUrl: ((a,b,c)->
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
App.SettingsController = Ember.ObjectController.extend
|
App.SettingsController = Ember.Controller.extend
|
||||||
needs: ['application']
|
needs: ['application']
|
||||||
# model: (-> @get('controllers.application.supplier')).property('controllers.application.supplier')
|
# model: (-> @get('controllers.application.supplier')).property('controllers.application.supplier')
|
||||||
time_zones: (-> window.time_zones ).property()
|
time_zones: (-> window.time_zones ).property()
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
App.TableController = Ember.ObjectController.extend
|
App.TableController = Ember.Controller.extend
|
||||||
table: (-> @get('model')).property('model')
|
table: (-> @get('model')).property('model')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
App.TablesIndexController = Ember.ArrayController.extend
|
App.TablesIndexController = Ember.Controller.extend
|
||||||
needs: ['application']
|
needs: ['application']
|
||||||
tables: (-> @get('model').sortBy('casted_number')).property('model.@each.number')
|
tables: (-> @get('model').sortBy('casted_number')).property('model.@each.number')
|
||||||
actions:
|
actions:
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
Ember.Handlebars.registerHelper 'can', (operation, resource, options)->
|
Ember.Handlebars.registerHelper 'can', (permission, resource, options)->
|
||||||
#if operation is 'manage' and @get('current_employee.manager')
|
if employee = App.__container__.lookup('global:variables').get('current_employee')
|
||||||
#App.__container__.lookup('globals:current').get('employee.manager')
|
if permission is "read" or (permission is "manage" and employee.isManager())
|
||||||
if operation is 'manage' and options.data.view and options.data.view.get('controller.current_employee.manager')
|
options.fn @
|
||||||
options.fn @
|
else
|
||||||
|
options.inverse @ if options.inverse
|
||||||
else
|
else
|
||||||
options.inverse @ if options.inverse
|
options.inverse @ if options.inverse
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
Globals = Ember.Object.extend
|
||||||
|
current_employee: null
|
||||||
App.initializer
|
App.initializer
|
||||||
name: 'injectCurrent'
|
name: 'injectCurrent'
|
||||||
initialize: (container, app)->
|
initialize: (container, app)->
|
||||||
container.optionsForType 'globals', instantiate: false, singleton: true
|
#container.optionsForType 'globals', instantiate: false, singleton: true
|
||||||
container.register 'globals:current', Em.Object.create()
|
app.register 'global:variables', Globals, singleton: true
|
||||||
|
|
||||||
container.typeInjection 'controller', 'current', 'globals:current'
|
app.inject 'controller', 'globals', 'global:variables'
|
||||||
container.typeInjection 'route', 'current', 'globals:current'
|
app.inject 'route', 'globals', 'global:variables'
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ App.Employee= DS.Model.extend Ember.Validations.Mixin,
|
|||||||
color: attr 'string', defaultValue: '#3a87ad'
|
color: attr 'string', defaultValue: '#3a87ad'
|
||||||
employee_shifts: DS.hasMany('employee-shift')
|
employee_shifts: DS.hasMany('employee-shift')
|
||||||
|
|
||||||
|
isManager: -> @get('manager')
|
||||||
|
|
||||||
validations:
|
validations:
|
||||||
name: {presence: true}
|
name: {presence: true}
|
||||||
email: {format: /.+@.+\..{2,4}/}
|
email: {format: /.+@.+\..{2,4}/}
|
||||||
|
|||||||
+1
-3
@@ -11,8 +11,6 @@ ControllerExtensions = Ember.Mixin.create
|
|||||||
@send "openModal", name, options
|
@send "openModal", name, options
|
||||||
|
|
||||||
all_sections: (-> @store.all('section')).property()
|
all_sections: (-> @store.all('section')).property()
|
||||||
current_employee: (-> @get('controllers.application.employee') ).property('controllers.application.employee')
|
#current_employee: (-> @get('controllers.application.employee') ).property('controllers.application.employee')
|
||||||
|
|
||||||
Ember.Controller.reopen ControllerExtensions
|
Ember.Controller.reopen ControllerExtensions
|
||||||
Ember.ArrayController.reopen ControllerExtensions
|
|
||||||
Ember.ObjectController.reopen ControllerExtensions
|
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ App.ApplicationRoute = Ember.Route.extend
|
|||||||
#@store.find 'order', state: 'active' included in list
|
#@store.find 'order', state: 'active' included in list
|
||||||
setupController: (controller)->
|
setupController: (controller)->
|
||||||
controller.set 'supplier', @supplier
|
controller.set 'supplier', @supplier
|
||||||
controller.set 'employee', @employee
|
controller.set 'globals.current_employee', @employee
|
||||||
controller.set 'current.employee', @employee
|
|
||||||
# @set 'supplier', @store.find('supplier', supplier_id)
|
# @set 'supplier', @store.find('supplier', supplier_id)
|
||||||
#controller.set 'sections', @sections
|
#controller.set 'sections', @sections
|
||||||
#controller.set 'product_categories', @product_categories
|
#controller.set 'product_categories', @product_categories
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ if list.closed_at
|
|||||||
=state 'list' list.state
|
=state 'list' list.state
|
||||||
.display-row
|
.display-row
|
||||||
.display-label
|
.display-label
|
||||||
.display-field= view "close-list-button" content=list
|
.display-field= button-close-list content=list
|
||||||
.user-info-container
|
.user-info-container
|
||||||
each user in list.users
|
each user in list.users
|
||||||
=user.avatar_tag
|
=user.avatar_tag
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ td.actions
|
|||||||
/= view "mark-list-helped-button" content=view.content
|
/= view "mark-list-helped-button" content=view.content
|
||||||
= button-mark-list-helped content=view.content
|
= button-mark-list-helped content=view.content
|
||||||
/= view "remove-list-needs-payment" content=view.content
|
/= view "remove-list-needs-payment" content=view.content
|
||||||
= view "close-list-button" content=view.content
|
/= view "close-list-button" content=view.content
|
||||||
|
= button-close-list content=view.content
|
||||||
|
|
||||||
button.show-list.button{action "showList" view.content.id}: span
|
button.show-list.button{action "showList" view.content.id}: span
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ else
|
|||||||
= partial "global/top_menu"
|
= partial "global/top_menu"
|
||||||
= partial "global/side_menu"
|
= partial "global/side_menu"
|
||||||
.main-section= outlet
|
.main-section= outlet
|
||||||
= view flash_message
|
= view "flash_message"
|
||||||
= outlet modal
|
= outlet "modal"
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
= flag locale
|
= flag view.locale
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
each locale in locales
|
each locale in locales
|
||||||
view language-switcher-button locale=locale
|
view "language-switcher-button" locale=locale
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ if editMode
|
|||||||
a.save-product-action{action "save"}: span
|
a.save-product-action{action "save"}: span
|
||||||
.row
|
.row
|
||||||
.small-3.columns= t 'attributes.product.active'
|
.small-3.columns= t 'attributes.product.active'
|
||||||
.small-9.columns: view boolean-switch value=product.active
|
.small-9.columns: view "boolean-switch" value=product.active
|
||||||
.row.menu-product-container
|
.row.menu-product-container
|
||||||
.small-12.medium-6.columns
|
.small-12.medium-6.columns
|
||||||
= descriptionPlaceholder
|
= descriptionPlaceholder
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
modal-dialog action="close"
|
|
||||||
h3.flush--top Alert
|
|
||||||
p= body
|
|
||||||
button{action "close"} Done
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
.row: .small-12.columns
|
.row: .small-12.columns
|
||||||
h2=model.title
|
h2=model.title
|
||||||
/= page-body model.body
|
/= page-body model.body
|
||||||
view page-body templateBody=model.body
|
view "page-body" templateBody=model.body
|
||||||
|
|||||||
@@ -24,5 +24,4 @@
|
|||||||
li= qr-codes-link section=content: span.qr-icon= t 'table.print_qr_codes'
|
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'
|
li: a.section-destroy{action "destroySection"}: span.section-remove-icon=t 'helpers.links.destroy'
|
||||||
a.section-edit-mode-button{ action "makeEditable" }: span
|
a.section-edit-mode-button{ action "makeEditable" }: span
|
||||||
= view "section-tables" contentBinding="tables"
|
= view "section-tables" content=model.tables
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,24 @@
|
|||||||
.table-number= table.number
|
.table-number= view.content.number
|
||||||
unless editmode
|
unless editmode
|
||||||
.status-icons
|
.status-icons
|
||||||
span.needs_payment
|
span.needs_payment
|
||||||
span.needs_help
|
span.needs_help
|
||||||
span.active_order
|
span.active_order
|
||||||
if table.active_list
|
if view.content.active_list
|
||||||
div.table-actions
|
div.table-actions
|
||||||
.title= table.number
|
.title= table.number
|
||||||
if table.active_list
|
if view.content.active_list
|
||||||
.table-action-row
|
.table-action-row
|
||||||
/= view "mark-list-helped-button" contentBinding="table.active_list"
|
/= view "mark-list-helped-button" view.contentBinding="table.active_list"
|
||||||
= button-mark-list-helped content=table.active_list
|
= button-mark-list-helped content=view.content.active_list
|
||||||
= view "close-list-button" contentBinding="table.active_list"
|
/= view "close-list-button" view.contentBinding="table.active_list"
|
||||||
each order in table.active_list.active_orders
|
= button-close-list content=view.content.active_list
|
||||||
|
each order in view.content.active_list.active_orders
|
||||||
.table-action-row= order.display_tag
|
.table-action-row= order.display_tag
|
||||||
.table-action-row.total
|
.table-action-row.total
|
||||||
= link-to "list" table.active_list
|
= link-to "list" view.content.active_list
|
||||||
=currency table.active_list.total
|
=currency view.content.active_list.total
|
||||||
/.table-action-row
|
/.table-action-row
|
||||||
a{action "editTable" table}: span.fa.fa-lg.fa-wrench
|
a{action "editTable" table}: span.fa.fa-lg.fa-wrench
|
||||||
each user in table.active_list.users
|
each user in view.content.active_list.users
|
||||||
= user.avatar_tag
|
= user.avatar_tag
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
each section_element in section_elements
|
each section_element in view.section_elements
|
||||||
view "section-element" content=section_element
|
view "section-element" content=section_element
|
||||||
each section_area in section_areas
|
each section_area in view.section_areas
|
||||||
= section-area section_area=section_area
|
= section-area section_area=section_area
|
||||||
each table in tables
|
each table in view.tables
|
||||||
= view "section-table" content=table
|
= view "section-table" content=table
|
||||||
|
|||||||
Reference in New Issue
Block a user