cleanup
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
GIT
|
GIT
|
||||||
remote: git://github.com/bterkuile/cmtool.git
|
remote: git://github.com/bterkuile/cmtool.git
|
||||||
revision: 02e60c174da507348c5c268ea7d2a18e5e61c080
|
revision: 3aa204aa303c7c0579a00cf0b638e5e733ff8319
|
||||||
branch: master
|
branch: master
|
||||||
specs:
|
specs:
|
||||||
cmtool (2.0.0)
|
cmtool (2.0.0)
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
#App.ApplicationAdapter = DS.ActiveModelAdapter.extend
|
|
||||||
# namespace: 'supplier'
|
|
||||||
# headers:
|
|
||||||
# "Accept": "application/json, text/javascript; q=0.01"
|
|
||||||
App.ApplicationAdapter = DS.JSONAPIAdapter.extend
|
|
||||||
namespace: 'supplier'
|
|
||||||
pathForType: (type)->
|
|
||||||
type.underscore().pluralize()
|
|
||||||
# Code for createRecord and updateRecord taken from ember data v2.0.0 restadapter
|
|
||||||
createRecord: (store, type, snapshot)->
|
|
||||||
data = {}
|
|
||||||
#var serializer = store.serializerFor(type.modelName);
|
|
||||||
serializer = Ember.get(snapshot.record, 'store').serializerFor('creation')
|
|
||||||
url = @buildURL(type.modelName, null, snapshot, 'createRecord')
|
|
||||||
|
|
||||||
serializer.serializeIntoHash data, type, snapshot, includeId: true
|
|
||||||
|
|
||||||
@ajax url, "POST", data: data
|
|
||||||
|
|
||||||
updateRecord: (store, type, snapshot)->
|
|
||||||
data = {}
|
|
||||||
#var serializer = store.serializerFor(type.modelName);
|
|
||||||
serializer = Ember.get(snapshot.record, 'store').serializerFor('creation')
|
|
||||||
id = snapshot.id
|
|
||||||
url = @buildURL(type.modelName, id, snapshot, 'updateRecord')
|
|
||||||
serializer.serializeIntoHash data, type, snapshot, includeId: true
|
|
||||||
@ajax url, "PUT", data: data
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
window.ember_ready = false
|
|
||||||
@App = Ember.Application.create
|
|
||||||
LOG_TRANSITIONS: true
|
|
||||||
LOG_VIEW_LOOKUPS: true
|
|
||||||
rootElement: '#ember-app-container'
|
|
||||||
store: -> @__container__.lookup('service:store')
|
|
||||||
ready: ->
|
|
||||||
window.ember_ready = true
|
|
||||||
@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
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#= require_self
|
|
||||||
#= require md5
|
|
||||||
#= require handlebars
|
|
||||||
# require ember
|
|
||||||
# require ember-data
|
|
||||||
# require active-model-adapter
|
|
||||||
# require ember-validations
|
|
||||||
# require ember-template-compiler
|
|
||||||
#= require_directory ./modifications
|
|
||||||
#= require ./app
|
|
||||||
# require shared-ember-helpers/all
|
|
||||||
#= require_directory ./mixins
|
|
||||||
#= require_directory ./services
|
|
||||||
#= require ./controllers/modals/base_controller
|
|
||||||
# require ion.sound
|
|
||||||
#= require_tree .
|
|
||||||
|
|
||||||
@$assets_path = '/assets/'
|
|
||||||
#@EmberENV = {FEATURES: {'query-params-new': true}}
|
|
||||||
@$days = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
App.ApplicationView = Ember.Component.extend
|
|
||||||
layoutName: 'application'
|
|
||||||
classNames: ['application-view']
|
|
||||||
didRender: ->
|
|
||||||
$('.toggle-side-menu,.side-menu').click ->
|
|
||||||
menu = $('.side-menu')
|
|
||||||
toggle = $('.toggle-side-menu')
|
|
||||||
if menu.is(':visible')
|
|
||||||
menu.animate left: -255, -> $(@).hide()
|
|
||||||
toggle.animate left: 0, -> $(@).removeClass('open')
|
|
||||||
else
|
|
||||||
menu.show().animate left: 0
|
|
||||||
toggle.animate left: 222 - 30, -> $(@).addClass('open')
|
|
||||||
|
|
||||||
ion.sound
|
|
||||||
sounds: [
|
|
||||||
{name: "bell_ring", volume: 0.8}
|
|
||||||
{name: "water_droplet"}
|
|
||||||
{name: "water_droplet_3"}
|
|
||||||
]
|
|
||||||
path: "/sounds/"
|
|
||||||
preload: true
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
App.ButtonChangeListTableComponent = Ember.Component.extend
|
|
||||||
layoutName: 'components/button/change-list-table'
|
|
||||||
tagName: 'button'
|
|
||||||
classNames: ['change-list-table-button']
|
|
||||||
click: ->
|
|
||||||
@modal 'change-list-table',
|
|
||||||
model: @list
|
|
||||||
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
App.ButtonCloseListComponent = Ember.Component.extend
|
|
||||||
layoutName: 'close_list_button'
|
|
||||||
classNames: ['close-list-button']
|
|
||||||
classNameBindings: ['content.active:show:hide']
|
|
||||||
tagName: 'button'
|
|
||||||
click: (e)->
|
|
||||||
@modal 'close_list', model: @get('content')
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
App.ButtonLanguageSwitcherComponent = Ember.Component.extend
|
|
||||||
tagName: 'a'
|
|
||||||
layoutName: 'components/language-switcher-button'
|
|
||||||
classNameBindings: ['isCurrent:current']
|
|
||||||
classNames: ['language-switch-button']
|
|
||||||
isCurrent: Ember.computed 'locale', 'globals.locale', ->
|
|
||||||
@get('locale') is @get('globals.locale')
|
|
||||||
#isCurrent: Ember.computed.equal 'locale', 'globals.locale'
|
|
||||||
click: -> @get('controller').send 'switchTo', @get('locale')
|
|
||||||
action: 'switchTo'
|
|
||||||
#TODO: EASY BUBBLE ACTION
|
|
||||||
actions:
|
|
||||||
switchTo: (locale)->
|
|
||||||
setLocale locale
|
|
||||||
@set 'globals.locale', locale
|
|
||||||
@store.peekAll("page").invoke 'reload'
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
App.ButtonMarkListHelpedComponent = Ember.Component.extend
|
|
||||||
layoutName: 'components/button/mark-list-helped'
|
|
||||||
classNames: ['mark-list-as-helped-button']
|
|
||||||
classNameBindings: ['content.needs_help:show:hide']
|
|
||||||
tagName: 'button'
|
|
||||||
click: (e)->
|
|
||||||
# record could be promise or object
|
|
||||||
@get('content').invoke 'markHelped'
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
App.ButtonMarkOrderActiveComponent = Ember.Component.extend
|
|
||||||
tagName: 'button'
|
|
||||||
layoutName: 'components/button/mark-order-active'
|
|
||||||
classNames: ['mark-order-active-button']
|
|
||||||
classNameBindings: ['order.placed:active:hide']
|
|
||||||
click: -> @get('order').mark_active()
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
App.ButtonMarkOrderCancelledComponent = Ember.Component.extend
|
|
||||||
tagName: 'button'
|
|
||||||
layoutName: 'components/button/mark-order-cancelled'
|
|
||||||
classNames: ['mark-order-cancelled-button']
|
|
||||||
classNameBindings: ['showButton:active:hide']
|
|
||||||
showButton: Ember.computed 'order.list.state', ->
|
|
||||||
@get('order.list.state') is 'active'
|
|
||||||
click: ->
|
|
||||||
@modal 'confirm',
|
|
||||||
model: @get('order')
|
|
||||||
ok: => @get('order').mark_cancelled()
|
|
||||||
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
App.ButtonMarkOrderDeliveredComponent = Ember.Component.extend
|
|
||||||
tagName: 'button'
|
|
||||||
layoutName: 'components/button/mark-order-delivered'
|
|
||||||
classNames: ['mark-order-delivered-button']
|
|
||||||
classNameBindings: ['showButton:active:hide']
|
|
||||||
showButton: Ember.computed 'order.state', ->
|
|
||||||
state = @get('order.state')
|
|
||||||
state is 'placed' or state is 'active'
|
|
||||||
click: -> @get('order').mark_delivered()
|
|
||||||
|
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
App.ButtonRemoveListNeedsPaymentComponent = Ember.Component.extend
|
|
||||||
tagName: 'button'
|
|
||||||
layoutName: 'components/button/remove-list-needs-payment'
|
|
||||||
classNames: ['remove-list-needs-payment-button']
|
|
||||||
classNameBindings: ['content.needs_payment:show:hide']
|
|
||||||
click: ->
|
|
||||||
@get('content').invoke 'remove_needs_payment'
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
App.ButtonShowListComponent = Ember.Component.extend
|
|
||||||
tagName: 'button'
|
|
||||||
layoutName: 'components/button/show-list'
|
|
||||||
classNames: ['show-list-button']
|
|
||||||
click: ->
|
|
||||||
@get('targetObject.targetObject').transitionToRoute('list', @get('content'))
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
App.DashboardActiveListComponent = Ember.Component.extend
|
|
||||||
classNames: ['row']
|
|
||||||
layoutName: 'dashboard/active-list'
|
|
||||||
classNameBindings: ['classIdentifier']
|
|
||||||
classIdentifier: Ember.computed 'list.id', -> "list-row-#{@get('list.id')}"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
App.DashboardActiveOrderComponent = Ember.Component.extend
|
|
||||||
classNames: ['row']
|
|
||||||
layoutName: 'dashboard/active-order'
|
|
||||||
classNameBindings: ['order.active:active', 'order.delivered:delivered', 'classIdentifier']
|
|
||||||
classIdentifier: Ember.computed 'order.id', -> "order-row-#{@get('order.id')}"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
App.DropdownLinkComponent = Ember.Component.extend
|
|
||||||
active: false
|
|
||||||
classNames: ['dropdown-container']
|
|
||||||
classNameBindings: ['active']
|
|
||||||
click: -> @set 'active', !@get('active')
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
App.EditCurrencyComponent = Ember.Component.extend
|
|
||||||
classNames: ['edit-currency-container', 'row', 'collapse']
|
|
||||||
classNameBindings: ['has_error:error']
|
|
||||||
currencySymbol: '€'
|
|
||||||
has_error: false
|
|
||||||
placeholder: '0.00'
|
|
||||||
validatePresence: false
|
|
||||||
|
|
||||||
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 "value", parseFloat(value)
|
|
||||||
else
|
|
||||||
@set 'has_error', true
|
|
||||||
|
|
||||||
else
|
|
||||||
@set "value", 0.0 # empty
|
|
||||||
@set 'has_error', false
|
|
||||||
value
|
|
||||||
|
|
||||||
actions:
|
|
||||||
action: ->
|
|
||||||
@sendAction('action') if @action
|
|
||||||
#didInsertElement: ->
|
|
||||||
#@addObserver "model.#{@attribute}", (attribute)=>
|
|
||||||
#if value = @get("model.#{@attribute}")
|
|
||||||
#@set 'value', value.toFixed(2) if parseFloat(@get('value')) isnt value
|
|
||||||
#else
|
|
||||||
#@set 'value', 0
|
|
||||||
## @set('value', @get("model.#{@attribute}").toFixed)
|
|
||||||
## # dynamically observe the model's attribute
|
|
||||||
## # if this changes outside the component's context, it is not
|
|
||||||
## # observed by the computed property. model.@attribute is not (yet) working :)
|
|
||||||
## current_value = @get 'value'
|
|
||||||
## if value = @get("model.#{@attribute}")
|
|
||||||
## string_value = value.toPrecision()
|
|
||||||
## @set('value', string_value) if parseFloat(current_value) isnt @get("model.#{@attribute}")
|
|
||||||
#@addObserver "model.errors.#{@attribute}.length", (attribute)=>
|
|
||||||
#@set 'has_error', !!@get("model.errors.#{@attribute}.length")
|
|
||||||
#@model.validate().then =>
|
|
||||||
#@set 'has_error', !!@get("model.errors.#{@attribute}.length")
|
|
||||||
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
App.FlashMessageComponent = Ember.Component.extend
|
|
||||||
layoutName: 'flash_message'
|
|
||||||
classNames: ['flash-message']
|
|
||||||
classNameBindings: ['message:active']
|
|
||||||
message: Ember.computed.alias 'globals.flash_message'
|
|
||||||
click: -> @set 'globals.flash_message', ''
|
|
||||||
inactivator: (->
|
|
||||||
if @get('message')
|
|
||||||
Ember.run.later((=> @set 'globals.flash_message', ''), 4000)
|
|
||||||
).observes('message')
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
App.BooleanButtonComponent = Ember.Component.extend
|
|
||||||
tagName: 'a'
|
|
||||||
href: '#'
|
|
||||||
classNames: "button"
|
|
||||||
layoutName: "form/boolean-button"
|
|
||||||
#template: Ember.Handlebars.compile "<span>{{view.text}}</span>"
|
|
||||||
classNameBindings: ['rounded:round', 'active:active:disabled']
|
|
||||||
|
|
||||||
text: Ember.computed 'text_path', ->
|
|
||||||
return unless text_path = @get('text_path')
|
|
||||||
tspan(text_path).htmlSafe()
|
|
||||||
|
|
||||||
active: Ember.computed 'value', ->
|
|
||||||
if @reverse then !@get('value') else !!@get('value')
|
|
||||||
|
|
||||||
click: ->
|
|
||||||
@set 'value', !@get('value')
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
App.BooleanSwitchComponent = Ember.Component.extend
|
|
||||||
layoutName: "form/boolean-switch"
|
|
||||||
classNames: "switch"
|
|
||||||
classNameBindings: ['rounded:round']
|
|
||||||
|
|
||||||
# UniqueId is used to connect the label and the checkbox to eachother in the template
|
|
||||||
setUniqueId: (->@set 'switchId', "switch-#{Math.round(Math.random()*1000)}").on('init')
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
App.FormFileUploadComponent = Ember.TextField.extend
|
|
||||||
tagName: 'input'
|
|
||||||
attributeBindings: ['name']
|
|
||||||
type: 'file'
|
|
||||||
file: null,
|
|
||||||
change: (e)->
|
|
||||||
reader = new FileReader()
|
|
||||||
that = this
|
|
||||||
reader.onload = (el)->
|
|
||||||
fileToUpload = el.target.result
|
|
||||||
Ember.run -> that.set('file', fileToUpload)
|
|
||||||
reader.readAsDataURL(e.target.files[0])
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
App.MySelectComponent = Ember.Component.extend
|
|
||||||
# possible passed-in values with their defaults:
|
|
||||||
layoutName: 'form/my-select'
|
|
||||||
content: null
|
|
||||||
prompt: null
|
|
||||||
optionValuePath: 'id'
|
|
||||||
optionLabelPath: 'title'
|
|
||||||
action: Ember.K # action to fire on change
|
|
||||||
selection: null
|
|
||||||
identity: true
|
|
||||||
|
|
||||||
# shadow the passed-in `selection` to avoid
|
|
||||||
# leaking changes to it via a 2-way binding
|
|
||||||
#_selection: Ember.computed.reads('selection')
|
|
||||||
|
|
||||||
setContent: (->
|
|
||||||
@set('content', []) unless @get('content')
|
|
||||||
).on('init')
|
|
||||||
|
|
||||||
didRender: ->
|
|
||||||
# Set select to current value if can be found
|
|
||||||
if @get('identity')
|
|
||||||
key = @get('optionValuePath')
|
|
||||||
index = @get('content').mapBy(key).indexOf(@get("selection.#{key}")) # Ember 2.0.1 cannot find real objects yet
|
|
||||||
else
|
|
||||||
index = @get('content').indexOf(@get('selection'))
|
|
||||||
if index > -1
|
|
||||||
@$('select:first').prop('selectedIndex', index)
|
|
||||||
|
|
||||||
actions:
|
|
||||||
showDebugger: -> debugger
|
|
||||||
change: ->
|
|
||||||
selectedIndex = @$('select:first').get(0).selectedIndex
|
|
||||||
|
|
||||||
# decrement index by 1 if we have a prompt
|
|
||||||
hasPrompt = !!@get('prompt')
|
|
||||||
contentIndex = if hasPrompt then selectedIndex - 1 else selectedIndex
|
|
||||||
|
|
||||||
selection = @get('content').toArray()[contentIndex]
|
|
||||||
|
|
||||||
# set the local, shadowed selection to avoid leaking
|
|
||||||
# changes to `selection` out via 2-way binding
|
|
||||||
@set('selection', selection)
|
|
||||||
|
|
||||||
#changeCallback(selection) if changeCallback = @get('action')
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
App.SelectMinuteOfDayComponent = Ember.Component.extend
|
|
||||||
layoutName: "form/select_minute_of_day"
|
|
||||||
classNameBindings: ['rounded:round']
|
|
||||||
hours_list: [0..24].map (n) -> "0#{n}".substr(-2,2)
|
|
||||||
minutes_list: [0..60].map (n) -> "0#{n}".substr(-2,2)
|
|
||||||
hour: Ember.computed 'value',
|
|
||||||
set: (key, value)->
|
|
||||||
minute = if @get('minute') then parseInt(@get('minute')) else 0
|
|
||||||
@set 'value', 60*parseInt(value) + minute
|
|
||||||
value
|
|
||||||
get: ->
|
|
||||||
number = Math.floor (@get('value') || 0)/60
|
|
||||||
"0#{number}".substr(-2,2)
|
|
||||||
minute: Ember.computed 'value',
|
|
||||||
set: (key, value)->
|
|
||||||
hour = if @get('hour') then parseInt(@get('hour')) else 0
|
|
||||||
@set 'value', 60*hour + parseInt(value)
|
|
||||||
value
|
|
||||||
get: ->
|
|
||||||
return "00" unless value = @get('value')
|
|
||||||
number = Math.floor value%60
|
|
||||||
"0#{number}".substr(-2,2)
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
App.LanguageSwitcherComponent = Ember.Component.extend
|
|
||||||
classNames: ['language-switcher-container']
|
|
||||||
locales: (-> ['en', 'nl']).property()
|
|
||||||
actions:
|
|
||||||
switchTo: (locale)->
|
|
||||||
setLocale locale
|
|
||||||
@set 'globals.locale', locale
|
|
||||||
@store.peekAll("page").invoke 'reload'
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
App.ListDisplayDateSelectorComponent = Ember.TextField.extend
|
|
||||||
classNames: 'datepicker'
|
|
||||||
didInsertElement: ->
|
|
||||||
setTranslations @$().hide()
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
App.ListOrderComponent = Ember.Component.extend
|
|
||||||
layoutName: 'list/order'
|
|
||||||
classNames: ['list-order-container']
|
|
||||||
classNameBindings: ['order.state']
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
App.MenuProductComponent = Ember.Component.extend
|
|
||||||
editMode: false
|
|
||||||
code_filter: ''
|
|
||||||
classNames: 'menu-product-container'
|
|
||||||
classNameBindings: ['menu_product_class', 'editMode:editing', 'product.active:active:inactive']
|
|
||||||
showProduct: (->
|
|
||||||
return true unless filter = @get('code_filter')
|
|
||||||
(@get('product.code') || "").toLowerCase().indexOf(filter.toLowerCase()) >= 0
|
|
||||||
).property('code_filter')
|
|
||||||
menu_product_class: (-> "menu-product-#{@get('product.id') || 'new'}").property('product.id')
|
|
||||||
code_filter_display: Ember.computed 'code_filter', 'product.code', ->
|
|
||||||
return " ".htmlSafe() unless code = @get('product.code')
|
|
||||||
return code unless filter = @get('code_filter')
|
|
||||||
index = code.toLowerCase().indexOf(filter.toLowerCase())
|
|
||||||
if index >= 0
|
|
||||||
pre_code = code.substring(0,index)
|
|
||||||
highlight = code.substring(index,index + filter.length)
|
|
||||||
post_code = code.substring(index + filter.length)
|
|
||||||
"#{pre_code}<span class='highlight'>#{highlight}</span>#{post_code}".htmlSafe()
|
|
||||||
else
|
|
||||||
code
|
|
||||||
actions:
|
|
||||||
makeEditable: -> @set('editMode', true)
|
|
||||||
save: ->
|
|
||||||
return unless @get('product.isValid')
|
|
||||||
@get('product.product_variants').forEach (product_variant)->
|
|
||||||
product_variant.save() if product_variant.get('hasDirtyAttributes')
|
|
||||||
if @get('product.hasDirtyAttributes')
|
|
||||||
@get('product').save()
|
|
||||||
@set 'editMode', false
|
|
||||||
destroyProduct: (product)->
|
|
||||||
if product.get('isNew')
|
|
||||||
product.deleteRecord()
|
|
||||||
else
|
|
||||||
@modal 'confirm',
|
|
||||||
model: product
|
|
||||||
title_path: 'product.destroy_confirmation'
|
|
||||||
ok: -> product.destroyRecord()
|
|
||||||
rollbackProduct: ->
|
|
||||||
if @get('product.isNew')
|
|
||||||
@get('product').deleteRecord()
|
|
||||||
else
|
|
||||||
@get('product.product_variants').forEach (product_variant)->
|
|
||||||
product_variant.rollbackAttributes()
|
|
||||||
@get('product').rollbackAttributes()
|
|
||||||
@set 'editMode', false
|
|
||||||
addProductVariant: ->
|
|
||||||
product_variant = @get('targetObject.store').createRecord('product_variant')
|
|
||||||
@get('product.product_variants').addObject product_variant
|
|
||||||
removeProductVariant: (product_variant)->
|
|
||||||
product_variant.destroyRecord()
|
|
||||||
didInsertElement: ->
|
|
||||||
if @get('product.isNew')
|
|
||||||
@set 'editMode', true
|
|
||||||
Ember.run.later =>
|
|
||||||
@$('input:first').focus()
|
|
||||||
, 300
|
|
||||||
namePlaceholder: (-> t "attributes.product.name").property()
|
|
||||||
pricePlaceholder: (-> t "attributes.product.price").property()
|
|
||||||
codePlaceholder: (-> t "attributes.product.code").property()
|
|
||||||
descriptionPlaceholder: (-> t "attributes.product.description").property()
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
App.MenuTimePreviewComponent = Ember.Component.extend
|
|
||||||
active: false
|
|
||||||
collapsed: true
|
|
||||||
preview_day: null
|
|
||||||
filter: null
|
|
||||||
preview_full_day: true
|
|
||||||
preview_minute_of_day: 1340
|
|
||||||
classNames: 'menu-time-preview-container'
|
|
||||||
classNameBindings: ['active:active']
|
|
||||||
actions:
|
|
||||||
openTimePreview: ->
|
|
||||||
@set 'collapsed', false
|
|
||||||
closeTimePreview: ->
|
|
||||||
#@set 'active', false
|
|
||||||
@set 'collapsed', true
|
|
||||||
activateTimePreview: ->
|
|
||||||
@set 'collapsed', true
|
|
||||||
@set 'active', true
|
|
||||||
deactivateTimePreview: ->
|
|
||||||
@set 'preview_day', null
|
|
||||||
@set 'preview_full_day', true
|
|
||||||
@set 'active', false
|
|
||||||
@set 'collapsed', true
|
|
||||||
daysContent: (->
|
|
||||||
$days.map( (d) -> Ember.Object.create( name: d, text: t("date.day_name.#{d}")) )
|
|
||||||
).property()
|
|
||||||
preview_day_text: (->
|
|
||||||
return "" unless day = @get('preview_day.text')
|
|
||||||
#day_text = tspan("date.day_name.#{day.get('name')}")
|
|
||||||
"<h4>#{day}</h4>".htmlSafe()
|
|
||||||
).property('preview_day')
|
|
||||||
|
|
||||||
preview_time_text: (->
|
|
||||||
return "" if @get('preview_full_day')
|
|
||||||
day_minute = @get('preview_minute_of_day')
|
|
||||||
hour = Math.floor(day_minute/60)
|
|
||||||
minute = Math.floor(day_minute%60)
|
|
||||||
hour = "0#{hour}".substr(-2,2)
|
|
||||||
minute = "0#{minute}".substr(-2,2)
|
|
||||||
"<span class='time-preview-active-time time'>#{hour}:#{minute}</span>".htmlSafe()
|
|
||||||
).property('preview_full_day', 'preview_minute_of_day')
|
|
||||||
hasSelection: (->
|
|
||||||
return true if @get('preview_day')
|
|
||||||
return true unless @get('preview_full_day')
|
|
||||||
false
|
|
||||||
).property('preview_day', 'preview_full_day')
|
|
||||||
|
|
||||||
remoteFilter: (->
|
|
||||||
return @set('targetObject.filter', null) unless @get('active')
|
|
||||||
filter = Ember.Object.create()
|
|
||||||
filter.set 'day', @get('preview_day.name')
|
|
||||||
filter.set 'minute_of_day', @get('preview_minute_of_day') unless @get('preview_full_day')
|
|
||||||
@set('targetObject.filter', filter)
|
|
||||||
).observes('active', 'preview_day', 'preview_full_day', 'preview_minute_of_day')
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
App.ModalView = Ember.Component.extend
|
|
||||||
layoutName: 'modals/layout'
|
|
||||||
didInsertElement: ->
|
|
||||||
@$('input:first').focus()
|
|
||||||
sortable = $('.sortable')
|
|
||||||
controller = @get('controller')
|
|
||||||
if sortable.length
|
|
||||||
sortable.sortable
|
|
||||||
update: (e, ui)->
|
|
||||||
ids = sortable.find('.sortable-item-container').map((i, el) -> $(el).data('sortableId')).toArray()
|
|
||||||
if callback = controller.sortableUpdate
|
|
||||||
callback.call(controller, ids)
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
App.MyScheduleView = Ember.Component.extend
|
|
||||||
layoutName: 'my-schedule'
|
|
||||||
classNames: ['schedule-view']
|
|
||||||
didInsertElement: ->
|
|
||||||
placeholder = @$('#schedule-placeholder')
|
|
||||||
events = @get('globals.current_employee.employee_shifts').map( (employee_shift)->employee_shift.get('calendar_event_for_employee') )
|
|
||||||
placeholder.fullCalendar
|
|
||||||
header:
|
|
||||||
left: 'prev,next,today'
|
|
||||||
center: 'title'
|
|
||||||
right: 'agendaDay,agendaWeek,month'
|
|
||||||
selectable: false
|
|
||||||
defaultView: 'agendaWeek'
|
|
||||||
events: events
|
|
||||||
timezone: 'UTC'
|
|
||||||
timeFormat: 'H(:mm)'
|
|
||||||
axisFormat: 'H:mm'
|
|
||||||
lang: moment.locale()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
App.NumberFieldComponent = Ember.TextField.extend
|
|
||||||
type: 'number'
|
|
||||||
attributeBindings: ['min', 'max', 'step']
|
|
||||||
focusIn: -> @$().select()
|
|
||||||
numericValue: Ember.computed 'value',
|
|
||||||
get: ->
|
|
||||||
value = @get 'value'
|
|
||||||
if value? then String(value) else ''
|
|
||||||
set: (key, value)->
|
|
||||||
if value?
|
|
||||||
setValue = parseFloat(value)
|
|
||||||
@set "value", if Number.isFinite(setValue) then setValue else null
|
|
||||||
else
|
|
||||||
@set 'value', null
|
|
||||||
value
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
App.PageBodyComponent = Ember.Component.extend
|
|
||||||
setTemplate: (->
|
|
||||||
body = @get('page.body')
|
|
||||||
body ||= ""
|
|
||||||
try
|
|
||||||
template = Ember.HTMLBars.compile(body)
|
|
||||||
catch
|
|
||||||
template = Ember.HTMLBars.compile(tspan('page.cannot_compile'))
|
|
||||||
@set 'layout', Ember.HTMLBars.template(template)
|
|
||||||
@rerender()
|
|
||||||
).on('init').observes('page.body')
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
App.QrCodesLinkComponent = Ember.Component.extend
|
|
||||||
tagName: 'a'
|
|
||||||
target: '_blank'
|
|
||||||
classNames: ["table-qr-codes"]
|
|
||||||
attributeBindings: ['href', 'target']
|
|
||||||
href: Ember.computed 'section.id', 'table.id', ->
|
|
||||||
Routes.qr_codes_suppliers_tables_path(section_id: @get('section.id'), table_id: @get('table.id'))
|
|
||||||
click: ->
|
|
||||||
# Somehow this is needed for within the actions menu
|
|
||||||
@$().click()
|
|
||||||
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
App.ScheduleView = Ember.Component.extend
|
|
||||||
event_changed: (event)->
|
|
||||||
if employee_shift = @get('globals.current_employee').store.peekRecord('employee-shift', event.id)
|
|
||||||
return unless event.start and event.end
|
|
||||||
employee_shift.set 'start_from', event.start
|
|
||||||
employee_shift.set 'end_on', event.end
|
|
||||||
employee_shift.save()
|
|
||||||
editEvent: (id, callbacks)->
|
|
||||||
if employee_shift = @get('globals.current_employee').store.peekRecord('employee-shift', id)
|
|
||||||
@modal 'employee_shift',
|
|
||||||
title_path: 'employee_shift.modal.title'
|
|
||||||
destroy_text_path: 'employee_shift.modal.destroy_confirmation'
|
|
||||||
model: employee_shift
|
|
||||||
save: -> callbacks.save.call(@, employee_shift) if callbacks.save
|
|
||||||
destroy_callback: -> callbacks.destroy.call(@, employee_shift) if callbacks.destroy
|
|
||||||
classNames: ['schedule-view']
|
|
||||||
|
|
||||||
didRender: -> @drawCalendar()
|
|
||||||
drawCalendar: ->
|
|
||||||
placeholder = @$('#schedule-placeholder')
|
|
||||||
events = @get('globals.current_supplier.employee_shifts').filter((employee_shift) -> employee_shift.get('employee.active') ).map( (employee_shift)->employee_shift.get('calendar_event') )
|
|
||||||
editable = !!@get('globals.current_employee.manager')
|
|
||||||
fullCalendarOptions =
|
|
||||||
header:
|
|
||||||
left: 'prev,next,today'
|
|
||||||
center: 'title'
|
|
||||||
right: 'agendaDay,agendaWeek,month'
|
|
||||||
selectable: editable
|
|
||||||
selectHelper: editable
|
|
||||||
editable: editable
|
|
||||||
defaultView: 'agendaWeek'
|
|
||||||
events: events
|
|
||||||
timezone: 'UTC'
|
|
||||||
eventDrop: @event_changed.bind(@)
|
|
||||||
eventResize: @event_changed.bind(@)
|
|
||||||
dayClick: (date, jsEvent, view)->
|
|
||||||
jsEvent.preventDefault()
|
|
||||||
if view.type is 'month'
|
|
||||||
placeholder.fullCalendar('changeView', 'agendaDay')
|
|
||||||
placeholder.fullCalendar('gotoDate', date)
|
|
||||||
false
|
|
||||||
eventClick: (event)=>
|
|
||||||
return unless editable
|
|
||||||
@editEvent event.id,
|
|
||||||
save: (shift)->
|
|
||||||
placeholder.fullCalendar('removeEvents', [event.id])
|
|
||||||
placeholder.fullCalendar('renderEvent', shift.get('calendar_event'), true)
|
|
||||||
destroy: (shift)->
|
|
||||||
placeholder.fullCalendar('removeEvents', [event.id])
|
|
||||||
timeFormat: 'H(:mm)'
|
|
||||||
slotLabelFormat: 'H:mm'
|
|
||||||
lang: moment.locale()
|
|
||||||
if editable
|
|
||||||
fullCalendarOptions.select = (start, end, jsEvent, view) =>
|
|
||||||
return if view.type is 'month'
|
|
||||||
format = 'dddd h:mm'
|
|
||||||
@modal 'select_employee',
|
|
||||||
ok: ->
|
|
||||||
# this context is SelectEmployeeController
|
|
||||||
if employee = @get('employee')
|
|
||||||
shift = employee.store.createRecord 'employee-shift', start_from: start, end_on: end
|
|
||||||
shift.set 'employee', employee
|
|
||||||
shift.save().then ->
|
|
||||||
placeholder.fullCalendar('renderEvent', shift.get('calendar_event'), true)
|
|
||||||
header: t('employee_shift.time_window', start: start.format(format), end: end.format(format))
|
|
||||||
|
|
||||||
placeholder.fullCalendar fullCalendarOptions
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
App.SectionAreaComponent = Ember.Component.extend DragNDrop.Draggable,
|
|
||||||
layoutName: 'section/area'
|
|
||||||
classNames: ['section-area-container']
|
|
||||||
attributeBindings: ['style']
|
|
||||||
classNameBindings: ['vertical', 'right_half:right-half', 'section_area.rounded:rounded']
|
|
||||||
pixelWidth: Ember.computed 'section_area.width', 'dpm', -> @get('dpm') * @get('section_area.width')
|
|
||||||
pixelHeight: Ember.computed 'section_area.height', 'dpm', -> @get('dpm') * @get('section_area.height')
|
|
||||||
offsetX: Ember.computed.product 'dpm', 'section_area.position_x'
|
|
||||||
offsetY: Ember.computed.product 'dpm', 'section_area.position_y'
|
|
||||||
vertical: Ember.computed 'section_area.width', 'section_area.height', 'section.editmode', ->
|
|
||||||
not @get('section.editmode') and @get('section_area.height') > @get('section_area.width')
|
|
||||||
right_half: Ember.computed 'section_area.position_x', 'section_area.width', 'section_area.section.width', ->
|
|
||||||
@get('section_area.position_x') + (@get('section_area.width') / 2) > (@get('section_area.section.width') / 2)
|
|
||||||
style: Ember.computed 'offsetX', 'offsetY', 'pixelWidth', 'pixelHeight', 'section_area.color', ->
|
|
||||||
background_color = @get('section_area.color')
|
|
||||||
color = if App.CssObject.isColorDark(background_color) then 'white' else 'black'
|
|
||||||
App.CssObject.create(
|
|
||||||
width: @get('pixelWidth')
|
|
||||||
height: @get('pixelHeight')
|
|
||||||
left: @get('offsetX')
|
|
||||||
top: @get('offsetY')
|
|
||||||
"background-color": background_color
|
|
||||||
color: color
|
|
||||||
"line-height": @get('pixelHeight')
|
|
||||||
).toString()
|
|
||||||
draggable: (-> if @get('section.editmode') then true else false ).property('section.editmode')
|
|
||||||
positionChange: (position)->
|
|
||||||
dpm = @get('dpm')
|
|
||||||
return if !dpm or parseFloat(dpm) is 0
|
|
||||||
@get('section_area').setProperties
|
|
||||||
position_x: position.left / dpm
|
|
||||||
position_y: position.top / dpm
|
|
||||||
click: ->
|
|
||||||
return unless @get('section.editmode')
|
|
||||||
@modal 'section_area',
|
|
||||||
title_path: 'section_area.modal.title'
|
|
||||||
model: @get('section_area')
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
App.SectionElementComponent = Ember.Component.extend DragNDrop.Draggable,
|
|
||||||
layoutName: 'section/element'
|
|
||||||
classNames: ['section-element-container']
|
|
||||||
attributeBindings: ['style']
|
|
||||||
show_handles: false
|
|
||||||
spinning: false
|
|
||||||
classNameBindings: ['uniqueClass', 'spinning:spin-rotate']
|
|
||||||
uniqueClass: Ember.computed 'section_element.id', -> "section-element-#{@get('section_element.id')}"
|
|
||||||
draggable: Ember.computed.alias 'section.editmode'
|
|
||||||
offsetX: (->
|
|
||||||
(@get('dpm') || 0) * (@get('section_element.position_x') || 0)
|
|
||||||
).property('dpm', 'section_element.position_x')
|
|
||||||
offsetY: (->
|
|
||||||
return 0 unless dpm = @get('dpm')
|
|
||||||
dpm * (@get('section_element.position_y') || 0)
|
|
||||||
).property('dpm', 'section_element.position_y', 'section_element.rotation')
|
|
||||||
#myHeight: (-> (@get('dpm') || 0 ) * @get('section_element.height')).property('dpm', 'section_element.height')
|
|
||||||
#myWidth: (-> (@get('dpm') || 0 ) * @get('section_element.width')).property('dpm', 'section_element.width')
|
|
||||||
|
|
||||||
# box size in dots [d]
|
|
||||||
box_size: (-> (@get('dpm') || 0 ) * @get('section_element.box_size')).property('dpm', 'section_element.box_size')
|
|
||||||
style: Ember.computed 'offsetX', 'offsetY', 'box_size', 'section_element.rotation', ->
|
|
||||||
"position:absolute;width:#{@get('box_size')}px;height:#{@get('box_size')}px;left:#{@get('offsetX')}px;top:#{@get('offsetY')}px".htmlSafe()
|
|
||||||
positionChange: (position)->
|
|
||||||
dpm = @get('dpm')
|
|
||||||
return if !dpm or parseFloat(dpm) is 0
|
|
||||||
@get('section_element').setProperties
|
|
||||||
position_x: position.left / dpm
|
|
||||||
position_y: position.top / dpm
|
|
||||||
click: ->
|
|
||||||
if @get('section.editmode')
|
|
||||||
@toggleProperty('show_handles')
|
|
||||||
else
|
|
||||||
@set 'spinning', true
|
|
||||||
Ember.run.later (=> @set('spinning', false)), 2000
|
|
||||||
showHandles: Ember.computed.and 'show_handles', 'section.editmode'
|
|
||||||
actions:
|
|
||||||
rotateLeft: ->
|
|
||||||
@get('section_element').invoke "rotateLeft"
|
|
||||||
rotateRight: ->
|
|
||||||
@get('section_element').invoke "rotateRight"
|
|
||||||
removeSectionElement: -> @get('section_element').destroyRecord()
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
App.SectionTabHeaderComponent= Ember.Component.extend
|
|
||||||
layoutName: 'section/tab-header'
|
|
||||||
classNameBindings: ['section_header_class', 'section_active:active']
|
|
||||||
classNames: ['section-tab-header']
|
|
||||||
click: (e)->
|
|
||||||
@set 'globals.active_section', @get('section')
|
|
||||||
@get('targetObject').transitionToRoute 'section', @get('section.id')
|
|
||||||
|
|
||||||
section_header_class: (-> "section-tab-header-#{@get('section.id')}").property()
|
|
||||||
#dragEntered: (view)->
|
|
||||||
#@$().addClass('table-hover')
|
|
||||||
#return false
|
|
||||||
# Changing the route for now is too difficult. Just do a move
|
|
||||||
#if view.constructor.toString().match(/SectionTableView$/)
|
|
||||||
#@get('controller').transitionToRoute 'section', @get('section')
|
|
||||||
#dragLeft: -> @$().removeClass('table-hover')
|
|
||||||
#dropped: (view)->
|
|
||||||
#if view.constructor.toString().match(/SectionTableView$/)
|
|
||||||
#table = view.get('section')
|
|
||||||
#section = @get('section')
|
|
||||||
#if section isnt table.get('section')
|
|
||||||
#section.get('tables').addObject table
|
|
||||||
#table.save()
|
|
||||||
#@get('controller').transitionToRoute 'section', section.get('id')
|
|
||||||
#didInsertElement: ->
|
|
||||||
#@$el = $ @get('element')
|
|
||||||
|
|
||||||
section_active: (->
|
|
||||||
current_section = @get('targetObject.model.id')
|
|
||||||
view_section = @get('section.id')
|
|
||||||
current_section == view_section
|
|
||||||
).property('targetObject.model.id')
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
App.SectionTableComponent = Ember.Component.extend DragNDrop.Draggable,
|
|
||||||
layoutName: 'section/table'
|
|
||||||
classNames: ['section-table']
|
|
||||||
attributeBindings: ['style']
|
|
||||||
|
|
||||||
# required bindings
|
|
||||||
dpm: 1
|
|
||||||
section: null
|
|
||||||
table: null
|
|
||||||
|
|
||||||
classNameBindings: [
|
|
||||||
'table.active_list.active:occupied',
|
|
||||||
'section.editmode:draggable',
|
|
||||||
'table.active_list.needs_help:needs_help',
|
|
||||||
'table.active_list.needs_payment:needs_payment',
|
|
||||||
'table.active_list.has_active_orders:active_order',
|
|
||||||
'right_half:right-half',
|
|
||||||
'uniqueClass'
|
|
||||||
]
|
|
||||||
uniqueClass: (->
|
|
||||||
"section-table-#{@get('table.id')}"
|
|
||||||
).property('table.id')
|
|
||||||
right_half: Ember.computed 'table.position_x', 'table.width', 'table.section.width', ->
|
|
||||||
@get('table.position_x') + (@get('table.width') / 2) > (@get('table.section.width') / 2)
|
|
||||||
offsetX: (->
|
|
||||||
(@get('dpm') || 0) * (@get('table.position_x') || 0)
|
|
||||||
).property('dpm', 'table.position_x')
|
|
||||||
offsetY: (->
|
|
||||||
(@get('dpm') || 0) * (@get('table.position_y') || 0)
|
|
||||||
).property('dpm', 'table.position_y')
|
|
||||||
|
|
||||||
myHeight: (-> Math.max((@get('dpm') || 0 ) * @get('table.height'), 60)).property('dpm', 'table.height')
|
|
||||||
myWidth: (-> Math.max((@get('dpm') || 0 ) * @get('table.width'), 60)).property('dpm', 'table.width')
|
|
||||||
#style: (->
|
|
||||||
#"position:absolute;width:83px;height:48px;left:#{@get('offsetX')}px;top:#{@get('offsetY')}px"
|
|
||||||
#).property('offsetX', 'offsetY')
|
|
||||||
style: Ember.computed 'offsetX', 'offsetY', 'myWidth', 'myHeight', ->
|
|
||||||
"position:absolute;width:#{@get('myWidth')}px;height:#{@get('myHeight')}px;left:#{@get('offsetX')}px;top:#{@get('offsetY')}px".htmlSafe()
|
|
||||||
|
|
||||||
draggable: Ember.computed.alias 'section.editmode'
|
|
||||||
positionChange: (position)->
|
|
||||||
dpm = @get('dpm')
|
|
||||||
return if !dpm or parseFloat(dpm) is 0
|
|
||||||
|
|
||||||
@get('table').setProperties
|
|
||||||
position_x: position.left / dpm
|
|
||||||
position_y: position.top / dpm
|
|
||||||
#@get('table').save()
|
|
||||||
click: (evt)->
|
|
||||||
evt.preventDefault()
|
|
||||||
if @get('section.editmode')
|
|
||||||
table = @get('table')
|
|
||||||
@modal 'table_edit',
|
|
||||||
model: table
|
|
||||||
close: -> table.rollbackAttributes()
|
|
||||||
else
|
|
||||||
@$('.table-actions').toggle() if @$el.hasClass('occupied')
|
|
||||||
false
|
|
||||||
didInsertElement: ->
|
|
||||||
@$el = @$()
|
|
||||||
@$('.table-actions').hide()
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
App.SectionTablesComponent = Ember.Component.extend DragNDrop.Droppable,
|
|
||||||
classNames: ['well', 'section-tables-container', 'section-tables-active']
|
|
||||||
classNameBindings: ['section.editmode:editing']
|
|
||||||
layoutName: 'section/tables'
|
|
||||||
dpm: 1
|
|
||||||
dropped: (component, position)->
|
|
||||||
component.positionChange(position, @get('section.tables'))
|
|
||||||
handleDimensionChange: ->
|
|
||||||
return unless @get('element')
|
|
||||||
@$el = $(@get('element'))
|
|
||||||
viewport_width = $(window).width()
|
|
||||||
viewport_height = $(window).height() - 52
|
|
||||||
section_width = @get('section.width')
|
|
||||||
section_height = @get('section.height')
|
|
||||||
dpm = viewport_width / section_width # try to fill the width
|
|
||||||
if dpm * section_height > viewport_height
|
|
||||||
# Height goes of the window, not what we want, adjust to fit height
|
|
||||||
dpm = viewport_height / section_height
|
|
||||||
@$el.css 'width', dpm * section_width
|
|
||||||
@$el.css 'height', dpm * section_height
|
|
||||||
console.log "dpm: #{dpm}"
|
|
||||||
@set 'dpm', dpm
|
|
||||||
observeSectionDimensions: (->
|
|
||||||
@handleDimensionChange()
|
|
||||||
).observes('section.height', 'section.width')
|
|
||||||
didInsertElement: ->
|
|
||||||
# the first observable event is triggered without the container having its dimensions
|
|
||||||
@get('section').notifyPropertyChange('width') #.notifyPropertyChange('height')
|
|
||||||
that = this
|
|
||||||
$(window).on 'orientationchange resize', -> Ember.run( -> that.handleDimensionChange())
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#App.SectionView = Ember.View.extend {}
|
|
||||||
#initFoundation: (->
|
|
||||||
#@$().foundation()
|
|
||||||
#).on('didInsertElement')
|
|
||||||
#didInsertElement: ->
|
|
||||||
#@$().foundation()
|
|
||||||
#true
|
|
||||||
#$(document).on 'load', '[data-dropdown]', (a,b,c)->
|
|
||||||
#true
|
|
||||||
#$(document).on 'change', '[data-dropdown]', (a,b,c)->
|
|
||||||
#true
|
|
||||||
#$(document).on 'ready', '[data-dropdown]', (a,b,c)->
|
|
||||||
#true
|
|
||||||
#$(document).on 'click', '[data-dropdown]', (a,b,c)->
|
|
||||||
#true
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
App.SectionsHeaderSectionComponent = Ember.Component.extend
|
|
||||||
tagName: 'dd'
|
|
||||||
attributeBindings: ['dataSectionId:data-section']
|
|
||||||
dataSectionId: Ember.computed 'section.id', -> @get('section.id')
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
App.SectionsHeaderComponent = Ember.Component.extend
|
|
||||||
classNames: ['sections-switcher-container', 'main-section-header']
|
|
||||||
sections: Ember.computed -> @store.peekAll('section')
|
|
||||||
actions:
|
|
||||||
setSection: (section)->
|
|
||||||
if section and section is @get('active_section')
|
|
||||||
# click on already active section
|
|
||||||
#return @transitionTo('section', section.id)
|
|
||||||
#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('active_section', section)
|
|
||||||
didInsertElement: ->
|
|
||||||
@$('dd').removeClass('active')
|
|
||||||
section = @get('active_section')
|
|
||||||
@$("[data-section=#{if section then section.id else 'all'}]").addClass('active')
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
App.SuppliersSwitcherComponent = Ember.Component.extend
|
|
||||||
classNames: ['suppliers-switcher-container']
|
|
||||||
suppliers: (-> @get('targetObject.store').peekAll 'supplier').property()
|
|
||||||
other_suppliers: Ember.computed 'suppliers.[]',
|
|
||||||
-> @get('suppliers').rejectBy 'id', @get('globals.current_supplier.id')
|
|
||||||
actions:
|
|
||||||
switchTo: (supplier)->
|
|
||||||
window.location = Routes.switch_to_suppliers_supplier_path(supplier.get('id'))
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
App.TableNumberWithInfoComponent = Ember.Component.extend
|
|
||||||
tagName: 'span'
|
|
||||||
layoutName: 'table_number_with_info'
|
|
||||||
classNames: 'table-number-with-info'
|
|
||||||
click: ->
|
|
||||||
$el = $(@get('element')).find('.extra-list-info')
|
|
||||||
return $el.hide() if $el.is(':visible')
|
|
||||||
$el.show()
|
|
||||||
$.get Routes.extra_info_suppliers_list_path(@get('context.id')), (res)->
|
|
||||||
$el.html(res)
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
App.UsersButtonsComponent = Ember.Component.extend
|
|
||||||
classNames: ['users-buttons']
|
|
||||||
actions:
|
|
||||||
userClick: (user)->
|
|
||||||
@modal 'user_info',
|
|
||||||
title_path: 'modal.user_info.title'
|
|
||||||
model: user
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
App.ApplicationController = Ember.Controller.extend
|
|
||||||
#init: ->
|
|
||||||
#success = (supplier)=>
|
|
||||||
## A supplier record with id current and with the content of the returned supplier is created
|
|
||||||
## at the moment remove the dummy supplier, this should be resolved by Ember eventually
|
|
||||||
#if error_supplier = @store.peekAll('supplier').findBy('id', 'current')
|
|
||||||
#error_supplier.eraseRecord()
|
|
||||||
#@set 'supplier', supplier
|
|
||||||
|
|
||||||
#error = (emberError)=>
|
|
||||||
#if error_supplier = @store.peekAll('supplier').findBy('id', 'current')
|
|
||||||
#error_supplier.eraseRecord()
|
|
||||||
#@set 'supplier', null
|
|
||||||
#@store.findRecord('supplier', 'current').then success, error
|
|
||||||
# @set 'supplier', @store.findRecord('supplier', supplier_id)
|
|
||||||
#current_employee: (-> @get('employee') ).property('employee')
|
|
||||||
actions:
|
|
||||||
signOut: ->
|
|
||||||
window.location = Routes.destroy_employee_session_path()
|
|
||||||
showSupplierStatusInfo: ->
|
|
||||||
@modal 'supplier_status_info',
|
|
||||||
model: @get('globals.current_supplier')
|
|
||||||
title_path: 'supplier_status_info.title'
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
App.EmployeesController = Ember.Controller.extend
|
|
||||||
employeeSorting: ['name']
|
|
||||||
employees: Ember.computed.sort 'model', 'employeeSorting'
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
App.IndexController = Ember.Controller.extend
|
|
||||||
show_lists: true
|
|
||||||
show_orders: true
|
|
||||||
loading_data: true
|
|
||||||
lists: Ember.computed -> @store.peekAll('list')
|
|
||||||
orders: Ember.computed -> @store.peekAll('order')
|
|
||||||
sections: Ember.computed -> @store.peekAll('section')
|
|
||||||
#active_section: Ember.computed.alias 'globals.active_section'
|
|
||||||
active_lists: Ember.computed 'lists.@each.state', 'globals.active_section.id', 'lists.@each.table', -> # table needed for when list changes table
|
|
||||||
@get('orders') # trigger orders, otherwise observers are not initialized/triggered (active_orders)
|
|
||||||
if section_id = @get('globals.active_section.id')
|
|
||||||
lists = @get('lists').filter (list) =>
|
|
||||||
return false unless list.get('state') is 'active'
|
|
||||||
list.get('table.section.id') is section_id
|
|
||||||
else
|
|
||||||
lists = @get('lists').filterBy('state', 'active')
|
|
||||||
lists.sortBy('created_at') # Not reversed, oldest on top, start with oldest order first, work your way down :-) Customer happyness
|
|
||||||
|
|
||||||
active_orders: Ember.computed 'active_lists.[]', 'orders.@each.state', ->
|
|
||||||
orders = Ember.A()
|
|
||||||
@get('active_lists').forEach (list)->
|
|
||||||
list.get('orders').filterBy('needs_supplier_attention').forEach (order)->
|
|
||||||
orders.push order
|
|
||||||
orders.sortBy('created_at') # Not reversed, oldest on top, start with oldest order first, work your way down :-) Customer happyness
|
|
||||||
|
|
||||||
show_lists_table: Ember.computed 'show_lists', 'active_lists.[]', ->
|
|
||||||
@get('show_lists') and @get('active_lists.length')
|
|
||||||
show_orders_table: Ember.computed 'show_orders', 'active_orders.[]', ->
|
|
||||||
@get('show_orders') and @get('active_orders.length')
|
|
||||||
list_number_info: (-> " (#{@get('active_lists.length')})").property('active_lists.[]')
|
|
||||||
order_number_info: (-> " (#{@get('active_orders.length')})").property('active_orders.[]')
|
|
||||||
|
|
||||||
actions:
|
|
||||||
toggleDashboardLists: -> @set 'show_lists', !@get('show_lists')
|
|
||||||
toggleDashboardOrders: ->@set 'show_orders', !@get('show_orders')
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
App.ListController = Ember.Controller.extend
|
|
||||||
list: (-> @get('model')).property('model')
|
|
||||||
showTotal: (->
|
|
||||||
if @get('list.orders.length') && @get('list.orders.length') > 1 then true else false
|
|
||||||
).property('list.orders.length')
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
App.ListsIndexController = Ember.Controller.extend
|
|
||||||
loading: true
|
|
||||||
date: (new Date()).toISOString().substr(0,10) # 2015-11-02
|
|
||||||
dateChanged: (->
|
|
||||||
return @set('loading', false) unless date = @get('date')
|
|
||||||
@set 'loading', true
|
|
||||||
@store.query 'list', date: date
|
|
||||||
.then => @set('loading', false)
|
|
||||||
).observes('date').on('init')
|
|
||||||
lists: Ember.computed -> @store.peekAll('list')
|
|
||||||
|
|
||||||
sorted_lists: Ember.computed 'date', 'lists.[]', ->
|
|
||||||
lists = @get('lists')
|
|
||||||
if selected_date = @get('date')
|
|
||||||
lists = lists.filter (list)->
|
|
||||||
return false unless list_creation_date = list.get('created_at')
|
|
||||||
list_creation_date = list_creation_date.toISOString().substring(0,10) if typeof(list_creation_date) is 'object'
|
|
||||||
selected_date is list_creation_date
|
|
||||||
lists.sortBy('created_at').reverseObjects()
|
|
||||||
pricesList: Ember.computed.mapBy 'sorted_lists', 'price'
|
|
||||||
date_lists_total: Ember.computed.sum 'pricesList'
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
App.MenuController = Ember.Controller.extend
|
|
||||||
product_code_filter: ''
|
|
||||||
product_categories: (-> @store.peekAll('product_category')).property()
|
|
||||||
filter: null
|
|
||||||
sorted_product_categories: (->
|
|
||||||
list = @get('product_categories')
|
|
||||||
if filter_day = @get('filter.day')
|
|
||||||
list = list.filterBy "active_on_#{filter_day}"
|
|
||||||
if filter_minute = @get('filter.minute_of_day')
|
|
||||||
list = list.filter (r) -> r.get('full_day') or (filter_minute >= r.get('start_from') and filter_minute <= r.get('end_on'))
|
|
||||||
|
|
||||||
list.sortBy('position')
|
|
||||||
).property('product_categories.[]', 'product_categories.@each.position', 'filter.day', 'filter.minute_of_day')
|
|
||||||
product_code_filter_placeholder: t('product.code_filter.placeholder')
|
|
||||||
actions:
|
|
||||||
editProductCategory: (product_category)->
|
|
||||||
@modal 'product_category_edit',
|
|
||||||
model: product_category
|
|
||||||
close: -> product_category.rollbackAttributes()
|
|
||||||
destroy_text_path: 'product_category.modal.destroy_confirm_text'
|
|
||||||
|
|
||||||
moveProductCategory: (product_category)->
|
|
||||||
@modal 'product_category_move',
|
|
||||||
model: product_category
|
|
||||||
newProductCategory: ->
|
|
||||||
@modal 'product_category_new',
|
|
||||||
model: @store.createRecord('product_category', position: @get('product_categories.length'))
|
|
||||||
close: -> @get('model').deleteRecord()
|
|
||||||
addProduct: (product_category)->
|
|
||||||
product = @store.createRecord 'product', position: product_category.get('products.length')
|
|
||||||
product_category.get('products').addObject product
|
|
||||||
-38
@@ -1,38 +0,0 @@
|
|||||||
App.modals.AddSectionController = @App.modals.BaseController.extend
|
|
||||||
section_title: ''
|
|
||||||
section_width: 15
|
|
||||||
section_height: 8
|
|
||||||
title_path: 'section.add_section.modal.title'
|
|
||||||
actions:
|
|
||||||
addSection: ->
|
|
||||||
@set 'alert_message', null
|
|
||||||
title = @get('section_title')
|
|
||||||
width = @get('section_width')
|
|
||||||
height = @get('section_height')
|
|
||||||
unless title
|
|
||||||
@set 'alert_message', error_message
|
|
||||||
attribute: t('attributes.section.title')
|
|
||||||
message: 'blank'
|
|
||||||
return
|
|
||||||
unless parseInt(width) > 0
|
|
||||||
@set 'alert_message', error_message
|
|
||||||
attribute: t('attributes.section.width')
|
|
||||||
message: 'greater_than'
|
|
||||||
count: 0
|
|
||||||
return
|
|
||||||
unless parseInt(height) > 0
|
|
||||||
@set 'alert_message', error_message
|
|
||||||
attribute: t('attributes.section.height')
|
|
||||||
message: 'greater_than'
|
|
||||||
count: 0
|
|
||||||
return
|
|
||||||
section = @store.createRecord 'section',
|
|
||||||
title: title
|
|
||||||
width: width
|
|
||||||
height: height
|
|
||||||
section.save().then (s)=>
|
|
||||||
@set 'section_title', ''
|
|
||||||
@send 'closeModal'
|
|
||||||
@transitionToRoute 'section', s.id
|
|
||||||
, @save_error.bind(@)
|
|
||||||
|
|
||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
App.modals.AddSectionElementController = @App.modals.BaseController.extend
|
|
||||||
title_path: 'section_element.modal.title'
|
|
||||||
svg_elements: (-> @store.findAll 'svg_element').property()
|
|
||||||
actions:
|
|
||||||
addSectionElement: (svg_element)->
|
|
||||||
section_element = @store.createRecord 'section-element'
|
|
||||||
section_element.copy_values svg_element
|
|
||||||
section_element.set 'section', @get('model')
|
|
||||||
@send 'ok'
|
|
||||||
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
@App.modals.BaseController = Ember.Controller.extend
|
|
||||||
alert_message: ""
|
|
||||||
modal_options: {}
|
|
||||||
title: (->
|
|
||||||
# return title if directly set by options
|
|
||||||
return @get('modal_options.title') if @get('modal_options.title')
|
|
||||||
# return translated title_path if directly set by controller
|
|
||||||
translation_params = {}
|
|
||||||
if model = @get('model')
|
|
||||||
translation_params = model.toJSON() if model.toJSON
|
|
||||||
|
|
||||||
# return translated title_path if directly set by options
|
|
||||||
# return translated title_path if directly set by controller
|
|
||||||
if title_path = @get('modal_options.title_path') || @get('title_path')
|
|
||||||
return tspan(title_path, translation_params).htmlSafe()
|
|
||||||
# return translated title_path if directly set by options
|
|
||||||
#return tspan(@get('modal_options.title_path'), translation_params).htmlSafe() if @get('modal_options.title_path')
|
|
||||||
# return translated title_path if directly set by controller
|
|
||||||
#return tspan(@title_path, translation_params).htmlSafe() if @title_path
|
|
||||||
# infer title path based on controller name App.modals.AddSectionController => add_section
|
|
||||||
underscored = `this.constructor.toString().substr(11).replace(/Controller$/, '').underscore()`
|
|
||||||
#underscored = @constructor.toString().replace(/[a-zA-Z_-]+\@controller:modals\//, '').replace(/:$/, '').underscore() # ember cli
|
|
||||||
# find translated title or humanize the controller name
|
|
||||||
if convention_translation = ttry("modal.#{underscored}.title", translation_params)
|
|
||||||
tspan("modal.#{underscored}.title", translation_params).htmlSafe()
|
|
||||||
else
|
|
||||||
underscored.capitalize().replace(/_/, ' ')
|
|
||||||
).property('model.id', 'modal_options.title_path')
|
|
||||||
body: (->
|
|
||||||
@get('modal_options.body')
|
|
||||||
).property('modal_options.body')
|
|
||||||
save_error: (error)->
|
|
||||||
switch error.status
|
|
||||||
when 403
|
|
||||||
@set 'alert_message', 'Unauthorized action'
|
|
||||||
else
|
|
||||||
@set 'alert_message', 'Something went wrong'
|
|
||||||
save_success: ->
|
|
||||||
if save_callback = @get('modal_options.save')
|
|
||||||
save_callback.apply(@)
|
|
||||||
@set 'alert_message', ''
|
|
||||||
@send 'closeModal'
|
|
||||||
|
|
||||||
actions:
|
|
||||||
close: ->
|
|
||||||
if close = @get('modal_options.close')
|
|
||||||
close.apply(@)
|
|
||||||
unless @preventClose
|
|
||||||
@set 'alert_message', ''
|
|
||||||
@send 'closeModal'
|
|
||||||
closeOnOverlay: ->
|
|
||||||
@send('close') if @get('modal_options.closeOnOverlay')
|
|
||||||
false
|
|
||||||
modalClick: ->
|
|
||||||
@send('close') if @get('modal_options.closeOnModalClick')
|
|
||||||
false
|
|
||||||
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 @save_success.bind(@), @save_error.bind(@)
|
|
||||||
#@send 'closeModal' unless @preventClose
|
|
||||||
rollback_and_close: ->
|
|
||||||
@get('model').rollbackAttributes()
|
|
||||||
@send 'close'
|
|
||||||
destroyRecord: ->
|
|
||||||
my_scope = @
|
|
||||||
destroy_callback = @get('modal_options.destroy_callback')
|
|
||||||
@modal 'confirm',
|
|
||||||
title_path: @get('modal_options.destroy_text_path') || 'general.destroy.text'
|
|
||||||
model: @get('model')
|
|
||||||
ok: ->
|
|
||||||
@get('model').destroyRecord()
|
|
||||||
destroy_callback.call(my_scope) if destroy_callback
|
|
||||||
@send 'closeModal' unless @preventClose
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
App.modals.ChangeListTableController = @App.modals.BaseController.extend
|
|
||||||
list_moving: false
|
|
||||||
sections: Ember.computed -> @store.peekAll('section')
|
|
||||||
actions:
|
|
||||||
moveToTable: (table)->
|
|
||||||
@set 'list_moving', true
|
|
||||||
Ember.$.post Routes.change_table_suppliers_list_path(@get('model.id')), {table_id: table.id}, (response)=>
|
|
||||||
#@set "model.table", table
|
|
||||||
@send 'close'
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
App.modals.CloseListController = App.modals.BaseController.extend
|
|
||||||
title_path: 'list.close.modal.title'
|
|
||||||
actions:
|
|
||||||
confirm: ->
|
|
||||||
@get('model').invoke 'close'
|
|
||||||
#model = @get('model')
|
|
||||||
#if model.then then model.then((l) -> l.close()) else model.close()
|
|
||||||
@send 'closeModal'
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
App.modals.ConfirmController = App.modals.BaseController.extend
|
|
||||||
title_path: 'confirm.title'
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
App.modals.EmployeeEditController = App.modals.BaseController.extend
|
|
||||||
isNotSelf: (->
|
|
||||||
@get('model.id') isnt @get('globals.current_employee.id')
|
|
||||||
).property('model.id')
|
|
||||||
|
|
||||||
colors: (->
|
|
||||||
# taken from http://www.somacon.com/p142.php
|
|
||||||
[
|
|
||||||
'#458B74'
|
|
||||||
'#838B8B'
|
|
||||||
'#8B7D6B'
|
|
||||||
'#00008B'
|
|
||||||
'#8B2323'
|
|
||||||
'#8A2BE2'
|
|
||||||
'#458B00'
|
|
||||||
'#EEAD0E'
|
|
||||||
'#FF1493'
|
|
||||||
'#8B0A50'
|
|
||||||
]
|
|
||||||
).property()
|
|
||||||
actions:
|
|
||||||
setColor: (color)->
|
|
||||||
@set 'model.color', color
|
|
||||||
-2
@@ -1,2 +0,0 @@
|
|||||||
App.modals.ProductCategoryEditController = App.modals.BaseController.extend
|
|
||||||
title_path: 'product_category.modal.edit.title'
|
|
||||||
-31
@@ -1,31 +0,0 @@
|
|||||||
App.modals.ProductCategoryMoveController = App.modals.BaseController.extend
|
|
||||||
title_path: 'product_category.modal.move.title'
|
|
||||||
actions:
|
|
||||||
moveBelow: (below_product_category)->
|
|
||||||
position = 0
|
|
||||||
unless below_product_category
|
|
||||||
@set 'model.position', position
|
|
||||||
@get('model').save()
|
|
||||||
position += 1
|
|
||||||
for product_category in @get('product_categories')
|
|
||||||
product_category.set('position', position)
|
|
||||||
product_category.save()
|
|
||||||
if below_product_category and product_category.id is below_product_category.id
|
|
||||||
@set 'model.position', position += 1
|
|
||||||
@get('model').save()
|
|
||||||
position += 1
|
|
||||||
|
|
||||||
@send 'close'
|
|
||||||
|
|
||||||
product_categories: (->
|
|
||||||
# do not return self, since place below should not include self option
|
|
||||||
@store.peekAll('product_category').rejectBy('id', @get('model.id')).sortBy('position')
|
|
||||||
).property('model.id')
|
|
||||||
|
|
||||||
sortableUpdate: (ids)->
|
|
||||||
products = @get('model.products')
|
|
||||||
ids.forEach (id, i)->
|
|
||||||
if product = products.findProperty('id', id)
|
|
||||||
#TODO: raise in frontend if product.get('isDirty'). Cannot modify position of product containing non persisted change
|
|
||||||
product.set('position', i)
|
|
||||||
product.save() if product.get('hasDirtyAttributes')
|
|
||||||
-2
@@ -1,2 +0,0 @@
|
|||||||
App.modals.ProductCategoryNewController = App.modals.BaseController.extend
|
|
||||||
title_path: 'product_category.modal.new.title'
|
|
||||||
-27
@@ -1,27 +0,0 @@
|
|||||||
App.modals.SectionAddTablesController = App.modals.BaseController.extend
|
|
||||||
number_start: 100
|
|
||||||
number_end: 100
|
|
||||||
title_path: 'section.add_tables.modal.title'
|
|
||||||
#number_start: Ember.computed
|
|
||||||
#get: ->
|
|
||||||
#@_super() || 100
|
|
||||||
#set: (key, value)->
|
|
||||||
#@set 'number_end', value if value
|
|
||||||
#@_super()
|
|
||||||
actions:
|
|
||||||
addTables: ->
|
|
||||||
s = parseInt(@get('number_start'))
|
|
||||||
return @set('alert_message', t('section.add_tables.modal.invalid_start_number')) unless isFinite(s)
|
|
||||||
e = parseInt(@get('number_end'))
|
|
||||||
return @set('alert_message', t('section.add_tables.modal.invalid_end_number')) unless isFinite(e)
|
|
||||||
if e < s
|
|
||||||
@set 'number_start', e
|
|
||||||
@set 'number_end', s
|
|
||||||
s = @get('number_start')
|
|
||||||
e = @get('number_end')
|
|
||||||
number_of_tables = 1 + e - s
|
|
||||||
return @set('alert_message', t('section.add_tables.modal.too_many', count: number_of_tables)) if number_of_tables > 10
|
|
||||||
for number in [s..e]
|
|
||||||
@store.createRecord 'table', number: number, section: @get('model')
|
|
||||||
|
|
||||||
@send 'close'
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
App.modals.SectionAreaController = App.modals.BaseController.extend
|
|
||||||
colors: (->
|
|
||||||
# taken from http://www.somacon.com/p142.php
|
|
||||||
[
|
|
||||||
'#AAAAAA'
|
|
||||||
'#458B74'
|
|
||||||
'#838B8B'
|
|
||||||
'#8B7D6B'
|
|
||||||
'#00008B'
|
|
||||||
'#8B2323'
|
|
||||||
'#8A2BE2'
|
|
||||||
'#458B00'
|
|
||||||
'#EEAD0E'
|
|
||||||
'#FF1493'
|
|
||||||
'#8B0A50'
|
|
||||||
]
|
|
||||||
).property()
|
|
||||||
actions:
|
|
||||||
setColor: (color)->
|
|
||||||
@set 'model.color', color
|
|
||||||
-51
@@ -1,51 +0,0 @@
|
|||||||
App.modals.SectionArrangeTablesController = App.modals.BaseController.extend
|
|
||||||
title_path: 'section.arrange_tables.modal.title'
|
|
||||||
arrange_type: 'distributed' # can be distributed, by_row or by_column
|
|
||||||
row_count: 2
|
|
||||||
column_count: 2
|
|
||||||
alert_message: ''
|
|
||||||
#isDistributed: ~> @arrange_type is 'distributed'
|
|
||||||
#isByRow: ~> @arrange_type is 'by_row'
|
|
||||||
#isByColumn: ~> @arrange_type is 'by_column'
|
|
||||||
isDistributed: (->@get('arrange_type') is 'distributed').property('arrange_type')
|
|
||||||
isByRow: (->@get('arrange_type') is 'by_row').property('arrange_type')
|
|
||||||
isByColumn: (->@get('arrange_type') is 'by_column').property('arrange_type')
|
|
||||||
canArrangeTables: (->
|
|
||||||
unless parseFloat(@get('model.width')) > 0 and parseFloat(@get('model.height')) > 0
|
|
||||||
@set 'alert_message', t('section.arrange_tables.modal.cannot_arrange')
|
|
||||||
return false
|
|
||||||
@set 'alert_message', ''
|
|
||||||
true
|
|
||||||
).property('model.width', 'model.height')
|
|
||||||
actions:
|
|
||||||
arrangeTables: ->
|
|
||||||
return unless @isValid()
|
|
||||||
switch @get('arrange_type')
|
|
||||||
when 'by_row'
|
|
||||||
@get('model').invoke 'arrange_tables_in_rows_of', parseInt(@get('row_count'))
|
|
||||||
when 'by_column'
|
|
||||||
@get('model').invoke 'arrange_tables_in_columns_of', parseInt(@get('column_count'))
|
|
||||||
else
|
|
||||||
@get('model').invoke 'arrange_tables_in_grid'
|
|
||||||
@send 'close'
|
|
||||||
|
|
||||||
makeDistributed: ->
|
|
||||||
@set 'arrange_type', 'distributed'
|
|
||||||
@set 'alert_message', ''
|
|
||||||
makeByRow: ->
|
|
||||||
@set 'arrange_type', 'by_row'
|
|
||||||
@set 'alert_message', ''
|
|
||||||
makeByColumn: ->
|
|
||||||
@set 'arrange_type', 'by_column'
|
|
||||||
@set 'alert_message', ''
|
|
||||||
isValid: ->
|
|
||||||
switch @get('arrange_type')
|
|
||||||
when 'by_row'
|
|
||||||
if parseInt(@get('row_count')) < 1
|
|
||||||
@set 'alert_message', "Must at least be 1"
|
|
||||||
return false
|
|
||||||
when 'by_column'
|
|
||||||
if parseInt(@get('column_count')) < 1
|
|
||||||
@set 'alert_message', "Must at least be 1"
|
|
||||||
return false
|
|
||||||
true
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
App.modals.SelectEmployeeController = App.modals.BaseController.extend
|
|
||||||
employee: null
|
|
||||||
title_path: 'employee.select_modal.title'
|
|
||||||
employees: (-> @get('all_employees').filterBy('active') ).property('all_employees.@each.active')
|
|
||||||
all_employees: (-> @store.peekAll('employee')).property()
|
|
||||||
actions:
|
|
||||||
selectEmployee: (employee)->
|
|
||||||
@set 'employee', employee
|
|
||||||
@send 'ok'
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
App.modals.TableEditController = App.modals.BaseController.extend
|
|
||||||
title_path: 'table.modal.title'
|
|
||||||
sections: (-> @store.peekAll('section')).property()
|
|
||||||
#setSelectedSection: (-> @set 'selectedSection', @get('model.section')).on('init')
|
|
||||||
actions:
|
|
||||||
saveTable: ->
|
|
||||||
@send 'save'
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#App.MyScheduleController = Ember.Controller.extend
|
|
||||||
# actions:
|
|
||||||
# debugger: -> debugger
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
App.OrdersDisplayController = Ember.Controller.extend
|
|
||||||
sections: Ember.computed -> @store.peekAll('section')
|
|
||||||
orders: Ember.computed 'model.[]', 'globals.active_section.id', ->
|
|
||||||
orders = @get('model').filterBy('needs_supplier_attention')
|
|
||||||
orders = orders.filterBy('list.table.section.id', id) if id = @get('globals.active_section.id')
|
|
||||||
orders.sortBy('created_at') # Not reversed, oldest on top, start with oldest order first :-) Customer happyness
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#App.ScheduleController = Ember.Controller.extend
|
|
||||||
# event_changed: (event)->
|
|
||||||
# @store.findRecord('employee-shift', event.id).then (employee_shift)->
|
|
||||||
# employee_shift.set 'start_from', event.start
|
|
||||||
# employee_shift.set 'end_on', event.end
|
|
||||||
# employee_shift.save()
|
|
||||||
# editEvent: (id, callbacks)->
|
|
||||||
# if employee_shift = @store.peekRecord('employee-shift', id)
|
|
||||||
# @modal 'employee_shift',
|
|
||||||
# title_path: 'employee_shift.modal.title'
|
|
||||||
# destroy_text_path: 'employee_shift.modal.destroy_confirmation'
|
|
||||||
# model: employee_shift
|
|
||||||
# save: -> callbacks.save.call(@, employee_shift) if callbacks.save
|
|
||||||
# destroy_callback: -> callbacks.destroy.call(@, employee_shift) if callbacks.destroy
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
App.SectionController = Ember.Controller.extend
|
|
||||||
#needs: ['application', 'sections', 'section'] #wtf? section, otherwise an Ember error
|
|
||||||
actions:
|
|
||||||
makeEditable: ->
|
|
||||||
@set('model.editmode', true)
|
|
||||||
false
|
|
||||||
finishEditable: ->
|
|
||||||
@set('model.editmode', false)
|
|
||||||
@get('model').save()
|
|
||||||
@get('model.tables').filterBy('hasDirtyAttributes').invoke 'save'
|
|
||||||
@get('model.section_elements').filterBy('hasDirtyAttributes').invoke 'save'
|
|
||||||
@get('model.section_areas').filterBy('hasDirtyAttributes').invoke 'save'
|
|
||||||
rollbackEditable: ->
|
|
||||||
@get('model').rollbackAttributes()
|
|
||||||
tables = @get('model.tables')
|
|
||||||
tables.filterBy('isNew').invoke 'unloadRecord'
|
|
||||||
tables.rejectBy('isNew').invoke 'rollbackAttributes'
|
|
||||||
|
|
||||||
section_elements = @get('model.section_elements')
|
|
||||||
section_elements.filterBy('isNew').invoke 'unloadRecord'
|
|
||||||
section_elements.rejectBy('isNew').invoke 'rollbackAttributes'
|
|
||||||
|
|
||||||
section_areas = @get('model.section_areas')
|
|
||||||
section_areas.filterBy('isNew').invoke 'unloadRecord'
|
|
||||||
section_areas.rejectBy('isNew').invoke 'rollbackAttributes'
|
|
||||||
@set('model.editmode', false)
|
|
||||||
addSection: -> @modal 'add_section', model: @get('model')
|
|
||||||
addTables: -> @modal 'section_add_tables', model: @get('model')
|
|
||||||
arrangeTables: -> @modal 'section_arrange_tables', model: @get('model')
|
|
||||||
destroySection: ->
|
|
||||||
@modal 'confirm',
|
|
||||||
title_path: 'helpers.links.are_you_sure'
|
|
||||||
ok: =>
|
|
||||||
@get('model').destroyRecord()
|
|
||||||
@transitionToRoute 'sections'
|
|
||||||
addSectionElement: ->
|
|
||||||
@modal 'add_section_element', model: @get('model')
|
|
||||||
addSectionArea: ->
|
|
||||||
section_area = @store.createRecord('section-area')
|
|
||||||
section_area.set 'section', @get('model')
|
|
||||||
#@set 'model.editmode', true
|
|
||||||
@modal 'section_area',
|
|
||||||
title_path: 'section_area.add_button'
|
|
||||||
model: section_area
|
|
||||||
textures: ['wood1', 'wood2']
|
|
||||||
|
|
||||||
#sections: (-> @get('controllers.sections.model')).property('controllers.sections.model')
|
|
||||||
sections_controller: Ember.inject.controller('sections')
|
|
||||||
sections: Ember.computed.alias 'sections_controller.model'
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
App.SectionsController = Ember.Controller.extend {}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
App.SectionsIndexController = Ember.Controller.extend
|
|
||||||
#needs: ['application', 'sections', 'index']
|
|
||||||
#sections: Ember.computed.alias 'controllers.sections.model'
|
|
||||||
sections_controller: Ember.inject.controller('sections')
|
|
||||||
sections: Ember.computed.alias 'sections_controller.model'
|
|
||||||
newPath: Routes.new_suppliers_section_path()
|
|
||||||
actions:
|
|
||||||
addSection: -> @modal 'add_section', model: @get('model')
|
|
||||||
goToSection: (section)->
|
|
||||||
@set 'globals.active_section', section
|
|
||||||
@transitionToRoute 'section', section.id
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
App.SettingsController = Ember.Controller.extend
|
|
||||||
#supplier: Ember.computed.alias 'globals.current_supplier'
|
|
||||||
time_zones: (-> window.time_zones ).property()
|
|
||||||
countries: (-> window.countries.map (el)-> el.name ).property()
|
|
||||||
saving: false
|
|
||||||
editIensProfile: Ember.computed 'globals.current_supplier.country', ->
|
|
||||||
@get('globals.current_supplier.country') is 'Netherlands'
|
|
||||||
actions:
|
|
||||||
saveSettings: ->
|
|
||||||
@set 'saving', true
|
|
||||||
@get('globals.current_supplier').save().then (supplier) =>
|
|
||||||
@set 'saving', false
|
|
||||||
#$('.top-menu .supplier-name').text @get('globals.current_supplier.name')
|
|
||||||
@transitionToRoute 'index'
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
App.TableController = Ember.Controller.extend
|
|
||||||
table: (-> @get('model')).property('model')
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
App.TablesIndexController = Ember.Controller.extend
|
|
||||||
tables: (-> @get('model').sortBy('casted_number')).property('model.@each.number')
|
|
||||||
actions:
|
|
||||||
newTable: ->
|
|
||||||
section = @get('globals.active_section') || @store.peekAll('section').toArray()[0]
|
|
||||||
table = @store.createRecord('table', section: section)
|
|
||||||
@modal 'table_edit',
|
|
||||||
model: table
|
|
||||||
close: -> table.deleteRecord()
|
|
||||||
destroyTable: (table)->
|
|
||||||
@modal 'confirm',
|
|
||||||
title: t('table.destroy.modal.title', number: table.get('number'))
|
|
||||||
ok: -> table.destroyRecord()
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
App.CanHelper = Ember.Helper.extend
|
|
||||||
compute: (params, options)->
|
|
||||||
[permission, resource] = params
|
|
||||||
if employee = App.__container__.lookup('global:variables').get('current_employee')
|
|
||||||
permission is "read" or (permission is "manage" and employee.isManager())
|
|
||||||
else
|
|
||||||
false
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
App.ColorboxHelper = Ember.Helper.helper (params, options)->
|
|
||||||
color = params[0]
|
|
||||||
"<span class='colorbox-container'><span style='background-color:#{color}'></span></span>".htmlSafe()
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
App.DimensionHelper = Ember.Helper.helper (params, options)->
|
|
||||||
value = params[0]
|
|
||||||
"#{value}<span class='dimension'>m</span>".htmlSafe()
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
App.DimensionsHelper = Ember.Helper.helper ([width, height], options)->
|
|
||||||
unit = options.unit || 'm'
|
|
||||||
width ||= 0
|
|
||||||
height ||= 0
|
|
||||||
width = " #{width}" if width < 10
|
|
||||||
height = " #{height}" if height < 10
|
|
||||||
"#{width} x #{height} <span class='dimension'>#{unit}</span>".htmlSafe()
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
class Distribution
|
|
||||||
##
|
|
||||||
# Distribute a section of width w and height h in a length and a width scale
|
|
||||||
# that makes n tables fit.
|
|
||||||
# distribute_lattice 10, 10, 3 #=> [5.0, 5.0]
|
|
||||||
# distribute_lattice 10, 10, 4 #=> [5.0, 5.0]
|
|
||||||
##
|
|
||||||
distribute_lattice: (w, h, n)->
|
|
||||||
epsilon = 1e-10
|
|
||||||
w = parseFloat(w)
|
|
||||||
h = parseFloat(h)
|
|
||||||
n = parseInt(n)
|
|
||||||
area = w*h
|
|
||||||
l = Math.sqrt(area/n)
|
|
||||||
nx = w/l
|
|
||||||
ny = h/l
|
|
||||||
while Math.floor(w/l + epsilon) * Math.floor(h/l + epsilon) < n
|
|
||||||
tx = w/l
|
|
||||||
ty = h/l
|
|
||||||
# The biggest remainder is closest to a fitting option
|
|
||||||
# Just add one if no remainder wins and it still is not enough
|
|
||||||
if (tx % 1) < epsilon and (ty % 1) < epsilon
|
|
||||||
# Both divide, but there is no solution yet. Just add one
|
|
||||||
l = Math.max(Math.round(w/(tx + 1)), Math.round(h/(ty + 1)))
|
|
||||||
nx = Math.ceil(tx)
|
|
||||||
ny = Math.ceil(ny)
|
|
||||||
else if (tx % 1) > (ty % 1)
|
|
||||||
nx = Math.ceil(tx)
|
|
||||||
ny = Math.ceil(n/nx)
|
|
||||||
l = w/nx
|
|
||||||
else
|
|
||||||
ny = Math.ceil(ty)
|
|
||||||
nx = Math.ceil(n/ny)
|
|
||||||
l = h/ny
|
|
||||||
[w/nx, h/ny]
|
|
||||||
App.Distribution = new Distribution()
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
App.ErrorsHelper = Ember.Helper.helper (params, options)->
|
|
||||||
errors = params[0]
|
|
||||||
return "" unless errors and errors.length
|
|
||||||
result = ""
|
|
||||||
model_name = options.includeAttribute
|
|
||||||
for error in errors
|
|
||||||
if typeof error is "string"
|
|
||||||
message = error
|
|
||||||
else
|
|
||||||
if model_name
|
|
||||||
attribute = ttry("attributes.#{model_name}.#{error.attribute}")
|
|
||||||
message = "#{attribute} #{error.message}"
|
|
||||||
else
|
|
||||||
message = error.message
|
|
||||||
result += "<div class='error'>#{message}</div>"
|
|
||||||
result.htmlSafe()
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
App.FlagHelper = Ember.Helper.helper (params, options)->
|
|
||||||
locale = params[0]
|
|
||||||
"<img src=\"#{$assets_path}supplier/flags/flag-#{locale}.png\">".htmlSafe()
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
App.GravatarImageHelper = Ember.Helper.helper (params, options)->
|
|
||||||
email = params[0]
|
|
||||||
size = options.size || 48
|
|
||||||
gravatar_hash = md5(String(email).trim().toLowerCase())
|
|
||||||
"<img src='http://www.gravatar.com/avatar/#{gravatar_hash}?s=#{size}' />".htmlSafe()
|
|
||||||
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
App.IsEqualHelper = Ember.Helper.helper ([lhs, rhs])->
|
|
||||||
lhs is rhs
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
App.IsNotHelper = Ember.Helper.helper ([value])->
|
|
||||||
return !value
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
## Used to be able to use DS.attr('moment')
|
|
||||||
App.MomentTransform = DS.Transform.extend
|
|
||||||
deserialize: (serialized)->
|
|
||||||
return serialized unless serialized
|
|
||||||
m = moment(serialized)
|
|
||||||
m._ambigTime = true if serialized.length < 11
|
|
||||||
m
|
|
||||||
|
|
||||||
serialize: (deserialized)->
|
|
||||||
return deserialized unless deserialized
|
|
||||||
deserialized = moment(deserialized) unless moment.isMoment(deserialized)
|
|
||||||
return deserialized.format('YYYY-MM-DD') if deserialized._ambigTime # dates do not flip time zone!!!!!!!
|
|
||||||
deserialized.toISOString()
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#Ember.Handlebars.registerHelper 'page-body-helper', (resource, params..., options)->
|
|
||||||
# body = @get resource
|
|
||||||
# template = Ember.Handlebars.compile('body')
|
|
||||||
# body.htmlSafe()
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
App.ReadPathHelper = Ember.Helper.helper ([object, path])->
|
|
||||||
Ember.get(object, path)
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#Ember.Handlebars.registerHelper 'route', (route_name, params..., options)->
|
|
||||||
# opts = options.hash
|
|
||||||
# if scope = @get('content')
|
|
||||||
# params = params.map (a) -> scope.get(a)
|
|
||||||
# for k,v of opts
|
|
||||||
# opts[k] = scope.get(v) if typeof(v) == 'string' && scope.get(v)
|
|
||||||
# route = if params.length then Routes[route_name].call(this, params, opts) else Routes[route_name].call(this, opts)
|
|
||||||
# new Handlebars.SafeString route
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#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}'")
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#Ember.Handlebars.helper 'select-hour', (params..., options)->
|
|
||||||
# result = "<select class=\"select-hour\">"
|
|
||||||
# result += "<option>#{hour}</option>" for hour in [0..24]
|
|
||||||
# result += "</select>"
|
|
||||||
# new Handlebars.SafeString result
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#Ember.Handlebars.helper 'select-minute', (params..., options)->
|
|
||||||
# result = "<select class=\"select-minute\">"
|
|
||||||
# result += "<option>#{minute}</option>" for minute in [0..24]
|
|
||||||
# result += "</select>"
|
|
||||||
# new Handlebars.SafeString result
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
App.SvgHelper = Ember.Helper.helper (params, options)->
|
|
||||||
content = params[0]
|
|
||||||
width = options.width
|
|
||||||
height = options.height
|
|
||||||
angle = options.rotation || 0
|
|
||||||
box_size = Math.sqrt((width * width) + (height * height))
|
|
||||||
svg_head = "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 #{box_size} #{box_size}\">"
|
|
||||||
group_head = "<g transform=\"translate(#{(box_size - width)/2}, #{(box_size - height)/2}) rotate(#{angle} #{width/2} #{height/2})\">"
|
|
||||||
"#{svg_head}#{group_head}#{content}</g></svg>".htmlSafe()
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
App.TableNumberHelper = Ember.Helper.helper (params, options)->
|
|
||||||
table_number = params[0]
|
|
||||||
return '' unless table_number
|
|
||||||
"# #{table_number}".htmlSafe()
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
Globals = Ember.Object.extend
|
|
||||||
current_employee: null
|
|
||||||
current_supplier: null
|
|
||||||
isDragging: false
|
|
||||||
active_section: null
|
|
||||||
flash_message: ''
|
|
||||||
modal_active: false
|
|
||||||
locale: Qstorage.getItem('locale')
|
|
||||||
App.initializer
|
|
||||||
name: 'injectCurrent'
|
|
||||||
initialize: (container, app)->
|
|
||||||
#container.optionsForType 'globals', instantiate: false, singleton: true
|
|
||||||
app.register 'global:variables', Globals, singleton: true
|
|
||||||
|
|
||||||
app.inject 'controller', 'globals', 'global:variables'
|
|
||||||
app.inject 'component', 'globals', 'global:variables'
|
|
||||||
app.inject 'view', 'globals', 'global:variables'
|
|
||||||
app.inject 'route', 'globals', 'global:variables'
|
|
||||||
|
|
||||||
app.inject 'component', 'store', 'service:store'
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
# on why local storage is used in the enter events
|
|
||||||
# http://stackoverflow.com/questions/8762635/getting-the-filename-during-the-dragenter-event
|
|
||||||
DragNDrop = Ember.Namespace.create
|
|
||||||
cancel: (e)->
|
|
||||||
e.preventDefault()
|
|
||||||
false
|
|
||||||
nothing: ->
|
|
||||||
|
|
||||||
DragNDrop.Draggable = Ember.Mixin.create
|
|
||||||
attributeBindings: 'draggable'
|
|
||||||
draggable: 'true'
|
|
||||||
dragStart: (ev)->
|
|
||||||
@set 'isDragging', true
|
|
||||||
@set 'globals.isDragging', true
|
|
||||||
localStorage.setItem('draggingView', @get('elementId'))
|
|
||||||
dataTransfer = ev.originalEvent.dataTransfer
|
|
||||||
#dataTransfer.setData 'Text', @get('elementId')
|
|
||||||
offset = $(ev.target).offset()
|
|
||||||
dataTransfer.setData 'application/json', JSON.stringify
|
|
||||||
id: @get('elementId')
|
|
||||||
elementX: (ev.originalEvent.offsetX || ev.originalEvent.clientX) - offset.left
|
|
||||||
elementY: (ev.originalEvent.offsetY || ev.originalEvent.clientY) - offset.top
|
|
||||||
pageX: ev.originalEvent.pageX
|
|
||||||
pageY: ev.originalEvent.pageY
|
|
||||||
dragEnd: (e)->
|
|
||||||
@set 'isDragging', false
|
|
||||||
@set 'globals.isDragging', false
|
|
||||||
localStorage.removeItem 'draggingView' if localStorage.getItem 'draggingView'
|
|
||||||
touchStart: (ev)->
|
|
||||||
ev.preventDefault()
|
|
||||||
target = @$()
|
|
||||||
touch = ev.originalEvent.changedTouches[0]
|
|
||||||
@touchStartEvent =
|
|
||||||
left: parseFloat(target.css('left'))
|
|
||||||
top: parseFloat(target.css('top'))
|
|
||||||
pageX: touch.pageX
|
|
||||||
pageY: touch.pageY
|
|
||||||
return unless target.prop 'draggable'
|
|
||||||
|
|
||||||
touchMove: (ev)->
|
|
||||||
ev.preventDefault()
|
|
||||||
target = @$()
|
|
||||||
return unless target.prop 'draggable'
|
|
||||||
if ev.originalEvent.changedTouches.length is 1
|
|
||||||
touch = ev.originalEvent.changedTouches[0]
|
|
||||||
target.css
|
|
||||||
left: "#{@touchStartEvent.left + touch.pageX - @touchStartEvent.pageX}px"
|
|
||||||
top: "#{@touchStartEvent.top + touch.pageY - @touchStartEvent.pageY}px"
|
|
||||||
touchEnd: (ev)->
|
|
||||||
ev.preventDefault()
|
|
||||||
touch = ev.originalEvent.changedTouches[0]
|
|
||||||
if Math.abs(@touchStartEvent.pageX - touch.pageX) < 2 and Math.abs(@touchStartEvent.pageY - touch.pageY) < 2
|
|
||||||
# The preventDefaults are preventing the click action to fire, therefore we trigger it ourselves
|
|
||||||
# But do not trigger when a handle insed the element is clicked
|
|
||||||
#NOTE: I think that $(ev.target).click() will work for all cases, makes the code simpler,
|
|
||||||
# but no time to test that now. Tested mostly on section elements, since they are draggable, clickable
|
|
||||||
# and have subclickable buttons
|
|
||||||
unless $(ev.target).parents('.handles-inside-draggable') or $(ev.target).hasClass('handles-inside-draggable')
|
|
||||||
@click() if @click
|
|
||||||
else
|
|
||||||
$(ev.target).click()
|
|
||||||
|
|
||||||
@touchStartEvent = null
|
|
||||||
this
|
|
||||||
DragNDrop.Droppable = Ember.Mixin.create
|
|
||||||
dragEnter: (e)->
|
|
||||||
if @dragEntered
|
|
||||||
# e.preventDefault()
|
|
||||||
viewId = localStorage.getItem 'draggingView'
|
|
||||||
view = Ember.View.views[viewId]
|
|
||||||
@dragEntered view
|
|
||||||
# else
|
|
||||||
# DragNDrop.cancel(e)
|
|
||||||
dragOver: DragNDrop.cancel # don't know why, but crucial for the current way of working with section tables
|
|
||||||
# dragOver: (e)->(e.preventDefault(); false)
|
|
||||||
touchEnd: (ev)->
|
|
||||||
ev.preventDefault()
|
|
||||||
view = ev.result
|
|
||||||
return unless view._parentView
|
|
||||||
target = view.$()
|
|
||||||
return unless target.prop 'draggable'
|
|
||||||
newX = parseFloat(target.css('left'))
|
|
||||||
newY = parseFloat(target.css('top'))
|
|
||||||
return unless newX? and newY?
|
|
||||||
position =
|
|
||||||
left: newX
|
|
||||||
top: newY
|
|
||||||
@dropped view, position if @dropped
|
|
||||||
this
|
|
||||||
dragLeave: ->
|
|
||||||
if @dragLeft
|
|
||||||
@dragLeft()
|
|
||||||
drop: (ev)->
|
|
||||||
# e.preventDefault()
|
|
||||||
data = JSON.parse(ev.originalEvent.dataTransfer.getData('application/json'))
|
|
||||||
#debugger
|
|
||||||
viewRegistry = App.__container__.lookup("-view-registry:main") || Ember.View.views
|
|
||||||
#view = Ember.View.views[data.id]
|
|
||||||
return unless viewRegistry and view = viewRegistry[data.id]
|
|
||||||
view.dragEnd(ev) if view.dragEnd # not triggered on its own on drop
|
|
||||||
|
|
||||||
# Calculate the element's center drop position relative to container
|
|
||||||
el = $(view.get('element'))
|
|
||||||
offset = el.offset()
|
|
||||||
parentOffset = el.offsetParent().offset()
|
|
||||||
newX = offset.left - parentOffset.left + ev.originalEvent.pageX - data.pageX
|
|
||||||
newY = offset.top - parentOffset.top + ev.originalEvent.pageY - data.pageY
|
|
||||||
position =
|
|
||||||
left: newX
|
|
||||||
top: newY
|
|
||||||
|
|
||||||
@dropped view, position if @dropped
|
|
||||||
@dragLeft() if @dragLeft # not triggered by system itself in case of drop
|
|
||||||
false
|
|
||||||
|
|
||||||
@DragNDrop = DragNDrop
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
App.EmployeeActionsMixin = Ember.Mixin.create
|
|
||||||
actions:
|
|
||||||
newEmployee: ->
|
|
||||||
employee = @store.createRecord('employee')
|
|
||||||
@get('controller').modal 'employee_edit',
|
|
||||||
model: employee
|
|
||||||
title_path: 'employee.modal.new_title'
|
|
||||||
close: -> employee.deleteRecord()
|
|
||||||
editEmployee: (employee)->
|
|
||||||
@get('controller').modal 'employee_edit',
|
|
||||||
model: employee
|
|
||||||
title_path: 'employee.modal.edit_title'
|
|
||||||
close: -> employee.rollbackAttributes()
|
|
||||||
destroyEmployee: (employee)->
|
|
||||||
ac = @controllerFor('application')
|
|
||||||
if @get('globals.current_employee.id') isnt employee.id
|
|
||||||
ac.modal 'confirm',
|
|
||||||
title: t('employee.destroy.modal.title', employee.toJSON())
|
|
||||||
ok: -> employee.destroyRecord()
|
|
||||||
else
|
|
||||||
ac.modal 'alert',
|
|
||||||
title: 'You cannot remove yourself'
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
App.Rotation = Ember.Mixin.create
|
|
||||||
rotateLeft: ->
|
|
||||||
new_rotation = -90 + @get('rotation')
|
|
||||||
new_rotation += 360 if new_rotation < 0
|
|
||||||
@set 'rotation', new_rotation
|
|
||||||
rotateRight: ->
|
|
||||||
new_rotation = 90 + @get('rotation')
|
|
||||||
new_rotation -= 360 if new_rotation >= 360
|
|
||||||
@set 'rotation', new_rotation
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user