diff --git a/addon/adapters/application.coffee b/addon/adapters/application.coffee
index 6736064..e0eefb8 100644
--- a/addon/adapters/application.coffee
+++ b/addon/adapters/application.coffee
@@ -8,6 +8,10 @@ export default DS.JSONAPIAdapter.extend DataAdapterMixin,
namespace: config.apiNamespace
host: config.apiHost
authorizer: 'authorizer:devise'
+ headers: Ember.computed 'session.data.authenticated.access_token', ->
+ headers = {}
+ headers['Authorization'] = "Bearer #{@session.data.authenticated.token}" if @session.isAuthenticated
+ headers
#pathForType: (type)->
# type.underscore().pluralize()
@@ -42,14 +46,14 @@ export default DS.JSONAPIAdapter.extend DataAdapterMixin,
switch status
when 401, 403
application_route = Ember.getOwner(@).lookup('route:application')
- application_route.set 'router.globals.flash_message', "Unauthorized action"
+ application_route.set 'globals.flash_message', "Unauthorized action"
#@get('session')?.invalidate()
- #application_route.set 'router.globals.current_user', null
+ #application_route.set 'globals.current_user', null
#application_route.transitionTo('login')
else
if typeof(payload?.error) is 'string'
application_route = Ember.getOwner(@).lookup('route:application')
- application_route.set 'router.globals.flash_message', payload.error
+ application_route.set 'globals.flash_message', payload.error
@_super arguments...
#buildURL: (modelName, id, snapshot, requestType, query)->
diff --git a/addon/components/editable-attribute.coffee b/addon/components/editable-attribute.coffee
index 37f2991..aa1575e 100644
--- a/addon/components/editable-attribute.coffee
+++ b/addon/components/editable-attribute.coffee
@@ -1,5 +1,6 @@
import Ember from 'ember'
import layout from '../templates/components/editable-attribute'
+#NOTE: this is an aged component locked to model and name. Needs more to be used differently, and name does not reflect it's function (Benjamin: 2019-12-21)
export default Ember.Component.extend
layout: layout
@@ -22,7 +23,7 @@ export default Ember.Component.extend
model = @get('model')
@set 'validation_message', ''
if validate = @get('validate')
- @set 'validation_message', 'Must be given' if validate is 'presence' and not @get('model.name')
+ @set 'validation_message', 'Must be given' if validate is 'presence' and not @get("model.#{@get 'attributeName'}")
unless @get 'validation_message'
@set 'isEditing', false
model.save()
diff --git a/addon/components/ui-calendar-moment.coffee b/addon/components/ui-calendar-moment.coffee
index 02749c6..038c7df 100644
--- a/addon/components/ui-calendar-moment.coffee
+++ b/addon/components/ui-calendar-moment.coffee
@@ -1,5 +1,5 @@
import Ember from 'ember'
-import UiCalendarComponent from 'ember-semantic-ui-calendar/components/ui-calendar'
+import UiCalendarComponent from 'fomantic-ui-ember/components/ui-calendar'
{ computed, inject, merge } = Ember
export default UiCalendarComponent.extend
momentValue: null
@@ -21,4 +21,3 @@ export default UiCalendarComponent.extend
momentDate = if date then moment(date) else null
momentDate._ambigTime = true if momentDate and @get('is_date')
@sendAction 'onChange', momentDate
-
diff --git a/addon/initializers/ember-cli-dunlop-overrides.coffee b/addon/initializers/ember-cli-dunlop-overrides.coffee
index 272f03d..dd76480 100644
--- a/addon/initializers/ember-cli-dunlop-overrides.coffee
+++ b/addon/initializers/ember-cli-dunlop-overrides.coffee
@@ -1,8 +1,9 @@
-import ComponentOverrides from 'ember-cli-dunlop/overrides/component'
-import ControllerOverrides from 'ember-cli-dunlop/overrides/controller'
-import ObjectOverrides from 'ember-cli-dunlop/overrides/object'
-import RouteOverrides from 'ember-cli-dunlop/overrides/route'
-import DunlopTranslationFunctions from 'ember-cli-dunlop/dunlop-translations/global-functions'
+import 'ember-cli-dunlop/overrides/component'
+import 'ember-cli-dunlop/overrides/model'
+import 'ember-cli-dunlop/overrides/controller'
+import 'ember-cli-dunlop/overrides/object'
+import 'ember-cli-dunlop/overrides/route'
+import 'ember-cli-dunlop/dunlop-translations/global-functions'
#included: function(app) {
# this._super.included(app);
# app.import('ember-cli-dunlop/overrides/component');
diff --git a/addon/mixins/application-route.coffee b/addon/mixins/application-route.coffee
index 472ef44..084b159 100644
--- a/addon/mixins/application-route.coffee
+++ b/addon/mixins/application-route.coffee
@@ -4,8 +4,9 @@ import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mi
export default Ember.Mixin.create ApplicationRouteMixin,
current_user_loaded: (user) -> @get('initial_resources_resolve')(user)
+ router: Ember.inject.service()
beforeModel: (transition) ->
- @set 'router.globals.initial_resources_fulfilled', false
+ @set 'globals.initial_resources_fulfilled', false
time_now = new Date()
console.log "Application beforeModel"
initial_resources_loaded = new Ember.RSVP.Promise((resolve, reject) =>
@@ -13,10 +14,10 @@ export default Ember.Mixin.create ApplicationRouteMixin,
@set 'initial_resources_reject', reject
).then((resources) =>
console.log "Initial resources loaded (#{Math.round((new Date() - time_now) / 100) / 10}s)" # rounded devide by 1000
- @set 'router.globals.initial_resources_fulfilled', true
+ @set 'globals.initial_resources_fulfilled', true
).catch((reason) =>
console.log "No initial resource loading (#{Math.round((new Date() - time_now) / 100) / 10}s)" # rounded devide by 1000
- @set('router.globals.flash_message', reason) if reason
+ @set('globals.flash_message', reason) if reason
).finally -> Ember.$('#initial-loader').remove()
@set 'initial_resources_loaded_promise', initial_resources_loaded
@@ -33,10 +34,10 @@ export default Ember.Mixin.create ApplicationRouteMixin,
@get('initial_resources_resolve')() # do not halt propagation
return
@get('store').queryRecord('user', me: true).then (user) =>
- @set 'router.globals.current_user', user
+ @set 'globals.current_user', user
@current_user_loaded user # overloadable
, =>
- @set 'router.globals.current_user', null
+ @set 'globals.current_user', null
@get('initial_resources_resolve')() # no initial resources without user, do not halt application propagation (login page)
@transitionTo('login')
@@ -48,7 +49,7 @@ export default Ember.Mixin.create ApplicationRouteMixin,
if status = error.status || error?.errors?[0].status
switch parseInt(status)
when 401, 403
- @set 'router.globals.current_user', null
+ @set 'globals.current_user', null
@transitionTo 'login'
return
#when 404
@@ -63,7 +64,7 @@ export default Ember.Mixin.create ApplicationRouteMixin,
into: 'application'
outlet: 'error-handling'
controller: controller
- #@set "router.globals.flash_message", "Oops! Something went wrong!
#{error.message}".htmlSafe()
+ #@set "globals.flash_message", "Oops! Something went wrong!
#{error.message}".htmlSafe()
clear_error: ->
#@disconnectOutlet # https://github.com/emberjs/ember-inspector/issues/625
@@ -73,7 +74,7 @@ export default Ember.Mixin.create ApplicationRouteMixin,
outlet: 'error-handling'
into: 'application'
controller: 'application'
- @set 'router.globals.modal_active', false
+ @set 'globals.modal_active', false
clear_error_and_go_home: ->
@send 'clear_error'
@@ -82,8 +83,8 @@ export default Ember.Mixin.create ApplicationRouteMixin,
didTransition: ->
@_super arguments...
Ember.run.next =>
- return unless path = @get('controller.currentPath')
- @set 'router.globals.current_route', Ember.Object.create
+ return unless path = @get('router.currentRouteName')
+ @set 'globals.current_route', Ember.Object.create
path: path # a.b.c
node: path.replace(/.*\./, '') # c
primary: '.' in path
@@ -159,17 +160,17 @@ export default Ember.Mixin.create ApplicationRouteMixin,
unless partialPath
message = "Cannot find template for modal '#{modalName}'"
console.log message
- @set "router.globals.flash_message", message
+ @set "globals.flash_message", message
return
controller.set 'partialName', partialPath
- @incrementProperty 'router.globals.modals_counter'
+ @incrementProperty 'globals.modals_counter'
controller.privateWillOpenModal() # setup expected attributes to be used in willOpenModal
controller.willOpenModal() # can be implemented to setup stuff before rendering and hooks
@render 'modals/layout',
into: 'application'
outlet: 'modal'
controller: controller
- @set 'router.globals.modal_active', true
+ @set 'globals.modal_active', true
false # return false since this result will in most cases the the last statement of an action. So prevent bubbling
closeModal: ->
@@ -180,10 +181,10 @@ export default Ember.Mixin.create ApplicationRouteMixin,
outlet: 'modal'
into: 'application'
controller: 'application'
- @set 'router.globals.modal_active', false
+ @set 'globals.modal_active', false
signOut: ->
- @set 'router.globals.current_user', null
+ @set 'globals.current_user', null
@get('session').invalidate() if @get('session.isAuthenticated')
@transitionTo 'login'
try
diff --git a/addon/mixins/modal-base.coffee b/addon/mixins/modal-base.coffee
index 973f859..5941809 100644
--- a/addon/mixins/modal-base.coffee
+++ b/addon/mixins/modal-base.coffee
@@ -37,7 +37,7 @@ export default Ember.Component.extend
return partialNameTranslation.htmlSafe() if partialNameTranslation = tspan(partial_title_path, translation_params)
# @toString() =>
- underscored = component_name.underscore().replace(/\//g, '.')
+ underscored = @get('component_name').underscore().replace(/\//g, '.')
return convention_translation.htmlSafe() if convention_translation = tspan("#{underscored}.title", translation_params)
# Return a kind of humanized version of the title
@@ -123,7 +123,7 @@ export default Ember.Component.extend
# transition to top level route if current is nested inside a model.show route
if modelName = my_scope.get('model.constructor.modelName')
flat_model_name = modelName.replace(/^\w+\//, '').replace('/', '.') # panda/projec => project
- if my_scope.get('router.globals.current_route.path')?.match("^#{flat_model_name}.show")
+ if my_scope.get('globals.current_route.path')?.match("^#{flat_model_name}.show")
my_scope.get('router').transitionTo flat_model_name
if @get('model.isNew')
diff --git a/addon/overrides/model.coffee b/addon/overrides/model.coffee
new file mode 100644
index 0000000..9826dae
--- /dev/null
+++ b/addon/overrides/model.coffee
@@ -0,0 +1,9 @@
+import DS from 'ember-data'
+export default DS.Model.reopen
+ toJSON: (options = {}) ->
+ #serializer = @_internalModel.store.serializerFor('-default')
+ serializer = Ember.getOwner(@).lookup('serializer:to-json')
+ options.includeId = true if options.includeId isnt false
+ #throw "The toJSON of models (global-functionality/ember-data-overrides) changed serializer type, expected DS.JSONSerializer" unless serializer.constructor.toString() is "DS.JSONSerializer"
+ snapshot = @_internalModel.createSnapshot()
+ serializer.serialize(snapshot, options)
diff --git a/addon/templates/components/editable-attribute.emblem b/addon/templates/components/editable-attribute.emblem
index fb8a241..5ea6ea6 100644
--- a/addon/templates/components/editable-attribute.emblem
+++ b/addon/templates/components/editable-attribute.emblem
@@ -8,12 +8,12 @@
if can_make_editable
/= push-action type='edit' action='editRecord'
if isEditing
- = input value=model.name enter='saveRecord'
+ = input value=model.name enter=(action 'saveRecord')
else
span= model.name
if isEditing
.ui.action.input
- = input value=model.name enter='saveRecord'
+ = input value=model.name enter=(action 'saveRecord')
= push-action type='rollback' action='rollbackRecord'
= push-action type='destroy' action='destroyRecord'
= push-action type='save' action='saveRecord'
diff --git a/app/components/login-form.coffee b/app/components/login-form.coffee
index 390d1e2..b181488 100644
--- a/app/components/login-form.coffee
+++ b/app/components/login-form.coffee
@@ -23,7 +23,7 @@ export default Ember.Component.extend
# localStorage.setItem 'user_id', result.user_id
# @get('router').transitionTo('index').then (index_route) ->
# # do not set on globals of current route, since that one will be 'destroyed' in trasition
- # index_route.store.findRecord('user', result.user_id).then (current_user) -> index_route.set('router.globals.current_user', current_user)
+ # index_route.store.findRecord('user', result.user_id).then (current_user) -> index_route.set('globals.current_user', current_user)
## STRATEGY 2 DEVISE SESSION BASED
#uri = "#{config.apiHost}/users/sign_in.json"
diff --git a/app/serializers/to-json.coffee b/app/serializers/to-json.coffee
new file mode 100644
index 0000000..078ab80
--- /dev/null
+++ b/app/serializers/to-json.coffee
@@ -0,0 +1,8 @@
+import DS from 'ember-data'
+
+export default DS.JSONSerializer.extend
+ keyForRelationship: (key, typeClass, method) ->
+ switch typeClass
+ when 'belongsTo' then "#{key}_id"
+ else key
+ shouldSerializeHasMany: -> false
diff --git a/app/templates/components/login-form.emblem b/app/templates/components/login-form.emblem
index db0b275..48f6ef7 100644
--- a/app/templates/components/login-form.emblem
+++ b/app/templates/components/login-form.emblem
@@ -1,9 +1,9 @@
.field
.ui.left.icon.input
i.user.icon
- = input type='email' value=identification enter='submitLogin' placeholder="e-mail" class='login-email'
+ = input type='email' value=identification enter=(action 'submitLogin') placeholder="e-mail" class='login-email'
.field
.ui.left.icon.input
i.lock.icon
- = input type='password' value=password enter='submitLogin' placeholder='password' class='login-password'
+ = input type='password' value=password enter=(action 'submitLogin') placeholder='password' class='login-password'
.ui.fluid.large.orange.submit.button{action 'submitLogin'} Login
diff --git a/app/templates/components/table-filters/date-range.emblem b/app/templates/components/table-filters/date-range.emblem
index c4bbca7..c59b9cd 100644
--- a/app/templates/components/table-filters/date-range.emblem
+++ b/app/templates/components/table-filters/date-range.emblem
@@ -16,9 +16,9 @@ ui-dropdown class='basic pointing' action='nothing'
.ui.horizontal.divider= t 'date.unit.week'
.divider
.item
- .ui.input.select-week= input type='number' value=week_selector_week placeholder='week' size=3 enter='week_selector_activate'
+ .ui.input.select-week= input type='number' value=week_selector_week placeholder='week' size=3 enter=(action 'week_selector_activate')
' /
- .ui.input.select-year= input type='number' value=week_selector_year placeholder='year' size=5 enter='week_selector_activate'
+ .ui.input.select-year= input type='number' value=week_selector_year placeholder='year' size=5 enter=(action 'week_selector_activate')
if has_valid_week_selector_value
'
button.ui.mini.secondary.icon.button{action 'week_selector_activate'}: i.filter.icon
diff --git a/app/templates/components/table-filters/input.emblem b/app/templates/components/table-filters/input.emblem
index 2551528..ac223f3 100644
--- a/app/templates/components/table-filters/input.emblem
+++ b/app/templates/components/table-filters/input.emblem
@@ -1,5 +1,5 @@
.ui.fluid.icon.input
- = input value=value enter='enterPressed' placeholder=smart_placeholder
+ = input value=value enter=(action 'enterPressed') placeholder=smart_placeholder
if has_active_filter_value
i.close.action.icon{action 'clear_query'}
else if showSearchIcon
diff --git a/app/templates/components/validated-input.emblem b/app/templates/components/validated-input.emblem
index ba11488..286a1d9 100644
--- a/app/templates/components/validated-input.emblem
+++ b/app/templates/components/validated-input.emblem
@@ -4,7 +4,7 @@ if label
else
if labelPath
label= t labelPath
-one-way-input value=(get changeset attribute) update=(action 'setAttribute') onblur=(action 'validateProperty' changeset attribute) disabled=disabled onenter='inputEnter'
+one-way-input value=(get changeset attribute) update=(action 'setAttribute') onblur=(action 'validateProperty' changeset attribute) disabled=disabled onenter=(action 'inputEnter')
if (get changeset.error attribute)
each (get (get changeset.error attribute) 'validation') as |error|
diff --git a/package.json b/package.json
index 56affb3..83ea41d 100644
--- a/package.json
+++ b/package.json
@@ -19,42 +19,40 @@
"coffee": "coffee --bare --compile --watch addon"
},
"dependencies": {
- "ember-cli-babel": "^6.6.0",
- "ember-cli-emblem": "^0.9.0",
- "ember-cli-htmlbars": "^2.0.1",
- "ember-cli-sass": ">=7.0.0"
+ "ember-cli-babel": "^7.18.0",
+ "ember-cli-emblem": "^0.12.0",
+ "ember-cli-htmlbars": "^4.2.3",
+ "ember-cli-sass": "^10.0.1"
},
"devDependencies": {
"active-model-adapter": "^2.2.0",
- "broccoli-asset-rev": "^2.4.5",
- "ember-ajax": "^3.0.0",
- "ember-cli": "2.16.2",
+ "broccoli-asset-rev": "^3.0.0",
+ "ember-ajax": "^5.0.0",
+ "ember-cli": "^3.17.0",
"ember-cli-coffeescript": "^1.16.1",
- "ember-cli-dependency-checker": "^1.3.0",
- "ember-cli-eslint": "^4.2.3",
- "ember-cli-htmlbars-inline-precompile": "^1.0.2",
- "ember-cli-inject-live-reload": "^1.4.1",
- "ember-cli-mirage": "^0.4.9",
- "ember-cli-moment-shim": "^3.5.0",
- "ember-cli-pagination": "^3.0.2",
- "ember-cli-qunit": "^4.3.0",
- "ember-cli-shims": "^1.0.2",
- "ember-cli-sri": "^2.1.0",
- "ember-cli-uglify": "^1.2.0",
- "ember-composable-helpers": "^2.1.0",
- "ember-data": "^2.16.3",
- "ember-export-application-global": "^1.0.5",
- "ember-get-config": "^0.2.1",
- "ember-load-initializers": "^1.0.0",
- "ember-one-way-controls": "^2.0.1",
- "ember-resolver": "^4.5.0",
- "ember-semantic-ui-calendar": "^1.0.1",
- "ember-simple-auth": "^1.4.2",
- "ember-source": "~2.16.2",
- "ember-truth-helpers": "^1.3.0",
+ "ember-cli-dependency-checker": "^3.2.0",
+ "ember-cli-inject-live-reload": "^2.0.2",
+ "ember-cli-moment-shim": "^3.7.1",
+ "ember-cli-pagination": "^3.1.5",
+ "ember-cli-shims": "^1.2.0",
+ "ember-cli-sri": "^2.1.1",
+ "ember-cli-uglify": "^3.0.0",
+ "ember-composable-helpers": "^4.0.0",
+ "ember-data": "^3.18.0",
+ "ember-export-application-global": "^2.0.1",
+ "ember-get-config": "^0.2.4",
+ "ember-load-initializers": "^2.1.1",
+ "ember-one-way-controls": "^3.1.0",
+ "ember-qunit": "^4.6.0",
+ "ember-resolver": "^7.0.0",
+ "ember-simple-auth": "^3.0.0",
+ "ember-source": "^3.18.0",
+ "ember-truth-helpers": "^2.1.0",
+ "eslint": "^6.8.0",
+ "eslint-plugin-ember": "^7.10.1",
+ "eslint-plugin-node": "^11.0.0",
"loader.js": "^4.2.3",
- "sass": "^1.15.1",
- "semantic-ui-ember": "^3.0.3"
+ "sass": "^1.15.1"
},
"engines": {
"node": ">= 4"