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'
|
||||
classNames: ['close-list-button']
|
||||
classNameBindings: ['content.active:show:hide']
|
||||
tagName: 'button'
|
||||
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'
|
||||
validatePresence: false
|
||||
|
||||
inputValue: Ember.computed (key, value, previousValue)->
|
||||
key = "value"
|
||||
if arguments.length > 1
|
||||
inputValue: Ember.computed "value",
|
||||
get: ->
|
||||
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 typeof value is 'number'
|
||||
# return_value = value.toPrecision()
|
||||
# @set key, value
|
||||
if typeof value is 'string' and value.match(/^[+-]?\d+(\.?\d?\d)?$/)
|
||||
@set 'has_error', false
|
||||
@set key, parseFloat(value)
|
||||
@set "value", parseFloat(value)
|
||||
else
|
||||
@set 'has_error', true
|
||||
|
||||
else
|
||||
@set key, 0.0 # empty
|
||||
@set "value", 0.0 # empty
|
||||
@set 'has_error', false
|
||||
return_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
|
||||
value
|
||||
|
||||
actions:
|
||||
action: ->
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
App.ModalDialogComponent = Ember.Component.extend
|
||||
actions:
|
||||
close: ->
|
||||
@sendAction()
|
||||
+3
-2
@@ -1,11 +1,12 @@
|
||||
App.SectionsHeaderComponent = Ember.Component.extend
|
||||
sections: (-> @get('targetObject.store').all('section') ).property()
|
||||
sections: (-> @get('targetObject.store').peekAll('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)
|
||||
#return App.Router.router.transitionTo('section', section)
|
||||
return @get('targetObject').transitionToRoute('section', section)
|
||||
@$('dd').removeClass('active')
|
||||
@$("[data-section=#{if section then section.id else 'all'}]").addClass('active')
|
||||
@set('section', section)
|
||||
@@ -15,7 +15,7 @@ App.ApplicationController = Ember.Controller.extend
|
||||
#@set 'supplier', null
|
||||
#@store.find('supplier', 'current').then success, error
|
||||
# @set 'supplier', @store.find('supplier', supplier_id)
|
||||
current_employee: (-> @get('employee') ).property('employee')
|
||||
#current_employee: (-> @get('employee') ).property('employee')
|
||||
actions:
|
||||
signOut: ->
|
||||
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']
|
||||
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']
|
||||
show_lists: 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
|
||||
list: (-> @get('model')).property('model')
|
||||
showTotal: (->
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
App.ListsIndexController = Ember.ArrayController.extend
|
||||
App.ListsIndexController = Ember.Controller.extend
|
||||
loading: true
|
||||
dateChanged: (->
|
||||
@set 'loading', true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
App.MenuController = Ember.ObjectController.extend
|
||||
App.MenuController = Ember.Controller.extend
|
||||
needs: ['application']
|
||||
product_code_filter: ''
|
||||
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']
|
||||
alert_message: ""
|
||||
modal_options: {}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
App.modals.EmployeeEditController = App.modals.BaseController.extend
|
||||
isNotSelf: (->
|
||||
@get('model.id') isnt @get('current_employee.id')
|
||||
@get('model.id') isnt @get('globals.current_employee.id')
|
||||
).property('model.id')
|
||||
|
||||
colors: (->
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
App.OrdersDisplayController = Ember.ObjectController.extend
|
||||
App.OrdersDisplayController = Ember.Controller.extend
|
||||
needs: ['application']
|
||||
active_section: null
|
||||
sections: (-> @store.all('section') ).property()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
App.ScheduleController = Ember.ArrayController.extend
|
||||
App.ScheduleController = Ember.Controller.extend
|
||||
event_changed: (event)->
|
||||
@store.find('employee-shift', event.id).then (employee_shift)->
|
||||
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
|
||||
editmode: false
|
||||
actions:
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
App.SectionsController = Ember.ArrayController.extend
|
||||
App.SectionsController = Ember.Controller.extend
|
||||
needs: ['application']
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
App.SectionsIndexController = Ember.ArrayController.extend
|
||||
App.SectionsIndexController = Ember.Controller.extend
|
||||
needs: ['application', 'sections', 'index']
|
||||
sections: (-> @get('controllers.sections.model')).property('controllers.sections.model')
|
||||
sectionQrCodesUrl: ((a,b,c)->
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
App.SettingsController = Ember.ObjectController.extend
|
||||
App.SettingsController = Ember.Controller.extend
|
||||
needs: ['application']
|
||||
# model: (-> @get('controllers.application.supplier')).property('controllers.application.supplier')
|
||||
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')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
App.TablesIndexController = Ember.ArrayController.extend
|
||||
App.TablesIndexController = Ember.Controller.extend
|
||||
needs: ['application']
|
||||
tables: (-> @get('model').sortBy('casted_number')).property('model.@each.number')
|
||||
actions:
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
Ember.Handlebars.registerHelper 'can', (operation, resource, options)->
|
||||
#if operation is 'manage' and @get('current_employee.manager')
|
||||
#App.__container__.lookup('globals:current').get('employee.manager')
|
||||
if operation is 'manage' and options.data.view and options.data.view.get('controller.current_employee.manager')
|
||||
options.fn @
|
||||
Ember.Handlebars.registerHelper 'can', (permission, resource, options)->
|
||||
if employee = App.__container__.lookup('global:variables').get('current_employee')
|
||||
if permission is "read" or (permission is "manage" and employee.isManager())
|
||||
options.fn @
|
||||
else
|
||||
options.inverse @ if options.inverse
|
||||
else
|
||||
options.inverse @ if options.inverse
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
Globals = Ember.Object.extend
|
||||
current_employee: null
|
||||
App.initializer
|
||||
name: 'injectCurrent'
|
||||
initialize: (container, app)->
|
||||
container.optionsForType 'globals', instantiate: false, singleton: true
|
||||
container.register 'globals:current', Em.Object.create()
|
||||
#container.optionsForType 'globals', instantiate: false, singleton: true
|
||||
app.register 'global:variables', Globals, singleton: true
|
||||
|
||||
container.typeInjection 'controller', 'current', 'globals:current'
|
||||
container.typeInjection 'route', 'current', 'globals:current'
|
||||
app.inject 'controller', 'globals', 'global:variables'
|
||||
app.inject 'route', 'globals', 'global:variables'
|
||||
|
||||
@@ -7,6 +7,8 @@ App.Employee= DS.Model.extend Ember.Validations.Mixin,
|
||||
color: attr 'string', defaultValue: '#3a87ad'
|
||||
employee_shifts: DS.hasMany('employee-shift')
|
||||
|
||||
isManager: -> @get('manager')
|
||||
|
||||
validations:
|
||||
name: {presence: true}
|
||||
email: {format: /.+@.+\..{2,4}/}
|
||||
|
||||
+1
-3
@@ -11,8 +11,6 @@ ControllerExtensions = Ember.Mixin.create
|
||||
@send "openModal", name, options
|
||||
|
||||
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.ArrayController.reopen ControllerExtensions
|
||||
Ember.ObjectController.reopen ControllerExtensions
|
||||
|
||||
@@ -13,8 +13,7 @@ App.ApplicationRoute = Ember.Route.extend
|
||||
#@store.find 'order', state: 'active' included in list
|
||||
setupController: (controller)->
|
||||
controller.set 'supplier', @supplier
|
||||
controller.set 'employee', @employee
|
||||
controller.set 'current.employee', @employee
|
||||
controller.set 'globals.current_employee', @employee
|
||||
# @set 'supplier', @store.find('supplier', supplier_id)
|
||||
#controller.set 'sections', @sections
|
||||
#controller.set 'product_categories', @product_categories
|
||||
|
||||
@@ -11,7 +11,7 @@ if list.closed_at
|
||||
=state 'list' list.state
|
||||
.display-row
|
||||
.display-label
|
||||
.display-field= view "close-list-button" content=list
|
||||
.display-field= button-close-list content=list
|
||||
.user-info-container
|
||||
each user in list.users
|
||||
=user.avatar_tag
|
||||
|
||||
@@ -19,6 +19,7 @@ td.actions
|
||||
/= view "mark-list-helped-button" content=view.content
|
||||
= button-mark-list-helped 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
|
||||
|
||||
@@ -4,5 +4,5 @@ else
|
||||
= partial "global/top_menu"
|
||||
= partial "global/side_menu"
|
||||
.main-section= outlet
|
||||
= view flash_message
|
||||
= outlet modal
|
||||
= view "flash_message"
|
||||
= outlet "modal"
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
= flag locale
|
||||
= flag view.locale
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
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
|
||||
.row
|
||||
.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
|
||||
.small-12.medium-6.columns
|
||||
= 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
|
||||
h2=model.title
|
||||
/= 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: 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"
|
||||
|
||||
= view "section-tables" content=model.tables
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
.table-number= table.number
|
||||
.table-number= view.content.number
|
||||
unless editmode
|
||||
.status-icons
|
||||
span.needs_payment
|
||||
span.needs_help
|
||||
span.active_order
|
||||
if table.active_list
|
||||
if view.content.active_list
|
||||
div.table-actions
|
||||
.title= table.number
|
||||
if table.active_list
|
||||
if view.content.active_list
|
||||
.table-action-row
|
||||
/= view "mark-list-helped-button" contentBinding="table.active_list"
|
||||
= button-mark-list-helped content=table.active_list
|
||||
= view "close-list-button" contentBinding="table.active_list"
|
||||
each order in table.active_list.active_orders
|
||||
/= view "mark-list-helped-button" view.contentBinding="table.active_list"
|
||||
= button-mark-list-helped content=view.content.active_list
|
||||
/= view "close-list-button" view.contentBinding="table.active_list"
|
||||
= 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.total
|
||||
= link-to "list" table.active_list
|
||||
=currency table.active_list.total
|
||||
= link-to "list" view.content.active_list
|
||||
=currency view.content.active_list.total
|
||||
/.table-action-row
|
||||
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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
each section_element in section_elements
|
||||
each section_element in view.section_elements
|
||||
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
|
||||
each table in tables
|
||||
each table in view.tables
|
||||
= view "section-table" content=table
|
||||
|
||||
Reference in New Issue
Block a user